Bug 1525720, part 8 - Add RemoteBrowser interface and BrowserHost/BrowserBridgeHost implementations. r=nika
☠☠ backed out by f287bb6c1894 ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Mon, 06 May 2019 16:04:34 -0500
changeset 474961 eadeacbe44838a0db21d5f535fd14bfd62455a22
parent 474960 32eeee79d628dade8109454c636d5f8aaff0c93e
child 474962 697774dd89848fb992355abaae97bba35b8c74ba
push id113182
push userrhunt@eqrion.net
push dateWed, 22 May 2019 20:02:12 +0000
treeherdermozilla-inbound@9b79caa460a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1525720
milestone69.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 1525720, part 8 - Add RemoteBrowser interface and BrowserHost/BrowserBridgeHost implementations. r=nika RemoteBrowser is a common interface between the chrome/content process cases for nsFrameLoader, that allows us to abstract IPC details away. BrowserHost is a concrete implementation for the chrome process, while BrowserBridgeHost implements the content process case. Differential Revision: https://phabricator.services.mozilla.com/D31438
dom/ipc/BrowserBridgeHost.cpp
dom/ipc/BrowserBridgeHost.h
dom/ipc/BrowserHost.cpp
dom/ipc/BrowserHost.h
dom/ipc/JSWindowActorChild.cpp
dom/ipc/RemoteBrowser.h
dom/ipc/moz.build
new file mode 100644
--- /dev/null
+++ b/dom/ipc/BrowserBridgeHost.cpp
@@ -0,0 +1,41 @@
+/* -*- 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/BrowserBridgeHost.h"
+
+namespace mozilla {
+namespace dom {
+
+BrowserBridgeHost::BrowserBridgeHost(BrowserBridgeChild* aChild)
+    : mBridge(aChild) {}
+
+mozilla::layers::LayersId BrowserBridgeHost::GetLayersId() const {
+  return LayersId{0};
+}
+
+BrowsingContext* BrowserBridgeHost::GetBrowsingContext() const {
+  return nullptr;
+}
+
+nsILoadContext* BrowserBridgeHost::GetLoadContext() const { return nullptr; }
+
+void BrowserBridgeHost::LoadURL(nsIURI* aURI) {}
+
+void BrowserBridgeHost::ResumeLoad(uint64_t aPendingSwitchId) {}
+
+void BrowserBridgeHost::DestroyStart() {}
+
+void BrowserBridgeHost::DestroyComplete() {}
+
+bool BrowserBridgeHost::Show(const ScreenIntSize& aSize, bool aParentIsActive) {
+  return true;
+}
+
+void BrowserBridgeHost::UpdateDimensions(const nsIntRect& aRect,
+                                         const ScreenIntSize& aSize) {}
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/ipc/BrowserBridgeHost.h
@@ -0,0 +1,62 @@
+/* -*- 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_BrowserBridgeHost_h
+#define mozilla_dom_BrowserBridgeHost_h
+
+#include "mozilla/dom/RemoteBrowser.h"
+#include "mozilla/dom/BrowserBridgeChild.h"
+
+namespace mozilla {
+namespace dom {
+
+/**
+ * BrowserBridgeHost manages a remote browser from a content process.
+ *
+ * It is used via the RemoteBrowser interface in nsFrameLoader and proxies
+ * work to the chrome process via PBrowserBridge.
+ *
+ * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
+ * actors.
+ */
+class BrowserBridgeHost : public RemoteBrowser {
+ public:
+  typedef mozilla::layers::LayersId LayersId;
+
+  explicit BrowserBridgeHost(BrowserBridgeChild* aChild);
+
+  NS_INLINE_DECL_REFCOUNTING(BrowserBridgeHost, override);
+
+  // Get the IPDL actor for the BrowserBridgeChild.
+  BrowserBridgeChild* GetActor() { return mBridge; }
+
+  BrowserHost* AsBrowserHost() override { return nullptr; }
+  BrowserBridgeHost* AsBrowserBridgeHost() override { return this; }
+
+  LayersId GetLayersId() const override;
+  BrowsingContext* GetBrowsingContext() const override;
+  nsILoadContext* GetLoadContext() const override;
+
+  void LoadURL(nsIURI* aURI) override;
+  void ResumeLoad(uint64_t aPendingSwitchId) override;
+  void DestroyStart() override;
+  void DestroyComplete() override;
+
+  bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
+  void UpdateDimensions(const nsIntRect& aRect,
+                        const ScreenIntSize& aSize) override;
+
+ private:
+  virtual ~BrowserBridgeHost() = default;
+
+  // The IPDL actor for proxying browser operations
+  RefPtr<BrowserBridgeChild> mBridge;
+};
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // mozilla_dom_BrowserBridgeHost_h
new file mode 100644
--- /dev/null
+++ b/dom/ipc/BrowserHost.cpp
@@ -0,0 +1,41 @@
+/* -*- 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/BrowserHost.h"
+
+#include "mozilla/dom/CancelContentJSOptionsBinding.h"
+#include "mozilla/dom/WindowGlobalParent.h"
+
+namespace mozilla {
+namespace dom {
+
+BrowserHost::BrowserHost(BrowserParent* aParent) : mRoot(aParent) {}
+
+mozilla::layers::LayersId BrowserHost::GetLayersId() const {
+  return LayersId{0};
+}
+
+BrowsingContext* BrowserHost::GetBrowsingContext() const { return nullptr; }
+
+nsILoadContext* BrowserHost::GetLoadContext() const { return nullptr; }
+
+void BrowserHost::LoadURL(nsIURI* aURI) {}
+
+void BrowserHost::ResumeLoad(uint64_t aPendingSwitchId) {}
+
+void BrowserHost::DestroyStart() {}
+
+void BrowserHost::DestroyComplete() {}
+
+bool BrowserHost::Show(const ScreenIntSize& aSize, bool aParentIsActive) {
+  return true;
+}
+
+void BrowserHost::UpdateDimensions(const nsIntRect& aRect,
+                                   const ScreenIntSize& aSize) {}
+
+}  // namespace dom
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/ipc/BrowserHost.h
@@ -0,0 +1,63 @@
+/* -*- 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_BrowserHost_h
+#define mozilla_dom_BrowserHost_h
+
+#include "mozilla/dom/RemoteBrowser.h"
+#include "mozilla/dom/BrowserParent.h"
+
+namespace mozilla {
+namespace dom {
+
+/**
+ * BrowserHost manages a remote browser from the chrome process.
+ *
+ * It is used via the RemoteBrowser interface in nsFrameLoader and supports
+ * operations over the tree of BrowserParent/BrowserBridgeParent's.
+ *
+ * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
+ * actors.
+ */
+class BrowserHost : public RemoteBrowser {
+ public:
+  typedef mozilla::layers::LayersId LayersId;
+
+  explicit BrowserHost(BrowserParent* aParent);
+
+  NS_INLINE_DECL_REFCOUNTING(BrowserHost, override);
+
+  // Get the IPDL actor for the root BrowserParent. This method should be
+  // avoided and consumers migrated to use this class.
+  BrowserParent* GetActor() { return mRoot; }
+
+  BrowserHost* AsBrowserHost() override { return this; }
+  BrowserBridgeHost* AsBrowserBridgeHost() override { return nullptr; }
+
+  LayersId GetLayersId() const override;
+  BrowsingContext* GetBrowsingContext() const override;
+  nsILoadContext* GetLoadContext() const override;
+
+  void LoadURL(nsIURI* aURI) override;
+  void ResumeLoad(uint64_t aPendingSwitchId) override;
+  void DestroyStart() override;
+  void DestroyComplete() override;
+
+  bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
+  void UpdateDimensions(const nsIntRect& aRect,
+                        const ScreenIntSize& aSize) override;
+
+ private:
+  virtual ~BrowserHost() = default;
+
+  // The root BrowserParent of this remote browser
+  RefPtr<BrowserParent> mRoot;
+};
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // mozilla_dom_BrowserHost_h
--- a/dom/ipc/JSWindowActorChild.cpp
+++ b/dom/ipc/JSWindowActorChild.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/JSWindowActorBinding.h"
 #include "mozilla/dom/JSWindowActorChild.h"
