Bug 1448125 - Move calls to ContentParent::Init into LaunchSubprocess; r?jld draft
authorAlex Gaynor <agaynor@mozilla.com>
Thu, 22 Mar 2018 16:02:57 -0400
changeset 771237 9944a62024f6b342427a6b012cc7e1d89ed06fe6
parent 771093 7771df14ea181add1dc4133f0f5559bf620bf976
push id103625
push userbmo:agaynor@mozilla.com
push dateThu, 22 Mar 2018 20:04:06 +0000
reviewersjld
bugs1448125
milestone61.0a1
Bug 1448125 - Move calls to ContentParent::Init into LaunchSubprocess; r?jld Every LaunchSubprocess caller immediatelly calls Init afterwards MozReview-Commit-ID: LATClQzWfyg
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -604,17 +604,16 @@ ContentParent::PreallocateProcess()
                       NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
 
   PreallocatedProcessManager::AddBlocker(process);
 
   if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
     return nullptr;
   }
 
-  process->Init();
   return process.forget();
 }
 
 /*static*/ void
 ContentParent::StartUp()
 {
   // We could launch sub processes from content process
   // FIXME Bug 1023701 - Stop using ContentParent static methods in
@@ -831,18 +830,16 @@ ContentParent::GetNewOrUsedBrowserProces
 
   // Until the new process is ready let's not allow to start up any preallocated processes.
   PreallocatedProcessManager::AddBlocker(p);
 
   if (!p->LaunchSubprocess(aPriority)) {
     return nullptr;
   }
 
-  p->Init();
-
   contentParents.AppendElement(p);
   p->mActivateTS = TimeStamp::Now();
   return p.forget();
 }
 
 /*static*/ already_AddRefed<ContentParent>
 ContentParent::GetNewOrUsedJSPluginProcess(uint32_t aPluginID,
                                            const hal::ProcessPriority& aPriority)
@@ -860,18 +857,16 @@ ContentParent::GetNewOrUsedJSPluginProce
   }
 
   p = new ContentParent(aPluginID);
 
   if (!p->LaunchSubprocess(aPriority)) {
     return nullptr;
   }
 
-  p->Init();
-
   sJSPluginContentParents->Put(aPluginID, p);
 
   return p.forget();
 }
 
 /*static*/ ProcessPriority
 ContentParent::GetInitialProcessPriority(Element* aFrameElement)
 {
@@ -2086,16 +2081,18 @@ ContentParent::LaunchSubprocess(ProcessP
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     nsAutoString cpId;
     cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
     obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-initializing", cpId.get());
   }
 
+  Init();
+
   return true;
 }
 
 ContentParent::ContentParent(ContentParent* aOpener,
                              const nsAString& aRemoteType,
                              int32_t aJSPluginID)
   : nsIContentParent()
   , mSubprocess(nullptr)
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -745,17 +745,17 @@ private:
   ContentParent(ContentParent* aOpener,
                 const nsAString& aRemoteType,
                 int32_t aPluginID);
 
   // Launch the subprocess and associated initialization.
   // Returns false if the process fails to start.
   bool LaunchSubprocess(hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND);
 
-  // Common initialization after sub process launch or adoption.
+  // Common initialization after sub process launch.
   void InitInternal(ProcessPriority aPriority);
 
   virtual ~ContentParent();
 
   void Init();
 
   // Some information could be sent to content very early, it
   // should be send from this function. This function should only be