Bug 1886946: Remove incorrect assertion that buffer is not-pinned. r=sfink
[gecko.git] / dom / ipc / BrowserHost.h
blob5b651a1df041151c6a7be567c21985bd636ca442
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_BrowserHost_h
8 #define mozilla_dom_BrowserHost_h
10 #include "nsIRemoteTab.h"
11 #include "mozilla/dom/RemoteBrowser.h"
12 #include "mozilla/dom/BrowserParent.h"
14 class nsPIDOMWindowOuter;
16 namespace mozilla {
18 namespace a11y {
19 class DocAccessibleParent;
20 } // namespace a11y
22 namespace dom {
24 class Element;
26 /**
27 * BrowserHost manages a remote browser from the chrome process.
29 * It is used via the RemoteBrowser interface in nsFrameLoader and supports
30 * operations over the tree of BrowserParent/BrowserBridgeParent's.
32 * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
33 * actors.
35 class BrowserHost : public RemoteBrowser,
36 public nsIRemoteTab,
37 public nsSupportsWeakReference {
38 public:
39 typedef mozilla::layers::LayersId LayersId;
41 explicit BrowserHost(BrowserParent* aParent);
43 static BrowserHost* GetFrom(nsIRemoteTab* aRemoteTab);
45 // NS_DECL_ISUPPORTS_INHERITED
46 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
47 // nsIRemoteTab
48 NS_DECL_NSIREMOTETAB
50 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(BrowserHost, RemoteBrowser)
52 // Get the IPDL actor for the root BrowserParent. This method should be
53 // avoided and consumers migrated to use this class.
54 BrowserParent* GetActor() { return mRoot; }
55 ContentParent* GetContentParent() const {
56 return mRoot ? mRoot->Manager() : nullptr;
59 BrowserHost* AsBrowserHost() override { return this; }
60 BrowserBridgeHost* AsBrowserBridgeHost() override { return nullptr; }
62 TabId GetTabId() const override;
63 LayersId GetLayersId() const override;
64 BrowsingContext* GetBrowsingContext() const override;
65 nsILoadContext* GetLoadContext() const override;
66 bool CanRecv() const override;
68 Element* GetOwnerElement() const { return mRoot->GetOwnerElement(); }
69 already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter() const {
70 return mRoot->GetParentWindowOuter();
72 a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
74 // Visit each BrowserParent in the tree formed by PBrowser and
75 // PBrowserBridge that is anchored by `mRoot`.
76 template <typename Callback>
77 void VisitAll(Callback aCallback) {
78 if (!mRoot) {
79 return;
81 mRoot->VisitAll(aCallback);
84 void LoadURL(nsDocShellLoadState* aLoadState) override;
85 void ResumeLoad(uint64_t aPendingSwitchId) override;
86 void DestroyStart() override;
87 void DestroyComplete() override;
89 bool Show(const OwnerShowInfo&) override;
90 void UpdateDimensions(const nsIntRect& aRect,
91 const ScreenIntSize& aSize) override;
93 void UpdateEffects(EffectsInfo aInfo) override;
95 private:
96 virtual ~BrowserHost() = default;
98 // The TabID for the root BrowserParent, we cache this so that we can access
99 // it after the remote browser has been destroyed
100 TabId mId;
101 // The root BrowserParent of this remote browser
102 RefPtr<BrowserParent> mRoot;
103 EffectsInfo mEffectsInfo;
106 } // namespace dom
107 } // namespace mozilla
109 #endif // mozilla_dom_BrowserHost_h