Bug 930282: Part 3: Don't fork after xpcom shutdown. r=khuey

This commit is contained in:
Patrick Wang 2013-12-09 22:42:48 +08:00
Родитель 7ce480d354
Коммит 7069e9193c
1 изменённых файлов: 7 добавлений и 1 удалений

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

@ -88,6 +88,7 @@ private:
void ObserveProcessShutdown(nsISupports* aSubject);
bool mEnabled;
bool mShutdown;
nsRefPtr<ContentParent> mPreallocatedAppProcess;
};
@ -114,6 +115,7 @@ PreallocatedProcessManagerImpl::PreallocatedProcessManagerImpl()
, mPreallocateAppProcessTask(nullptr)
, mIsNuwaReady(false)
#endif
, mShutdown(false)
{}
void
@ -124,6 +126,8 @@ PreallocatedProcessManagerImpl::Init()
if (os) {
os->AddObserver(this, "ipc:content-shutdown",
/* weakRef = */ false);
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
/* weakRef = */ false);
}
RereadPrefs();
}
@ -138,6 +142,8 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject,
} else if (!strcmp("nsPref:changed", aTopic)) {
// The only other observer we registered was for our prefs.
RereadPrefs();
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
mShutdown = true;
} else {
MOZ_ASSERT(false);
}
@ -240,7 +246,7 @@ PreallocatedProcessManagerImpl::DelayedNuwaFork()
mPreallocateAppProcessTask = nullptr;
if (!mIsNuwaReady) {
if (!mPreallocatedAppProcess) {
if (!mPreallocatedAppProcess && !mShutdown) {
mPreallocatedAppProcess = ContentParent::RunNuwaProcess();
}
// else mPreallocatedAppProcess is starting. It will NuwaFork() when ready.