зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1810817 - p1: move common CDM proxy functions around. r=alwu
Move identical virtual function implementations that access protected data members in the base class to there. Also protect the constructor because it's only meant for the derived classes. Differential Revision: https://phabricator.services.mozilla.com/D167055
This commit is contained in:
Родитель
347a2b16c4
Коммит
87826ac75d
|
@ -80,18 +80,6 @@ class CDMProxy {
|
|||
public:
|
||||
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
||||
|
||||
// Main thread only.
|
||||
CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
|
||||
bool aDistinctiveIdentifierRequired, bool aPersistentStateRequired)
|
||||
: mKeys(aKeys),
|
||||
mKeySystem(aKeySystem),
|
||||
mCapabilites("CDMProxy::mCDMCaps"),
|
||||
mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired),
|
||||
mPersistentStateRequired(aPersistentStateRequired),
|
||||
mMainThread(GetMainThreadSerialEventTarget()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
// Main thread only.
|
||||
// Loads the CDM corresponding to mKeySystem.
|
||||
// Calls MediaKeys::OnCDMCreated() when the CDM is created.
|
||||
|
@ -192,7 +180,7 @@ class CDMProxy {
|
|||
virtual void Terminated() = 0;
|
||||
|
||||
// Threadsafe.
|
||||
virtual const nsCString& GetNodeId() const = 0;
|
||||
const nsCString& GetNodeId() const { return mNodeId; };
|
||||
|
||||
// Main thread only.
|
||||
virtual void OnSetSessionId(uint32_t aCreateSessionToken,
|
||||
|
@ -239,9 +227,9 @@ class CDMProxy {
|
|||
virtual void ResolvePromise(PromiseId aId) = 0;
|
||||
|
||||
// Threadsafe.
|
||||
virtual const nsString& KeySystem() const = 0;
|
||||
const nsString& KeySystem() const { return mKeySystem; };
|
||||
|
||||
virtual DataMutex<CDMCaps>& Capabilites() = 0;
|
||||
DataMutex<CDMCaps>& Capabilites() { return mCapabilites; };
|
||||
|
||||
// Main thread only.
|
||||
virtual void OnKeyStatusesChange(const nsAString& aSessionId) = 0;
|
||||
|
@ -259,6 +247,18 @@ class CDMProxy {
|
|||
virtual ChromiumCDMProxy* AsChromiumCDMProxy() { return nullptr; }
|
||||
|
||||
protected:
|
||||
// Main thread only.
|
||||
CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
|
||||
bool aDistinctiveIdentifierRequired, bool aPersistentStateRequired)
|
||||
: mKeys(aKeys),
|
||||
mKeySystem(aKeySystem),
|
||||
mCapabilites("CDMProxy::mCDMCaps"),
|
||||
mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired),
|
||||
mPersistentStateRequired(aPersistentStateRequired),
|
||||
mMainThread(GetMainThreadSerialEventTarget()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
virtual ~CDMProxy() {}
|
||||
|
||||
// Helper to enforce that a raw pointer is only accessed on the main thread.
|
||||
|
|
|
@ -176,8 +176,6 @@ void MediaDrmCDMProxy::Terminated() {
|
|||
// Should find a way to handle the case when remote side MediaDrm crashed.
|
||||
}
|
||||
|
||||
const nsCString& MediaDrmCDMProxy::GetNodeId() const { return mNodeId; }
|
||||
|
||||
void MediaDrmCDMProxy::OnSetSessionId(uint32_t aCreateSessionToken,
|
||||
const nsAString& aSessionId) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -322,10 +320,6 @@ void MediaDrmCDMProxy::ResolvePromiseWithResult(PromiseId aId,
|
|||
mMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
const nsString& MediaDrmCDMProxy::KeySystem() const { return mKeySystem; }
|
||||
|
||||
DataMutex<CDMCaps>& MediaDrmCDMProxy::Capabilites() { return mCapabilites; }
|
||||
|
||||
void MediaDrmCDMProxy::OnKeyStatusesChange(const nsAString& aSessionId) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mKeys.IsNull()) {
|
||||
|
|
|
@ -63,8 +63,6 @@ class MediaDrmCDMProxy : public CDMProxy {
|
|||
|
||||
void Terminated() override;
|
||||
|
||||
const nsCString& GetNodeId() const override;
|
||||
|
||||
void OnSetSessionId(uint32_t aCreateSessionToken,
|
||||
const nsAString& aSessionId) override;
|
||||
|
||||
|
@ -98,11 +96,6 @@ class MediaDrmCDMProxy : public CDMProxy {
|
|||
// Can be called from any thread.
|
||||
void ResolvePromise(PromiseId aId) override;
|
||||
|
||||
// Threadsafe.
|
||||
const nsString& KeySystem() const override;
|
||||
|
||||
DataMutex<CDMCaps>& Capabilites() override;
|
||||
|
||||
void OnKeyStatusesChange(const nsAString& aSessionId) override;
|
||||
|
||||
void GetStatusForPolicy(PromiseId aPromiseId,
|
||||
|
|
|
@ -470,8 +470,6 @@ void ChromiumCDMProxy::ResolvePromise(PromiseId aId) {
|
|||
}
|
||||
}
|
||||
|
||||
const nsCString& ChromiumCDMProxy::GetNodeId() const { return mNodeId; }
|
||||
|
||||
void ChromiumCDMProxy::OnSetSessionId(uint32_t aCreateSessionToken,
|
||||
const nsAString& aSessionId) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -590,10 +588,6 @@ void ChromiumCDMProxy::OnRejectPromise(uint32_t aPromiseId,
|
|||
RejectPromise(aPromiseId, std::move(aException), aMsg);
|
||||
}
|
||||
|
||||
const nsString& ChromiumCDMProxy::KeySystem() const { return mKeySystem; }
|
||||
|
||||
DataMutex<CDMCaps>& ChromiumCDMProxy::Capabilites() { return mCapabilites; }
|
||||
|
||||
RefPtr<DecryptPromise> ChromiumCDMProxy::Decrypt(MediaRawData* aSample) {
|
||||
RefPtr<gmp::ChromiumCDMParent> cdm = GetCDMParent();
|
||||
if (!cdm) {
|
||||
|
|
|
@ -59,8 +59,6 @@ class ChromiumCDMProxy : public CDMProxy {
|
|||
|
||||
void Terminated() override;
|
||||
|
||||
const nsCString& GetNodeId() const override;
|
||||
|
||||
void OnSetSessionId(uint32_t aCreateSessionToken,
|
||||
const nsAString& aSessionId) override;
|
||||
|
||||
|
@ -97,10 +95,6 @@ class ChromiumCDMProxy : public CDMProxy {
|
|||
|
||||
void ResolvePromise(PromiseId aId) override;
|
||||
|
||||
const nsString& KeySystem() const override;
|
||||
|
||||
DataMutex<CDMCaps>& Capabilites() override;
|
||||
|
||||
void OnKeyStatusesChange(const nsAString& aSessionId) override;
|
||||
|
||||
void GetStatusForPolicy(PromiseId aPromiseId,
|
||||
|
|
Загрузка…
Ссылка в новой задаче