Bug 1522951 - Make ChromiumCDMProxy::mCrashHelper into a strong reference. r=jya

Refcounted objects should be put into refptrs when they are created.

This patch also moves the crash helper out of the object early in
Init, to maybe reduce the chance of a leak if it fails early.

This field is only used to pass in a value to the Init() method. It
can't be passed in directly because on Android there are two
implementations of CDMProxy, and MediaDrmCDMProxy doesn't take a crash
helper.

Differential Revision: https://phabricator.services.mozilla.com/D17707

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-02-01 00:20:19 +00:00
Родитель ac012b5064
Коммит f68a0b40f7
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -38,6 +38,9 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName) {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<GMPCrashHelper> helper(std::move(mCrashHelper));
NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
EME_LOG(
@ -62,7 +65,6 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
gmp::NodeId nodeId(aOrigin, aTopLevelOrigin, aGMPName);
RefPtr<AbstractThread> thread = mGMPThread;
RefPtr<GMPCrashHelper> helper(mCrashHelper);
RefPtr<ChromiumCDMProxy> self(this);
nsCString keySystem = NS_ConvertUTF16toUTF8(mKeySystem);
RefPtr<Runnable> task(NS_NewRunnableFunction(

Просмотреть файл

@ -111,7 +111,7 @@ class ChromiumCDMProxy : public CDMProxy {
~ChromiumCDMProxy();
GMPCrashHelper* mCrashHelper;
RefPtr<GMPCrashHelper> mCrashHelper;
Mutex mCDMMutex;
RefPtr<gmp::ChromiumCDMParent> mCDM;