Bug 1500257 part 2 - Add PRemoteFrame stub implementation. r=qdot
☠☠ backed out by 2b27038adbe4 ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Wed, 23 Jan 2019 10:38:09 -0600
changeset 458337 e72d9d31a8bc15e0d3e17d3bdae0b5717465c4b9
parent 458336 1615df089ad3b65333f50ac845a69e37c09b529f
child 458338 002762a021c49287c1aad0db877a3a242ea3eba8
push id111812
push userrhunt@eqrion.net
push dateSat, 09 Feb 2019 06:41:25 +0000
treeherdermozilla-inbound@335ddf6a213a [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 2 - Add PRemoteFrame stub implementation. r=qdot This commit adds a PRemoteFrame actor which is managed by PBrowser. It will be created in a child process nsFrameLoader when loading a remote subframe. This actor will mostly just bounce messages from a nsFrameLoader in the child process to the actor in the parent process which will redirect the messages to the TabParent of the remote subframe. The piece in the parent actor to create the proxied PBrowser actors is deferred to the next commit. Differential Revision: https://phabricator.services.mozilla.com/D17442
dom/ipc/PBrowser.ipdl
dom/ipc/PRemoteFrame.ipdl
dom/ipc/RemoteFrameChild.cpp
dom/ipc/RemoteFrameChild.h
dom/ipc/RemoteFrameParent.cpp
dom/ipc/RemoteFrameParent.h
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
dom/ipc/moz.build
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -14,16 +14,17 @@ include protocol PIndexedDBPermissionReq
 include protocol PPluginWidget;
 include protocol PRemotePrintJob;
 include protocol PChildToParentStream;
 include protocol PParentToChildStream;
 include protocol PFileDescriptorSet;
 include protocol PIPCBlobInputStream;
 include protocol PPaymentRequest;
 include protocol PWindowGlobal;
+include protocol PRemoteFrame;
 
 include DOMTypes;
 include IPCBlob;
 include IPCStream;
 include JavaScriptTypes;
 include URIParams;
 include PPrintingTypes;
 include PTabContext;
@@ -137,16 +138,17 @@ nested(upto inside_cpow) sync protocol P
 
     manages PColorPicker;
     manages PDocAccessible;
     manages PFilePicker;
     manages PIndexedDBPermissionRequest;
     manages PPluginWidget;
     manages PPaymentRequest;
     manages PWindowGlobal;
+    manages PRemoteFrame;
 
 both:
     async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
                        Principal aPrincipal, ClonedMessageData aData);
 
 parent:
     /**
      * Tell the parent process a new accessible document has been created.
@@ -170,16 +172,21 @@ parent:
 
     /**
      * Construct a new WindowGlobal actor for a window global in the given
      * BrowsingContext and with the given principal.
      */
     async PWindowGlobal(WindowGlobalInit init);
 
     /**
+     * Construct a new Remote iframe actor.
+     */
+    async PRemoteFrame(nsString aPresentationURL, nsString aRemoteType);
+
+    /**
      * Sends an NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW to be adopted by the
      * widget's shareable window on the chrome side. Only used on Windows.
      */
     async SetNativeChildOfShareableWindow(uintptr_t childWindow);
 
     /**
      * When content moves focus from a native plugin window that's a child
      * of the native browser window we need to move native focus to the
new file mode 100644
--- /dev/null
+++ b/dom/ipc/PRemoteFrame.ipdl
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
+/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+include protocol PBrowser;
+
+include DOMTypes;
+
+namespace mozilla {
+namespace dom {
+
+/**
+ * PRemoteFrame corresponds to a remote iframe.
+ */
+async protocol PRemoteFrame {
+  manager PBrowser;
+parent:
+  // Destroy the remote web browser due to the nsFrameLoader going away.
+  async __delete__();
+};
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/ipc/RemoteFrameChild.cpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/dom/RemoteFrameChild.h"
+
+using namespace mozilla::ipc;
+
+namespace mozilla {
+namespace dom {
+
+RemoteFrameChild::RemoteFrameChild(nsFrameLoader* aFrameLoader)
+    : mLayersId{0}, mIPCOpen(true), mFrameLoader(aFrameLoader) {}
+
+RemoteFrameChild::~RemoteFrameChild() {}
+
+already_AddRefed<RemoteFrameChild> RemoteFrameChild::Create(
+    nsFrameLoader* aFrameLoader, const TabContext& aContext,
+    const nsString& aRemoteType) {
+  MOZ_ASSERT(XRE_IsContentProcess());
+
+  // Determine our embedder's TabChild actor.
+  RefPtr<Element> owner = aFrameLoader->GetOwnerContent();
+  MOZ_DIAGNOSTIC_ASSERT(owner);
+
+  nsCOMPtr<nsIDocShell> docShell = do_GetInterface(owner->GetOwnerGlobal());
+  MOZ_DIAGNOSTIC_ASSERT(docShell);
+
+  RefPtr<TabChild> tabChild = TabChild::GetFrom(docShell);
+  MOZ_DIAGNOSTIC_ASSERT(tabChild);
+
+  RefPtr<RemoteFrameChild> remoteFrame = new RemoteFrameChild(aFrameLoader);
+  // Reference is freed in TabChild::DeallocPRemoteFrameChild.
+  tabChild->SendPRemoteFrameConstructor(
+      do_AddRef(remoteFrame).take(),
+      PromiseFlatString(aContext.PresentationURL()), aRemoteType);
+  remoteFrame->mIPCOpen = true;
+
+  return remoteFrame.forget();
+}
+
+void RemoteFrameChild::ActorDestroy(ActorDestroyReason aWhy) {
+  mIPCOpen = false;
+}
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/ipc/RemoteFrameChild.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_RemoteFrameChild_h
+#define mozilla_dom_RemoteFrameChild_h
+
+#include "mozilla/dom/PRemoteFrameChild.h"
+#include "mozilla/dom/TabChild.h"
+
+namespace mozilla {
+namespace dom {
+
+/**
+ * Child side for a remote frame.
+ */
+class RemoteFrameChild : public PRemoteFrameChild {
+ public:
+  NS_INLINE_DECL_REFCOUNTING(RemoteFrameChild);
+
+  TabChild* Manager() {
+    MOZ_ASSERT(mIPCOpen);
+    return static_cast<TabChild*>(PRemoteFrameChild::Manager());
+  }
+
+  mozilla::layers::LayersId GetLayersId() { return mLayersId; }
+
+  static already_AddRefed<RemoteFrameChild> Create(nsFrameLoader* aFrameLoader,
+                                                   const TabContext& aContext,
+                                                   const nsString& aRemoteType);
+ protected:
+  void ActorDestroy(ActorDestroyReason aWhy) override;
+
+ private:
+  explicit RemoteFrameChild(nsFrameLoader* aFrameLoader);
+  ~RemoteFrameChild();
+
+  mozilla::layers::LayersId mLayersId;
+  bool mIPCOpen;
+  RefPtr<nsFrameLoader> mFrameLoader;
+};
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // !defined(mozilla_dom_RemoteFrameParent_h)
new file mode 100644
--- /dev/null
+++ b/dom/ipc/RemoteFrameParent.cpp
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/dom/RemoteFrameParent.h"
+#include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/ContentProcessManager.h"
+
+using namespace mozilla::ipc;
+using namespace mozilla::layout;
+
+namespace mozilla {
+namespace dom {
+
+RemoteFrameParent::RemoteFrameParent() : mIPCOpen(false) {}
+
+RemoteFrameParent::~RemoteFrameParent() {}
+
+nsresult RemoteFrameParent::Init(const nsString& aPresentationURL,
+                                 const nsString& aRemoteType) {
+  return NS_OK;
+}
+
+void RemoteFrameParent::ActorDestroy(ActorDestroyReason aWhy) {
+  mIPCOpen = false;
+}
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/ipc/RemoteFrameParent.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_RemoteFrameParent_h
+#define mozilla_dom_RemoteFrameParent_h
+
+#include "mozilla/dom/PRemoteFrameParent.h"
+#include "mozilla/dom/TabParent.h"
+
+namespace mozilla {
+namespace dom {
+
+class RemoteFrameParent : public PRemoteFrameParent {
+ public:
+  NS_INLINE_DECL_REFCOUNTING(RemoteFrameParent);
+
+  RemoteFrameParent();
+
+  // Initialize this actor after performing startup.
+  nsresult Init(const nsString& aPresentationURL, const nsString& aRemoteType);
+
+  TabParent* GetTabParent() { return mTabParent; }
+
+  // Get our manager actor.
+  TabParent* Manager() {
+    MOZ_ASSERT(mIPCOpen);
+    return static_cast<TabParent*>(PRemoteFrameParent::Manager());
+  }
+
+ protected:
+  void ActorDestroy(ActorDestroyReason aWhy) override;
+
+ private:
+  ~RemoteFrameParent();
+
+  RefPtr<TabParent> mTabParent;
+  bool mIPCOpen;
+};
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // !defined(mozilla_dom_RemoteFrameParent_h)
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -25,16 +25,17 @@
 #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
 #include "mozilla/dom/LoadURIOptionsBinding.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/PaymentRequestChild.h"
 #include "mozilla/dom/PBrowser.h"
 #include "mozilla/dom/WindowProxyHolder.h"
+#include "mozilla/dom/RemoteFrameChild.h"
 #include "mozilla/gfx/CrossProcessPaint.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/layers/APZChild.h"
 #include "mozilla/layers/APZCCallbackHelper.h"
 #include "mozilla/layers/APZCTreeManagerChild.h"
 #include "mozilla/layers/APZEventState.h"
 #include "mozilla/layers/ContentProcessController.h"
@@ -3174,16 +3175,28 @@ PWindowGlobalChild* TabChild::AllocPWind
 }
 
 bool TabChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
   // This reference was added in WindowGlobalChild::Create.
   static_cast<WindowGlobalChild*>(aActor)->Release();
   return true;
 }
 
+PRemoteFrameChild* TabChild::AllocPRemoteFrameChild(const nsString&,
+                                                    const nsString&) {
+  MOZ_CRASH("We should never be manually allocating PRemoteFrameChild actors");
+  return nullptr;
+}
+
+bool TabChild::DeallocPRemoteFrameChild(PRemoteFrameChild* aActor) {
+  // This reference was added in RemoteFrameChild::Create.
+  static_cast<RemoteFrameChild*>(aActor)->Release();
+  return true;
+}
+
 ScreenIntSize TabChild::GetInnerSize() {
   LayoutDeviceIntSize innerSize =
       RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());
   return ViewAs<ScreenPixel>(
       innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
 };
 
 ScreenIntRect TabChild::GetOuterRect() {
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -665,16 +665,21 @@ class TabChild final : public TabChildBa
  protected:
   virtual ~TabChild();
 
   virtual PWindowGlobalChild* AllocPWindowGlobalChild(
       const WindowGlobalInit& aInit) override;
 
   virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override;
 
+  virtual PRemoteFrameChild* AllocPRemoteFrameChild(
+      const nsString& aName, const nsString& aRemoteType) override;
+
+  virtual bool DeallocPRemoteFrameChild(PRemoteFrameChild* aActor) override;
+
   virtual mozilla::ipc::IPCResult RecvDestroy() override;
 
   virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(
       const bool& aIsActive) override;
 
   virtual mozilla::ipc::IPCResult RecvRenderLayers(
       const bool& aEnabled, const bool& aForce,
       const layers::LayersObserverEpoch& aEpoch) override;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -17,16 +17,17 @@
 #include "mozilla/dom/ContentBridgeParent.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DataTransferItemList.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
 #include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/PaymentRequestParent.h"
+#include "mozilla/dom/RemoteFrameParent.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/Hal.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/layers/AsyncDragMetrics.h"
@@ -1010,16 +1011,35 @@ PWindowGlobalParent* TabParent::AllocPWi
 }
 
 bool TabParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
   // Free reference from AllocPWindowGlobalParent.
   static_cast<WindowGlobalParent*>(aActor)->Release();
   return true;
 }
 
+IPCResult TabParent::RecvPRemoteFrameConstructor(PRemoteFrameParent* aActor,
+                                                 const nsString& aName,
+                                                 const nsString& aRemoteType) {
+  static_cast<RemoteFrameParent*>(aActor)->Init(aName, aRemoteType);
+  return IPC_OK();
+}
+
+PRemoteFrameParent* TabParent::AllocPRemoteFrameParent(
+    const nsString& aName, const nsString& aRemoteType) {
+  // Reference freed in DeallocPRemoteFrameParent.
+  return do_AddRef(new RemoteFrameParent()).take();
+}
+
+bool TabParent::DeallocPRemoteFrameParent(PRemoteFrameParent* aActor) {
+  // Free reference from AllocPRemoteFrameParent.
+  static_cast<RemoteFrameParent*>(aActor)->Release();
+  return true;
+}
+
 void TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
                                int32_t aButton, int32_t aClickCount,
                                int32_t aModifiers,
                                bool aIgnoreRootScrollFrame) {
   if (!mIsDestroyed) {
     Unused << PBrowserParent::SendMouseEvent(nsString(aType), aX, aY, aButton,
                                              aClickCount, aModifiers,
                                              aIgnoreRootScrollFrame);
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -311,16 +311,25 @@ class TabParent final : public PBrowserP
 
   PWindowGlobalParent* AllocPWindowGlobalParent(const WindowGlobalInit& aInit);
 
   bool DeallocPWindowGlobalParent(PWindowGlobalParent* aActor);
 
   virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
       PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
 
+  virtual PRemoteFrameParent* AllocPRemoteFrameParent(
+      const nsString& aPresentationURL, const nsString& aRemoteType) override;
+
+  virtual bool DeallocPRemoteFrameParent(PRemoteFrameParent* aActor) override;
+
+  virtual mozilla::ipc::IPCResult RecvPRemoteFrameConstructor(
+      PRemoteFrameParent* aActor, const nsString& aPresentationURL,
+      const nsString& aRemoteType) override;
+
   void LoadURL(nsIURI* aURI);
 
   void InitRendering();
   void MaybeShowFrame();
 
   // XXX/cjones: it's not clear what we gain by hiding these
   // message-sending functions under a layer of indirection and
   // eating the return values
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -42,16 +42,18 @@ EXPORTS.mozilla.dom += [
     'FilePickerParent.h',
     'JSWindowActorChild.h',
     'JSWindowActorParent.h',
     'JSWindowActorService.h',
     'MemoryReportRequest.h',
     'nsIContentChild.h',
     'nsIContentParent.h',
     'PermissionMessageUtils.h',
+    'RemoteFrameChild.h',
+    'RemoteFrameParent.h',
     'TabChild.h',
     'TabContext.h',
     'TabMessageUtils.h',
     'TabParent.h',
     'URLClassifierChild.h',
     'URLClassifierParent.h',
     'WindowGlobalChild.h',
     'WindowGlobalParent.h',
@@ -81,16 +83,18 @@ UNIFIED_SOURCES += [
     'MemMapSnapshot.cpp',
     'MemoryReportRequest.cpp',
     'MMPrinter.cpp',
     'nsIContentChild.cpp',
     'nsIContentParent.cpp',
     'PermissionMessageUtils.cpp',
     'PreallocatedProcessManager.cpp',
     'ProcessPriorityManager.cpp',
+    'RemoteFrameChild.cpp',
+    'RemoteFrameParent.cpp',
     'SharedMap.cpp',
     'SharedStringMap.cpp',
     'StructuredCloneData.cpp',
     'TabChild.cpp',
     'TabContext.cpp',
     'TabMessageUtils.cpp',
     'TabParent.cpp',
     'URLClassifierParent.cpp',
@@ -115,16 +119,17 @@ IPDL_SOURCES += [
     'PContentPermission.ipdlh',
     'PContentPermissionRequest.ipdl',
     'PCycleCollectWithLogs.ipdl',
     'PFilePicker.ipdl',
     'PLoginReputation.ipdl',
     'PPluginWidget.ipdl',
     'PProcessHangMonitor.ipdl',
     'PrefsTypes.ipdlh',
+    'PRemoteFrame.ipdl',
     'PTabContext.ipdlh',
     'PURLClassifier.ipdl',
     'PURLClassifierInfo.ipdlh',
     'PURLClassifierLocal.ipdl',
     'PWindowGlobal.ipdl',
     'ServiceWorkerConfiguration.ipdlh',
 ]