mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1397214 - Prevent ContentChild::RecvSetXPCOMProcessAttributes from running after shutdown. r=ehsan
Since ContentChild itself may be created before the observer service is started, we cannot create an observer to simply listen for the xpcom-shutdown event. Thankfully we do not need to do anything special upon receiving the event -- we just need to know if it has been fired when we called RecvSetXPCOMProcessAttributes. As such, this patch creates a canary using ClearOnShutdown. If the canary is cleared, then we know xpcom-shutdown has been issued, and we should abort the initialization process. fixup
This commit is contained in:
parent
400f2bdf9d
commit
132cacdc6f
@ -516,7 +516,11 @@ PendingInputEventHangAnnotator PendingInputEventHangAnnotator::sSingleton;
|
||||
|
||||
NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
|
||||
|
||||
class ContentChild::ShutdownCanary final
|
||||
{ };
|
||||
|
||||
ContentChild* ContentChild::sSingleton;
|
||||
StaticAutoPtr<ContentChild::ShutdownCanary> ContentChild::sShutdownCanary;
|
||||
|
||||
ContentChild::ContentChild()
|
||||
: mID(uint64_t(-1))
|
||||
@ -530,6 +534,16 @@ ContentChild::ContentChild()
|
||||
// This process is a content process, so it's clearly running in
|
||||
// multiprocess mode!
|
||||
nsDebugImpl::SetMultiprocessMode("Child");
|
||||
|
||||
// When ContentChild is created, the observer service does not even exist.
|
||||
// When ContentChild::RecvSetXPCOMProcessAttributes is called (the first
|
||||
// IPDL call made on this object), shutdown may have already happened. Thus
|
||||
// we create a canary here that relies upon getting cleared if shutdown
|
||||
// happens without requiring the observer service at this time.
|
||||
if (!sShutdownCanary) {
|
||||
sShutdownCanary = new ShutdownCanary();
|
||||
ClearOnShutdown(&sShutdownCanary, ShutdownPhase::Shutdown);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -561,6 +575,10 @@ ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
|
||||
nsTArray<FontFamilyListEntry>&& aFontFamilyList)
|
||||
{
|
||||
if (!sShutdownCanary) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mLookAndFeelCache = Move(aLookAndFeelIntCache);
|
||||
mFontFamilies = Move(aFontFamilyList);
|
||||
gfx::gfxVars::SetValuesForInitialize(aXPCOMInit.gfxNonDefaultVarUpdates());
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/dom/nsIContentChild.h"
|
||||
#include "mozilla/dom/PBrowserOrId.h"
|
||||
#include "mozilla/dom/PContentChild.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIObserver.h"
|
||||
@ -773,6 +774,9 @@ private:
|
||||
|
||||
static ContentChild* sSingleton;
|
||||
|
||||
class ShutdownCanary;
|
||||
static StaticAutoPtr<ShutdownCanary> sShutdownCanary;
|
||||
|
||||
nsCOMPtr<nsIDomainPolicy> mPolicy;
|
||||
nsCOMPtr<nsITimer> mForceKillTimer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user