+#include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/WindowGlobalChild.h"
 #include "mozilla/dom/WindowGlobalParent.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "nsGlobalWindowInner.h"
 
 namespace mozilla {
 namespace dom {
new file mode 100644
--- /dev/null
+++ b/dom/ipc/RemoteBrowser.h
@@ -0,0 +1,64 @@
+/* -*- 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_ipc_RemoteBrowser_h
+#define mozilla_dom_ipc_RemoteBrowser_h
+
+#include "mozilla/dom/BrowsingContext.h"
+#include "mozilla/dom/ipc/IdType.h"
+#include "mozilla/layers/LayersTypes.h"
+#include "nsILoadContext.h"
+#include "nsISupportsImpl.h"
+#include "nsIURI.h"
+#include "nsRect.h"
+#include "Units.h"
+
+namespace mozilla {
+namespace dom {
+
+class BrowserHost;
+class BrowserBridgeHost;
+
+/**
+ * An interface to control a browser hosted in another process.
+ *
+ * This is used by nsFrameLoader to abstract between hosting a top-level remote
+ * browser in the chrome process and hosting an OOP-iframe in a content process.
+ *
+ * There are two concrete implementations that are used depending on whether
+ * the nsFrameLoader is in the chrome or content process. A chrome process
+ * nsFrameLoader will use BrowserHost, and a content process nsFrameLoader will
+ * use BrowserBridgeHost.
+ */
+class RemoteBrowser {
+ public:
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
+
+  typedef mozilla::layers::LayersId LayersId;
+
+  // Try to cast this RemoteBrowser to a BrowserHost, may return null
+  virtual BrowserHost* AsBrowserHost() = 0;
+  // Try to cast this RemoteBrowser to a BrowserBridgeHost, may return null
+  virtual BrowserBridgeHost* AsBrowserBridgeHost() = 0;
+
+  virtual LayersId GetLayersId() const = 0;
+  virtual BrowsingContext* GetBrowsingContext() const = 0;
+  virtual nsILoadContext* GetLoadContext() const = 0;
+
+  virtual void LoadURL(nsIURI* aURI) = 0;
+  virtual void ResumeLoad(uint64_t aPendingSwitchId) = 0;
+  virtual void DestroyStart() = 0;
+  virtual void DestroyComplete() = 0;
+
+  virtual bool Show(const ScreenIntSize& aSize, bool aParentIsActive) = 0;
+  virtual void UpdateDimensions(const nsIntRect& aRect,
+                                const ScreenIntSize& aSize) = 0;
+};
+
+}  // namespace dom
+}  // namespace mozilla
+
+#endif  // mozilla_dom_ipc_RemoteBrowser_h
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -30,18 +30,20 @@ EXPORTS.mozilla.dom.ipc += [
     'SharedMapChangeEvent.h',
     'SharedStringMap.h',
     'StringTable.h',
     'StructuredCloneData.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'BrowserBridgeChild.h',
+    'BrowserBridgeHost.h',
     'BrowserBridgeParent.h',
     'BrowserChild.h',
+    'BrowserHost.h',
     'BrowserParent.h',
     'CoalescedInputData.h',
     'CoalescedMouseData.h',
     'CoalescedWheelData.h',
     'ContentChild.h',
     'ContentParent.h',
     'ContentProcess.h',
     'ContentProcessManager.h',
@@ -51,16 +53,17 @@ EXPORTS.mozilla.dom += [
     'FilePickerParent.h',
     'JSWindowActor.h',
     'JSWindowActorChild.h',
     'JSWindowActorParent.h',
     'JSWindowActorService.h',
     'MemoryReportRequest.h',
     'PermissionMessageUtils.h',
     'ReferrerInfoUtils.h',
+    'RemoteBrowser.h',
     'RemoteWebProgress.h',
     'RemoteWebProgressRequest.h',
     'TabContext.h',
     'TabMessageUtils.h',
     'URLClassifierChild.h',
     'URLClassifierParent.h',
     'WindowGlobalActor.h',
     'WindowGlobalChild.h',
@@ -71,18 +74,20 @@ EXPORTS.mozilla += [
     'PreallocatedProcessManager.h',
     'ProcessHangMonitor.h',
     'ProcessHangMonitorIPC.h',
     'ProcessPriorityManager.h',
 ]
 
 UNIFIED_SOURCES += [
     'BrowserBridgeChild.cpp',
+    'BrowserBridgeHost.cpp',
     'BrowserBridgeParent.cpp',
     'BrowserChild.cpp',
+    'BrowserHost.cpp',
     'BrowserParent.cpp',
     'CoalescedMouseData.cpp',
     'CoalescedWheelData.cpp',
     'ColorPickerParent.cpp',
     'ContentParent.cpp',
     'ContentProcess.cpp',
     'ContentProcessManager.cpp',
     'CSPMessageUtils.cpp',