mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169129 - Make GMPParent hold a self ref while GMP child process is alive. r=edwin
This commit is contained in:
parent
a78140e377
commit
0d8527a1bb
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user