Bug 1525720, part 16 - Cycle collect RemoteBrowser and support weak references in BrowserHost. r=nika

BrowserParent is cycle collected and supported weak references, so this commit adds support
for these things to BrowserHost.

Differential Revision: https://phabricator.services.mozilla.com/D31448

--HG--
extra : source : e65cb2d4c5a55e3049922df02af643337b7a58b2
This commit is contained in:
Ryan Hunt 2019-05-14 16:28:10 -05:00
parent 7073efe48d
commit 8768003b13
6 changed files with 31 additions and 8 deletions

View File

@ -157,7 +157,7 @@ typedef ScrollableLayerGuid::ViewID ViewID;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsFrameLoader, mBrowsingContext, NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsFrameLoader, mBrowsingContext,
mMessageManager, mChildMessageManager, mMessageManager, mChildMessageManager,
mParentSHistory) mParentSHistory, mRemoteBrowser)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameLoader) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameLoader)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameLoader) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameLoader)

View File

@ -9,6 +9,15 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserBridgeHost)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(BrowserBridgeHost)
NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserBridgeHost)
NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserBridgeHost)
BrowserBridgeHost::BrowserBridgeHost(BrowserBridgeChild* aChild) BrowserBridgeHost::BrowserBridgeHost(BrowserBridgeChild* aChild)
: mBridge(aChild) {} : mBridge(aChild) {}

View File

@ -28,7 +28,8 @@ class BrowserBridgeHost : public RemoteBrowser {
explicit BrowserBridgeHost(BrowserBridgeChild* aChild); explicit BrowserBridgeHost(BrowserBridgeChild* aChild);
NS_INLINE_DECL_REFCOUNTING(BrowserBridgeHost, override); NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(BrowserBridgeHost)
// Get the IPDL actor for the BrowserBridgeChild. // Get the IPDL actor for the BrowserBridgeChild.
BrowserBridgeChild* GetActor() { return mBridge; } BrowserBridgeChild* GetActor() { return mBridge; }

View File

@ -12,7 +12,16 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_ISUPPORTS(BrowserHost, nsIRemoteTab) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserHost)
NS_INTERFACE_MAP_ENTRY(nsIRemoteTab)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, RemoteBrowser)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(BrowserHost, mRoot)
NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserHost)
NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserHost)
BrowserHost::BrowserHost(BrowserParent* aParent) : mRoot(aParent) { BrowserHost::BrowserHost(BrowserParent* aParent) : mRoot(aParent) {
mRoot->SetBrowserHost(this); mRoot->SetBrowserHost(this);

View File

@ -32,7 +32,9 @@ class Element;
* See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
* actors. * actors.
*/ */
class BrowserHost : public RemoteBrowser, public nsIRemoteTab { class BrowserHost : public RemoteBrowser,
public nsIRemoteTab,
public nsSupportsWeakReference {
public: public:
typedef mozilla::layers::LayersId LayersId; typedef mozilla::layers::LayersId LayersId;
@ -40,10 +42,13 @@ class BrowserHost : public RemoteBrowser, public nsIRemoteTab {
static BrowserHost* GetFrom(nsIRemoteTab* aRemoteTab); static BrowserHost* GetFrom(nsIRemoteTab* aRemoteTab);
NS_DECL_ISUPPORTS // NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// nsIRemoteTab // nsIRemoteTab
NS_DECL_NSIREMOTETAB NS_DECL_NSIREMOTETAB
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(BrowserHost, RemoteBrowser)
// Get the IPDL actor for the root BrowserParent. This method should be // Get the IPDL actor for the root BrowserParent. This method should be
// avoided and consumers migrated to use this class. // avoided and consumers migrated to use this class.
BrowserParent* GetActor() { return mRoot; } BrowserParent* GetActor() { return mRoot; }

View File

@ -11,6 +11,7 @@
#include "mozilla/dom/ipc/IdType.h" #include "mozilla/dom/ipc/IdType.h"
#include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/LayersTypes.h"
#include "nsILoadContext.h" #include "nsILoadContext.h"
#include "nsISupports.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsRect.h" #include "nsRect.h"
@ -33,10 +34,8 @@ class BrowserBridgeHost;
* nsFrameLoader will use BrowserHost, and a content process nsFrameLoader will * nsFrameLoader will use BrowserHost, and a content process nsFrameLoader will
* use BrowserBridgeHost. * use BrowserBridgeHost.
*/ */
class RemoteBrowser { class RemoteBrowser : public nsISupports {
public: public:
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
typedef mozilla::layers::LayersId LayersId; typedef mozilla::layers::LayersId LayersId;
// Try to cast this RemoteBrowser to a BrowserHost, may return null // Try to cast this RemoteBrowser to a BrowserHost, may return null