Bug 1500257 part 3 - Create remote browser in parent process when initializing RemoteFrameParent. r=qdot
authorRyan Hunt <rhunt@eqrion.net>
Wed, 23 Jan 2019 10:40:08 -0600
changeset 458562 b5d1d5f2c850b6e3bf6762e1a1a3377ba78b0ae4
parent 458561 ea9fcc2f47f332eba8f0c22c37f5857b69df2a52
child 458563 5cfed0a28a2c029df316a8d67b4262c15c827841
push id111857
push userrhunt@eqrion.net
push dateTue, 12 Feb 2019 02:34:21 +0000
treeherdermozilla-inbound@409364e06a94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1500257
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1500257 part 3 - Create remote browser in parent process when initializing RemoteFrameParent. r=qdot This commit causes a new TabParent/TabChild to be created for a remote subframe. The logic here is partially bogus and will need to be iterated on. Differential Revision: https://phabricator.services.mozilla.com/D17443
dom/ipc/RemoteFrameParent.cpp
--- a/dom/ipc/RemoteFrameParent.cpp
+++ b/dom/ipc/RemoteFrameParent.cpp
@@ -15,16 +15,65 @@ namespace mozilla {
 namespace dom {
 
 RemoteFrameParent::RemoteFrameParent() : mIPCOpen(false) {}
 
 RemoteFrameParent::~RemoteFrameParent() {}
 
 nsresult RemoteFrameParent::Init(const nsString& aPresentationURL,
                                  const nsString& aRemoteType) {
+  mIPCOpen = true;
+
+  // FIXME: This should actually use a non-bogus TabContext, probably inherited
+  // from our Manager().
+  OriginAttributes attrs;
+  attrs.mInIsolatedMozBrowser = false;
+  attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
+  attrs.SyncAttributesWithPrivateBrowsing(false);
+  MutableTabContext tabContext;
+  tabContext.SetTabContext(false, 0, UIStateChangeType_Set,
+                           UIStateChangeType_Set, attrs, aPresentationURL);
+
+  ProcessPriority initialPriority = PROCESS_PRIORITY_FOREGROUND;
+
+  // Get our ConstructorSender object.
+  RefPtr<nsIContentParent> constructorSender =
+      ContentParent::GetNewOrUsedBrowserProcess(
+          nullptr, aRemoteType, initialPriority, nullptr, false);
+  if (NS_WARN_IF(!constructorSender)) {
+    MOZ_ASSERT(false, "Unable to allocate content process!");
+    return NS_ERROR_FAILURE;
+  }
+
+  ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
+  TabId tabId(nsContentUtils::GenerateTabId());
+  cpm->RegisterRemoteFrame(tabId, ContentParentId(0), TabId(0),
+                           tabContext.AsIPCTabContext(),
+                           constructorSender->ChildID());
+
+  // Construct the TabParent object for our subframe.
+  uint32_t chromeFlags = 0;
+  RefPtr<TabParent> tabParent(
+      new TabParent(constructorSender, tabId, tabContext, chromeFlags));
+
+  PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
+      // DeallocPBrowserParent() releases this ref.
+      tabParent.forget().take(), tabId, TabId(0), tabContext.AsIPCTabContext(),
+      chromeFlags, constructorSender->ChildID(),
+      constructorSender->IsForBrowser());
+  if (NS_WARN_IF(!browser)) {
+    MOZ_ASSERT(false, "Browser Constructor Failed");
+    return NS_ERROR_FAILURE;
+  }
+
+  // Set our TabParent object to the newly created browser.
+  mTabParent = TabParent::GetFrom(browser);
+  mTabParent->SetOwnerElement(Manager()->GetOwnerElement());
+  mTabParent->InitRendering();
+
   return NS_OK;
 }
 
 void RemoteFrameParent::ActorDestroy(ActorDestroyReason aWhy) {
   mIPCOpen = false;
 }
 
 }  // namespace dom