b=545237 Keep track of the ContentProcessParent singleton's life and recreate it if necessary r=bsmedberg

This commit is contained in:
Josh Matthews 2010-04-12 12:24:45 +12:00
Родитель 32dc72e1a5
Коммит 5d189e4030
4 изменённых файлов: 26 добавлений и 9 удалений

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

@ -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<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
mChildProcess->SetOwnerElement(element);
@ -1556,6 +1558,8 @@ nsFrameLoader::TryNewProcess()
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
mChildProcess->SetBrowserDOMWindow(browserDOMWin);
mChildHost = parent;
}
return true;
}

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

@ -190,6 +190,7 @@ private:
PRPackedBool mRemoteWidgetCreated : 1;
bool mRemoteFrame;
// XXX leaking
nsCOMPtr<nsIObserver> mChildHost;
mozilla::dom::TabParent* mChildProcess;
#ifdef MOZ_WIDGET_GTK2

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

@ -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<ContentProcessParent> parent = new ContentProcessParent();
if (parent) {
nsCOMPtr<nsIObserverService> 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,

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

@ -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<nsIThreadObserver> mOldObserver;
bool mIsAlive;
};
} // namespace dom