diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index e508cf5b7221..bbd596015436 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -1542,7 +1542,9 @@ nsFrameLoader::TryNewProcess() return false; } - mChildProcess = ContentProcessParent::GetSingleton()->CreateTab(); + ContentProcessParent* parent = ContentProcessParent::GetSingleton(); + NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!"); + mChildProcess = parent->CreateTab(); if (mChildProcess) { nsCOMPtr element = do_QueryInterface(mOwnerContent); mChildProcess->SetOwnerElement(element); @@ -1556,6 +1558,8 @@ nsFrameLoader::TryNewProcess() nsCOMPtr browserDOMWin; rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); mChildProcess->SetBrowserDOMWindow(browserDOMWin); + + mChildHost = parent; } return true; } diff --git a/content/base/src/nsFrameLoader.h b/content/base/src/nsFrameLoader.h index d2a7e8fe7fdf..d31e25393a24 100644 --- a/content/base/src/nsFrameLoader.h +++ b/content/base/src/nsFrameLoader.h @@ -190,6 +190,7 @@ private: PRPackedBool mRemoteWidgetCreated : 1; bool mRemoteFrame; // XXX leaking + nsCOMPtr mChildHost; mozilla::dom::TabParent* mChildProcess; #ifdef MOZ_WIDGET_GTK2 diff --git a/dom/ipc/ContentProcessParent.cpp b/dom/ipc/ContentProcessParent.cpp index 1578891b51af..12035d7b93fa 100644 --- a/dom/ipc/ContentProcessParent.cpp +++ b/dom/ipc/ContentProcessParent.cpp @@ -54,10 +54,6 @@ using namespace mozilla::ipc; using namespace mozilla::net; using mozilla::MonitorAutoEnter; -namespace { -PRBool gSingletonDied = PR_FALSE; -} - namespace mozilla { namespace dom { @@ -66,7 +62,10 @@ ContentProcessParent* ContentProcessParent::gSingleton; ContentProcessParent* ContentProcessParent::GetSingleton() { - if (!gSingleton && !gSingletonDied) { + if (gSingleton && !gSingleton->IsAlive()) + gSingleton = nsnull; + + if (!gSingleton) { nsRefPtr parent = new ContentProcessParent(); if (parent) { nsCOMPtr obs = @@ -103,6 +102,8 @@ ContentProcessParent::ActorDestroy(ActorDestroyReason why) threadInt->SetObserver(mOldObserver); if (mRunToCompletionDepth) mRunToCompletionDepth = 0; + + mIsAlive = false; } TabParent* @@ -127,6 +128,7 @@ ContentProcessParent::ContentProcessParent() : mMonitor("ContentProcessParent::mMonitor") , mRunToCompletionDepth(0) , mShouldCallUnblockChild(false) + , mIsAlive(true) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content); @@ -142,9 +144,16 @@ ContentProcessParent::ContentProcessParent() ContentProcessParent::~ContentProcessParent() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - NS_ASSERTION(gSingleton == this, "More than one singleton?!"); - gSingletonDied = PR_TRUE; - gSingleton = nsnull; + //If the previous content process has died, a new one could have + //been started since. + if (gSingleton == this) + gSingleton = nsnull; +} + +bool +ContentProcessParent::IsAlive() +{ + return mIsAlive; } NS_IMPL_THREADSAFE_ISUPPORTS2(ContentProcessParent, diff --git a/dom/ipc/ContentProcessParent.h b/dom/ipc/ContentProcessParent.h index bf3fab7f0861..78b5191c30ef 100644 --- a/dom/ipc/ContentProcessParent.h +++ b/dom/ipc/ContentProcessParent.h @@ -86,6 +86,8 @@ public: void ReportChildAlreadyBlocked(); bool RequestRunToCompletion(); + bool IsAlive(); + protected: virtual void ActorDestroy(ActorDestroyReason why); @@ -117,6 +119,7 @@ private: bool mShouldCallUnblockChild; nsCOMPtr mOldObserver; + bool mIsAlive; }; } // namespace dom