diff --git a/dom/ipc/BrowserBridgeParent.cpp b/dom/ipc/BrowserBridgeParent.cpp index 633f6ae2db7b..7db0f9dd3528 100644 --- a/dom/ipc/BrowserBridgeParent.cpp +++ b/dom/ipc/BrowserBridgeParent.cpp @@ -86,9 +86,8 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL, auto windowParent = MakeRefPtr(aWindowInit, /* inprocess */ false); - // DeallocPWindowGlobalParent releases the ref taken. ManagedEndpoint windowChildEp = - browserParent->OpenPWindowGlobalEndpoint(do_AddRef(windowParent).take()); + browserParent->OpenPWindowGlobalEndpoint(windowParent); if (NS_WARN_IF(!windowChildEp.IsValid())) { MOZ_ASSERT(false, "WindowGlobal Open Endpoint Failed"); return NS_ERROR_FAILURE; diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 16af0efc8a7f..27b26f43e739 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -3290,18 +3290,6 @@ bool BrowserChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) { return true; } -PWindowGlobalChild* BrowserChild::AllocPWindowGlobalChild( - const WindowGlobalInit&) { - MOZ_CRASH("We should never be manually allocating PWindowGlobalChild actors"); - return nullptr; -} - -bool BrowserChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) { - // This reference was added in WindowGlobalChild::Create. - static_cast(aActor)->Release(); - return true; -} - ScreenIntSize BrowserChild::GetInnerSize() { LayoutDeviceIntSize innerSize = RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale()); diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index adc4c1fda431..50aa220f8f18 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -660,10 +660,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, protected: virtual ~BrowserChild(); - PWindowGlobalChild* AllocPWindowGlobalChild(const WindowGlobalInit& aInit); - - bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor); - mozilla::ipc::IPCResult RecvDestroy(); mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive); diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index 6e223f83e4a2..e89fd7225c13 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -1242,18 +1242,11 @@ IPCResult BrowserParent::RecvNewWindowGlobal( // Construct our new WindowGlobalParent, bind, and initialize it. auto wgp = MakeRefPtr(aInit, /* inproc */ false); - // Reference freed in DeallocPWindowGlobalParent. - BindPWindowGlobalEndpoint(std::move(aEndpoint), do_AddRef(wgp).take()); + BindPWindowGlobalEndpoint(std::move(aEndpoint), wgp); wgp->Init(aInit); return IPC_OK(); } -bool BrowserParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) { - // Free reference from RecvNewWindowGlobal. - static_cast(aActor)->Release(); - return true; -} - IPCResult BrowserParent::RecvPBrowserBridgeConstructor( PBrowserBridgeParent* aActor, const nsString& aName, const nsString& aRemoteType, BrowsingContext* aBrowsingContext, diff --git a/dom/ipc/BrowserParent.h b/dom/ipc/BrowserParent.h index b91e77134bfc..11d666c887d0 100644 --- a/dom/ipc/BrowserParent.h +++ b/dom/ipc/BrowserParent.h @@ -473,8 +473,6 @@ class BrowserParent final : public PBrowserParent, const uint64_t& aParentID, const uint32_t& aMsaaID, const IAccessibleHolder& aDocCOMProxy) override; - bool DeallocPWindowGlobalParent(PWindowGlobalParent* aActor); - mozilla::ipc::IPCResult RecvNewWindowGlobal( ManagedEndpoint&& aEndpoint, const WindowGlobalInit& aInit); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 085f5f2f1c39..76a875d6b130 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1019,9 +1019,8 @@ nsresult ContentChild::ProvideWindowCommon( } // Open a remote endpoint for our PWindowGlobal actor. - // DeallocPWindowGlobalChild releases the ref taken. ManagedEndpoint windowParentEp = - newChild->OpenPWindowGlobalEndpoint(do_AddRef(windowChild).take()); + newChild->OpenPWindowGlobalEndpoint(windowChild); if (NS_WARN_IF(!windowParentEp.IsValid())) { return NS_ERROR_ABORT; } @@ -1881,9 +1880,8 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser( return IPC_FAIL(this, "BindPBrowserEndpoint failed"); } - // The ref here is released in DeallocPWindowGlobalChild. - if (NS_WARN_IF(!browserChild->BindPWindowGlobalEndpoint( - std::move(aWindowEp), do_AddRef(windowChild).take()))) { + if (NS_WARN_IF(!browserChild->BindPWindowGlobalEndpoint(std::move(aWindowEp), + windowChild))) { return IPC_FAIL(this, "BindPWindowGlobalEndpoint failed"); } windowChild->Init(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 49a353c1739d..b42672c682a8 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1222,9 +1222,8 @@ already_AddRefed ContentParent::CreateBrowser( MakeRefPtr(windowInit, /* inprocess */ false); // Open a remote endpoint for the initial PWindowGlobal actor. - // DeallocPWindowGlobalParent releases the ref taken. ManagedEndpoint windowEp = - browserParent->OpenPWindowGlobalEndpoint(do_AddRef(windowParent).take()); + browserParent->OpenPWindowGlobalEndpoint(windowParent); if (NS_WARN_IF(!windowEp.IsValid())) { return nullptr; } @@ -3365,9 +3364,8 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser( } } - // The ref here is released in DeallocPWindowGlobalParent. - if (NS_WARN_IF(!parent->BindPWindowGlobalEndpoint( - std::move(aWindowEp), do_AddRef(initialWindow).take()))) { + if (NS_WARN_IF(!parent->BindPWindowGlobalEndpoint(std::move(aWindowEp), + initialWindow))) { return IPC_FAIL(this, "BindPWindowGlobalEndpoint failed"); } diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl index c32a1d156231..21bf2097a0e1 100644 --- a/dom/ipc/PWindowGlobal.ipdl +++ b/dom/ipc/PWindowGlobal.ipdl @@ -31,7 +31,7 @@ struct JSWindowActorMessageMeta { * link either between the chrome/content process, or will be in-process, for * documents which are loaded in the chrome process. */ -async protocol PWindowGlobal +async refcounted protocol PWindowGlobal { manager PBrowser or PInProcess; diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index 03fdaacb1f70..1475d1e14f7f 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -101,22 +101,20 @@ already_AddRefed WindowGlobalChild::Create( // Note: ref is released in DeallocPWindowGlobalChild ManagedEndpoint endpoint = - ipChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take()); + ipChild->OpenPWindowGlobalEndpoint(wgc); auto wgp = MakeRefPtr(init, /* aInProcess */ true); // Note: ref is released in DeallocPWindowGlobalParent - ipParent->BindPWindowGlobalEndpoint(std::move(endpoint), - do_AddRef(wgp).take()); + ipParent->BindPWindowGlobalEndpoint(std::move(endpoint), wgp); wgp->Init(init); } else { RefPtr browserChild = BrowserChild::GetFrom(static_cast(aWindow)); MOZ_ASSERT(browserChild); - // Note: ref is released in DeallocPWindowGlobalChild ManagedEndpoint endpoint = - browserChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take()); + browserChild->OpenPWindowGlobalEndpoint(wgc); browserChild->SendNewWindowGlobal(std::move(endpoint), init); } diff --git a/ipc/glue/InProcessChild.cpp b/ipc/glue/InProcessChild.cpp deleted file mode 100644 index 896f7a6fb0c7..000000000000 --- a/ipc/glue/InProcessChild.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- 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/ipc/InProcessChild.h" -#include "mozilla/dom/WindowGlobalChild.h" - -using namespace mozilla::dom; - -namespace mozilla { -namespace ipc { - -bool InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) { - // Free IPC-held reference - static_cast(aActor)->Release(); - return true; -} - -} // namespace ipc -} // namespace mozilla diff --git a/ipc/glue/InProcessChild.h b/ipc/glue/InProcessChild.h index 8e673418ed15..1f45294d27a4 100644 --- a/ipc/glue/InProcessChild.h +++ b/ipc/glue/InProcessChild.h @@ -43,9 +43,6 @@ class InProcessChild : public PInProcessChild { // |nullptr|. static IProtocol* ParentActorFor(IProtocol* aActor); - protected: - bool DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor); - private: // NOTE: PInProcess lifecycle management is declared as staic methods and // state on InProcessParent, and implemented in InProcessImpl.cpp. diff --git a/ipc/glue/InProcessImpl.cpp b/ipc/glue/InProcessImpl.cpp index 042f9dca31e0..73ab46d17b38 100644 --- a/ipc/glue/InProcessImpl.cpp +++ b/ipc/glue/InProcessImpl.cpp @@ -192,5 +192,7 @@ IProtocol* InProcessChild::ParentActorFor(IProtocol* aActor) { return GetOtherInProcessActor(aActor); } +NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver) + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/InProcessParent.cpp b/ipc/glue/InProcessParent.cpp deleted file mode 100644 index 1e0ea7e259ef..000000000000 --- a/ipc/glue/InProcessParent.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- 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/ipc/InProcessParent.h" -#include "mozilla/dom/WindowGlobalParent.h" - -using namespace mozilla::dom; - -namespace mozilla { -namespace ipc { - -NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver) - -bool InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) { - // Free IPC-held reference. - static_cast(aActor)->Release(); - return true; -} - -} // namespace ipc -} // namespace mozilla diff --git a/ipc/glue/InProcessParent.h b/ipc/glue/InProcessParent.h index 77f506654125..8f27b9b1bb95 100644 --- a/ipc/glue/InProcessParent.h +++ b/ipc/glue/InProcessParent.h @@ -44,9 +44,6 @@ class InProcessParent : public nsIObserver, public PInProcessParent { // |nullptr|. static IProtocol* ChildActorFor(IProtocol* aActor); - protected: - bool DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor); - private: // Lifecycle management is implemented in InProcessImpl.cpp virtual void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build index cb0bedb36162..cc5f410ce84b 100644 --- a/ipc/glue/moz.build +++ b/ipc/glue/moz.build @@ -148,9 +148,7 @@ UNIFIED_SOURCES += [ 'CrashReporterMetadataShmem.cpp', 'FileDescriptor.cpp', 'FileDescriptorUtils.cpp', - 'InProcessChild.cpp', 'InProcessImpl.cpp', - 'InProcessParent.cpp', 'InputStreamUtils.cpp', 'IPCMessageUtils.cpp', 'IPCStreamChild.cpp',