Bug 1024470 - Make sure we run InitOnContentProcessCreated in all cases. r=khuey

This commit is contained in:
"Kan-Ru Chen (陳侃如)" 2014-06-19 01:22:05 +08:00
parent c700a52d2a
commit 093e2092b9
2 changed files with 27 additions and 15 deletions

View File

@ -482,8 +482,17 @@ ContentChild* ContentChild::sSingleton;
// Performs initialization that is not fork-safe, i.e. that must be done after // Performs initialization that is not fork-safe, i.e. that must be done after
// forking from the Nuwa process. // forking from the Nuwa process.
static void static void
InitOnContentProcessCreated() InitOnContentProcessCreated(bool aAfterNuwaFork)
{ {
#ifdef MOZ_NUWA_PROCESS
// Wait until we are forked from Nuwa
if (!aAfterNuwaFork &&
Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
return;
}
#else
unused << aAfterNuwaFork;
#endif
// This will register cross-process observer. // This will register cross-process observer.
mozilla::dom::time::InitializeDateCacheCleaner(); mozilla::dom::time::InitializeDateCacheCleaner();
} }
@ -670,9 +679,7 @@ ContentChild::InitXPCOM()
new SystemMessageHandledObserver(); new SystemMessageHandledObserver();
sysMsgObserver->Init(); sysMsgObserver->Init();
#ifndef MOZ_NUWA_PROCESS InitOnContentProcessCreated(/* aAfterNuwaFork = */false);
InitOnContentProcessCreated();
#endif
} }
PMemoryReportRequestChild* PMemoryReportRequestChild*
@ -1843,7 +1850,7 @@ public:
} }
// Perform other after-fork initializations. // Perform other after-fork initializations.
InitOnContentProcessCreated(); InitOnContentProcessCreated(/* aAfterNuwaFork = */true);
return NS_OK; return NS_OK;
} }

View File

@ -602,14 +602,20 @@ ContentParent::MaybeTakePreallocatedAppProcess(const nsAString& aAppManifestURL,
/*static*/ void /*static*/ void
ContentParent::StartUp() ContentParent::StartUp()
{ {
// We could launch sub processes from content process
// FIXME Bug 1023701 - Stop using ContentParent static methods in
// child process
sCanLaunchSubprocesses = true;
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return;
}
// Note: This reporter measures all ContentParents. // Note: This reporter measures all ContentParents.
RegisterStrongMemoryReporter(new ContentParentsMemoryReporter()); RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());
mozilla::dom::time::InitializeDateCacheCleaner(); mozilla::dom::time::InitializeDateCacheCleaner();
sCanLaunchSubprocesses = true;
if (XRE_GetProcessType() == GeckoProcessType_Default) {
BackgroundChild::Startup(); BackgroundChild::Startup();
// Try to preallocate a process that we can transform into an app later. // Try to preallocate a process that we can transform into an app later.
@ -618,7 +624,6 @@ ContentParent::StartUp()
// Test the PBackground infrastructure on ENABLE_TESTS builds when a special // Test the PBackground infrastructure on ENABLE_TESTS builds when a special
// testing preference is set. // testing preference is set.
MaybeTestPBackground(); MaybeTestPBackground();
}
} }
/*static*/ void /*static*/ void