Bug 1550560 - Part 3: Make BrowserBridgeParent refcounted in IPDL, r=mccr8

This is an example refcounted actor which was easy enough to port over as an
initial test. More can be ported in the future, potentially alongside removing
`mIPCOpen`.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-07-29 19:54:18 +00:00
Родитель 5853ed26e9
Коммит 2698092f32
8 изменённых файлов: 11 добавлений и 32 удалений

Просмотреть файл

@ -29,7 +29,7 @@ class BrowserBridgeChild : public PBrowserBridgeChild {
public:
typedef mozilla::layers::LayersId LayersId;
NS_INLINE_DECL_REFCOUNTING(BrowserBridgeChild);
NS_INLINE_DECL_REFCOUNTING(BrowserBridgeChild, final);
BrowserChild* Manager() {
MOZ_ASSERT(mIPCOpen);

Просмотреть файл

@ -27,7 +27,7 @@ class BrowserParent;
*/
class BrowserBridgeParent : public PBrowserBridgeParent {
public:
NS_INLINE_DECL_REFCOUNTING(BrowserBridgeParent);
NS_INLINE_DECL_REFCOUNTING(BrowserBridgeParent, final);
BrowserBridgeParent();

Просмотреть файл

@ -3287,22 +3287,14 @@ bool BrowserChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
return true;
}
PBrowserBridgeChild* BrowserChild::AllocPBrowserBridgeChild(const nsString&,
const nsString&,
BrowsingContext*,
const uint32_t&,
const TabId&) {
already_AddRefed<PBrowserBridgeChild> BrowserChild::AllocPBrowserBridgeChild(
const nsString&, const nsString&, BrowsingContext*, const uint32_t&,
const TabId&) {
MOZ_CRASH(
"We should never be manually allocating PBrowserBridgeChild actors");
return nullptr;
}
bool BrowserChild::DeallocPBrowserBridgeChild(PBrowserBridgeChild* aActor) {
// This reference was added in BrowserBridgeChild::Create.
static_cast<BrowserBridgeChild*>(aActor)->Release();
return true;
}
ScreenIntSize BrowserChild::GetInnerSize() {
LayoutDeviceIntSize innerSize =
RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());

Просмотреть файл

@ -663,13 +663,11 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor);
PBrowserBridgeChild* AllocPBrowserBridgeChild(
already_AddRefed<PBrowserBridgeChild> AllocPBrowserBridgeChild(
const nsString& aName, const nsString& aRemoteType,
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
const TabId& aTabId);
bool DeallocPBrowserBridgeChild(PBrowserBridgeChild* aActor);
mozilla::ipc::IPCResult RecvDestroy();
mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive);

Просмотреть файл

@ -1266,18 +1266,11 @@ IPCResult BrowserParent::RecvPBrowserBridgeConstructor(
return IPC_OK();
}
PBrowserBridgeParent* BrowserParent::AllocPBrowserBridgeParent(
already_AddRefed<PBrowserBridgeParent> BrowserParent::AllocPBrowserBridgeParent(
const nsString& aName, const nsString& aRemoteType,
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
const TabId& aTabId) {
// Reference freed in DeallocPBrowserBridgeParent.
return do_AddRef(new BrowserBridgeParent()).take();
}
bool BrowserParent::DeallocPBrowserBridgeParent(PBrowserBridgeParent* aActor) {
// Free reference from AllocPBrowserBridgeParent.
static_cast<BrowserBridgeParent*>(aActor)->Release();
return true;
return do_AddRef(new BrowserBridgeParent());
}
void BrowserParent::SendMouseEvent(const nsAString& aType, float aX, float aY,

Просмотреть файл

@ -477,13 +477,11 @@ class BrowserParent final : public PBrowserParent,
virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
PBrowserBridgeParent* AllocPBrowserBridgeParent(
already_AddRefed<PBrowserBridgeParent> AllocPBrowserBridgeParent(
const nsString& aPresentationURL, const nsString& aRemoteType,
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
const TabId& aTabId);
bool DeallocPBrowserBridgeParent(PBrowserBridgeParent* aActor);
virtual mozilla::ipc::IPCResult RecvPBrowserBridgeConstructor(
PBrowserBridgeParent* aActor, const nsString& aPresentationURL,
const nsString& aRemoteType, BrowsingContext* aBrowsingContext,

Просмотреть файл

@ -2072,10 +2072,8 @@ already_AddRefed<RemoteBrowser> ContentChild::CreateBrowser(
TabId tabId(nsContentUtils::GenerateTabId());
RefPtr<BrowserBridgeChild> browserBridge =
new BrowserBridgeChild(aFrameLoader, aBrowsingContext, tabId);
// Reference is freed in BrowserChild::DeallocPBrowserBridgeChild.
browserChild->SendPBrowserBridgeConstructor(
do_AddRef(browserBridge).take(),
PromiseFlatString(aContext.PresentationURL()), aRemoteType,
browserBridge, PromiseFlatString(aContext.PresentationURL()), aRemoteType,
aBrowsingContext, chromeFlags, tabId);
browserBridge->mIPCOpen = true;

Просмотреть файл

@ -30,7 +30,7 @@ namespace dom {
* See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
* actors.
*/
async protocol PBrowserBridge {
async refcounted protocol PBrowserBridge {
manager PBrowser;
child: