From bf4d274ec0e2ced0d1e4ccbaf7a16703f118eb93 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 16 Aug 2019 10:54:23 +0000 Subject: [PATCH] Bug 1570369 - Part 15: Use IPDL refcounted for PHttpChannel, r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D40264 --HG-- extra : moz-landing-system : lando --- netwerk/ipc/NeckoChild.cpp | 19 ------------------- netwerk/ipc/NeckoChild.h | 5 ----- netwerk/ipc/NeckoParent.cpp | 13 +++---------- netwerk/ipc/NeckoParent.h | 3 +-- netwerk/protocol/http/HttpChannelChild.cpp | 8 -------- netwerk/protocol/http/PHttpChannel.ipdl | 2 +- 6 files changed, 5 insertions(+), 45 deletions(-) diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index 4746a0820553..5d4cf3fc0576 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -78,25 +78,6 @@ void NeckoChild::InitNeckoChild() { } } -PHttpChannelChild* NeckoChild::AllocPHttpChannelChild( - const PBrowserOrId& browser, const SerializedLoadContext& loadContext, - const HttpChannelCreationArgs& aOpenArgs) { - // We don't allocate here: instead we always use IPDL constructor that takes - // an existing HttpChildChannel - MOZ_ASSERT_UNREACHABLE( - "AllocPHttpChannelChild should not be called on " - "child"); - return nullptr; -} - -bool NeckoChild::DeallocPHttpChannelChild(PHttpChannelChild* channel) { - MOZ_ASSERT(IsNeckoChild(), "DeallocPHttpChannelChild called by non-child!"); - - HttpChannelChild* child = static_cast(channel); - child->Release(); - return true; -} - PStunAddrsRequestChild* NeckoChild::AllocPStunAddrsRequestChild() { // We don't allocate here: instead we always use IPDL constructor that takes // an existing object diff --git a/netwerk/ipc/NeckoChild.h b/netwerk/ipc/NeckoChild.h index e05b05cd08c0..f4aa2d1b3490 100644 --- a/netwerk/ipc/NeckoChild.h +++ b/netwerk/ipc/NeckoChild.h @@ -25,11 +25,6 @@ class NeckoChild : public PNeckoChild { static void InitNeckoChild(); protected: - PHttpChannelChild* AllocPHttpChannelChild( - const PBrowserOrId&, const SerializedLoadContext&, - const HttpChannelCreationArgs& aOpenArgs); - bool DeallocPHttpChannelChild(PHttpChannelChild*); - PStunAddrsRequestChild* AllocPStunAddrsRequestChild(); bool DeallocPStunAddrsRequestChild(PStunAddrsRequestChild* aActor); diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 0f0c79c8130d..4650f81b4785 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -270,7 +270,7 @@ void NeckoParent::ActorDestroy(ActorDestroyReason aWhy) { // non-refcounted class. } -PHttpChannelParent* NeckoParent::AllocPHttpChannelParent( +already_AddRefed NeckoParent::AllocPHttpChannelParent( const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized, const HttpChannelCreationArgs& aOpenArgs) { nsCOMPtr requestingPrincipal = @@ -288,16 +288,9 @@ PHttpChannelParent* NeckoParent::AllocPHttpChannelParent( } PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(aSerialized); - HttpChannelParent* p = + RefPtr p = new HttpChannelParent(aBrowser, loadContext, overrideStatus); - p->AddRef(); - return p; -} - -bool NeckoParent::DeallocPHttpChannelParent(PHttpChannelParent* channel) { - HttpChannelParent* p = static_cast(channel); - p->Release(); - return true; + return p.forget(); } mozilla::ipc::IPCResult NeckoParent::RecvPHttpChannelConstructor( diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 79f4ff8c2d62..07ac6b9007fc 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -91,14 +91,13 @@ class NeckoParent : public PNeckoParent { protected: bool mSocketProcessBridgeInited; - PHttpChannelParent* AllocPHttpChannelParent( + already_AddRefed AllocPHttpChannelParent( const PBrowserOrId&, const SerializedLoadContext&, const HttpChannelCreationArgs& aOpenArgs); virtual mozilla::ipc::IPCResult RecvPHttpChannelConstructor( PHttpChannelParent* aActor, const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized, const HttpChannelCreationArgs& aOpenArgs) override; - bool DeallocPHttpChannelParent(PHttpChannelParent*); PStunAddrsRequestParent* AllocPStunAddrsRequestParent(); bool DeallocPStunAddrsRequestParent(PStunAddrsRequestParent* aActor); diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index c4e98e6c5553..b8b4f3e5b268 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -2166,10 +2166,6 @@ HttpChannelChild::ConnectParent(uint32_t registrarId) { HttpBaseChannel::SetDocshellUserAgentOverride(); - // The socket transport in the chrome process now holds a logical ref to us - // until OnStopRequest, or we do a redirect, or we hit an IPDL error. - AddRef(); - // This must happen before the constructor message is sent. Otherwise messages // from the parent could arrive quickly and be delivered to the wrong event // target. @@ -2933,10 +2929,6 @@ nsresult HttpChannelChild::ContinueAsyncOpen() { // target. SetEventTarget(); - // The socket transport in the chrome process now holds a logical ref to us - // until OnStopRequest, or we do a redirect, or we hit an IPDL error. - AddRef(); - PBrowserOrId browser = cc->GetBrowserOrId(browserChild); if (!gNeckoChild->SendPHttpChannelConstructor( this, browser, IPC::SerializedLoadContext(this), openArgs)) { diff --git a/netwerk/protocol/http/PHttpChannel.ipdl b/netwerk/protocol/http/PHttpChannel.ipdl index 86e6ee5c0350..3ecc1daf7822 100644 --- a/netwerk/protocol/http/PHttpChannel.ipdl +++ b/netwerk/protocol/http/PHttpChannel.ipdl @@ -25,7 +25,7 @@ namespace mozilla { namespace net { //------------------------------------------------------------------- -protocol PHttpChannel +refcounted protocol PHttpChannel { manager PNecko;