зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522951 - Get rid of ChromiumCDMProxy::mCrashHelper. r=jya
This field is only used to pass a pointer from the ctor to the Init() method. Instead, just pass in the crash helper directly. This avoids some problems with the existing code where the crash helper is not AddRefed immediately after creation, which could lead to leaks in some error cases. Differential Revision: https://phabricator.services.mozilla.com/D17707 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
90b3961ab4
Коммит
4ec91b01d2
|
@ -93,8 +93,8 @@ class CDMProxy {
|
|||
// Main thread only.
|
||||
// Loads the CDM corresponding to mKeySystem.
|
||||
// Calls MediaKeys::OnCDMCreated() when the CDM is created.
|
||||
virtual void Init(PromiseId aPromiseId, const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
virtual void Init(RefPtr<GMPCrashHelper>&& aCrashHelper, PromiseId aPromiseId,
|
||||
const nsAString& aOrigin, const nsAString& aTopLevelOrigin,
|
||||
const nsAString& aName) = 0;
|
||||
|
||||
virtual void OnSetDecryptorId(uint32_t aId) {}
|
||||
|
|
|
@ -320,7 +320,7 @@ already_AddRefed<CDMProxy> MediaKeys::CreateCDMProxy(
|
|||
#endif
|
||||
{
|
||||
proxy = new ChromiumCDMProxy(
|
||||
this, mKeySystem, new MediaKeysGMPCrashHelper(this),
|
||||
this, mKeySystem,
|
||||
mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required,
|
||||
mConfig.mPersistentState == MediaKeysRequirement::Required,
|
||||
aMainThread);
|
||||
|
@ -408,9 +408,10 @@ already_AddRefed<DetailedPromise> MediaKeys::Init(ErrorResult& aRv) {
|
|||
MOZ_ASSERT(!mCreatePromiseId, "Should only be created once!");
|
||||
mCreatePromiseId = StorePromise(promise);
|
||||
AddRef();
|
||||
mProxy->Init(mCreatePromiseId, NS_ConvertUTF8toUTF16(origin),
|
||||
NS_ConvertUTF8toUTF16(topLevelOrigin),
|
||||
KeySystemToGMPName(mKeySystem));
|
||||
RefPtr<MediaKeysGMPCrashHelper> helper = new MediaKeysGMPCrashHelper(this);
|
||||
mProxy->Init(
|
||||
std::move(helper), mCreatePromiseId, NS_ConvertUTF8toUTF16(origin),
|
||||
NS_ConvertUTF8toUTF16(topLevelOrigin), KeySystemToGMPName(mKeySystem));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
|
|
@ -19,13 +19,11 @@ namespace mozilla {
|
|||
|
||||
ChromiumCDMProxy::ChromiumCDMProxy(dom::MediaKeys* aKeys,
|
||||
const nsAString& aKeySystem,
|
||||
GMPCrashHelper* aCrashHelper,
|
||||
bool aDistinctiveIdentifierRequired,
|
||||
bool aPersistentStateRequired,
|
||||
nsIEventTarget* aMainThread)
|
||||
: CDMProxy(aKeys, aKeySystem, aDistinctiveIdentifierRequired,
|
||||
aPersistentStateRequired, aMainThread),
|
||||
mCrashHelper(aCrashHelper),
|
||||
mCDMMutex("ChromiumCDMProxy"),
|
||||
mGMPThread(GetGMPAbstractThread()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -34,7 +32,8 @@ ChromiumCDMProxy::ChromiumCDMProxy(dom::MediaKeys* aKeys,
|
|||
|
||||
ChromiumCDMProxy::~ChromiumCDMProxy() { MOZ_COUNT_DTOR(ChromiumCDMProxy); }
|
||||
|
||||
void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
|
||||
void ChromiumCDMProxy::Init(RefPtr<GMPCrashHelper>&& aCrashHelper,
|
||||
PromiseId aPromiseId, const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
const nsAString& aGMPName) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -62,7 +61,7 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
|
|||
|
||||
gmp::NodeId nodeId(aOrigin, aTopLevelOrigin, aGMPName);
|
||||
RefPtr<AbstractThread> thread = mGMPThread;
|
||||
RefPtr<GMPCrashHelper> helper(mCrashHelper);
|
||||
RefPtr<GMPCrashHelper> helper(std::move(aCrashHelper));
|
||||
RefPtr<ChromiumCDMProxy> self(this);
|
||||
nsCString keySystem = NS_ConvertUTF16toUTF8(mKeySystem);
|
||||
RefPtr<Runnable> task(NS_NewRunnableFunction(
|
||||
|
|
|
@ -21,12 +21,11 @@ class ChromiumCDMProxy : public CDMProxy {
|
|||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChromiumCDMProxy, override)
|
||||
|
||||
ChromiumCDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem,
|
||||
GMPCrashHelper* aCrashHelper,
|
||||
bool aAllowDistinctiveIdentifier, bool aAllowPersistentState,
|
||||
nsIEventTarget* aMainThread);
|
||||
|
||||
void Init(PromiseId aPromiseId, const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
void Init(RefPtr<GMPCrashHelper>&& aCrashHelper, PromiseId aPromiseId,
|
||||
const nsAString& aOrigin, const nsAString& aTopLevelOrigin,
|
||||
const nsAString& aGMPName) override;
|
||||
|
||||
void CreateSession(uint32_t aCreateSessionToken,
|
||||
|
@ -111,8 +110,6 @@ class ChromiumCDMProxy : public CDMProxy {
|
|||
|
||||
~ChromiumCDMProxy();
|
||||
|
||||
GMPCrashHelper* mCrashHelper;
|
||||
|
||||
Mutex mCDMMutex;
|
||||
RefPtr<gmp::ChromiumCDMParent> mCDM;
|
||||
RefPtr<AbstractThread> mGMPThread;
|
||||
|
|
Загрузка…
Ссылка в новой задаче