Bug 645359 - Need to call Init after there's a global ContentParent available for use in observers. r=startup-bustage
authorJosh Matthews <josh@joshmatthews.net>
Sat, 26 Mar 2011 16:16:45 -0400
changeset 63976 fbe53bc0d7f62aab6198e86df27202823a483672
parent 63975 497e9a9d5982259264b3f0611793eb18bb706ab3
child 63977 5b6c6ecb4cae38dbee8e66cab4876f169196537f
child 64022 6854c982a6be8c4ab273ced37e44ce4c0c5424c5
push idunknown
push userunknown
push dateunknown
reviewersstartup-bustage
bugs645359
milestone2.2a1pre
first release with
nightly linux32
fbe53bc0d7f6 / 4.2a1pre / 20110327030428 / files
nightly linux64
fbe53bc0d7f6 / 4.2a1pre / 20110327030428 / files
nightly mac
fbe53bc0d7f6 / 4.2a1pre / 20110327030428 / files
nightly win32
fbe53bc0d7f6 / 4.2a1pre / 20110327030428 / files
nightly win64
fbe53bc0d7f6 / 4.2a1pre / 20110327030202 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 645359 - Need to call Init after there's a global ContentParent available for use in observers. r=startup-bustage
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -153,18 +153,21 @@ MemoryReportRequestParent::~MemoryReport
 ContentParent* ContentParent::gSingleton;
 
 ContentParent*
 ContentParent::GetSingleton(PRBool aForceNew)
 {
     if (gSingleton && !gSingleton->IsAlive())
         gSingleton = nsnull;
     
-    if (!gSingleton && aForceNew)
-        gSingleton = new ContentParent();
+    if (!gSingleton && aForceNew) {
+        nsRefPtr<ContentParent> parent = new ContentParent();
+        gSingleton = parent;
+        parent->Init();
+    }
 
     return gSingleton;
 }
 
 void
 ContentParent::Init()
 {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@@ -339,18 +342,16 @@ ContentParent::ContentParent()
     mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content);
     mSubprocess->AsyncLaunch();
     Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
 
     nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
     nsChromeRegistryChrome* chromeRegistry =
         static_cast<nsChromeRegistryChrome*>(registrySvc.get());
     chromeRegistry->SendRegisteredChrome(this);
-
-    Init();
 }
 
 ContentParent::~ContentParent()
 {
     if (OtherProcess())
         base::CloseProcessHandle(OtherProcess());
 
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");