Bug 1169129 - Make GMPParent hold a self ref while GMP child process is alive. r=edwin

This commit is contained in:
Chris Pearce 2015-06-05 21:55:52 +12:00
parent a78140e377
commit 0d8527a1bb
2 changed files with 20 additions and 0 deletions

View File

@ -64,6 +64,7 @@ GMPParent::GMPParent()
, mAsyncShutdownRequired(false)
, mAsyncShutdownInProgress(false)
, mChildPid(0)
, mHoldingSelfRef(false)
{
LOGD("GMPParent ctor");
mPluginId = GeckoChildProcessHost::GetUniqueID();
@ -74,6 +75,8 @@ GMPParent::~GMPParent()
// Can't Close or Destroy the process here, since destruction is MainThread only
MOZ_ASSERT(NS_IsMainThread());
LOGD("GMPParent dtor");
MOZ_ASSERT(!mProcess);
}
nsresult
@ -178,6 +181,13 @@ GMPParent::LoadProcess()
mState = GMPStateLoaded;
// Hold a self ref while the child process is alive. This ensures that
// during shutdown the GMPParent stays we stay alive long enough to
// terminate the child process.
MOZ_ASSERT(!mHoldingSelfRef);
mHoldingSelfRef = true;
AddRef();
return NS_OK;
}
@ -408,6 +418,10 @@ GMPParent::DeleteProcess()
new NotifyGMPShutdownTask(NS_ConvertUTF8toUTF16(mNodeId)),
NS_DISPATCH_NORMAL);
if (mHoldingSelfRef) {
Release();
mHoldingSelfRef = false;
}
}
GMPState

View File

@ -218,6 +218,12 @@ private:
bool mAsyncShutdownInProgress;
int mChildPid;
// We hold a self reference to ourself while the child process is alive.
// This ensures that if the GMPService tries to shut us down and drops
// its reference to us, we stay alive long enough for the child process
// to terminate gracefully.
bool mHoldingSelfRef;
};
} // namespace gmp