From 3f876da3c73c6743c0139575a21542f9d5c355bd Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 11 Nov 2019 21:02:46 +0000 Subject: [PATCH] Bug 1589270 - Part 1: Allow passing a specific status when disconnecting the child side, but only pass it to nsDocumentOpenInfo, not the load group. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D49526 --HG-- extra : moz-landing-system : lando --- netwerk/ipc/DocumentChannelChild.cpp | 14 ++++++++++++-- netwerk/ipc/DocumentChannelChild.h | 2 +- netwerk/ipc/DocumentChannelParent.cpp | 2 +- netwerk/ipc/PDocumentChannel.ipdl | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/netwerk/ipc/DocumentChannelChild.cpp b/netwerk/ipc/DocumentChannelChild.cpp index 202fb962976d..28f54544952e 100644 --- a/netwerk/ipc/DocumentChannelChild.cpp +++ b/netwerk/ipc/DocumentChannelChild.cpp @@ -243,8 +243,18 @@ void DocumentChannelChild::ShutdownListeners(nsresult aStatusCode) { } } -IPCResult DocumentChannelChild::RecvCancelForProcessSwitch() { - ShutdownListeners(NS_BINDING_ABORTED); +IPCResult DocumentChannelChild::RecvDisconnectChildListeners( + const nsresult& aStatus) { + MOZ_ASSERT(NS_FAILED(aStatus)); + // Make sure we remove from the load group before + // setting mStatus, as existing tests expect the + // status to be successful when we disconnect. + if (mLoadGroup) { + mLoadGroup->RemoveRequest(this, nullptr, aStatus); + mLoadGroup = nullptr; + } + + ShutdownListeners(aStatus); return IPC_OK(); } diff --git a/netwerk/ipc/DocumentChannelChild.h b/netwerk/ipc/DocumentChannelChild.h index fda6018432f5..8a86bcb7a3f7 100644 --- a/netwerk/ipc/DocumentChannelChild.h +++ b/netwerk/ipc/DocumentChannelChild.h @@ -57,7 +57,7 @@ class DocumentChannelChild final : public PDocumentChannelChild, mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& aStatusCode); - mozilla::ipc::IPCResult RecvCancelForProcessSwitch(); + mozilla::ipc::IPCResult RecvDisconnectChildListeners(const nsresult& aStatus); mozilla::ipc::IPCResult RecvDeleteSelf(); diff --git a/netwerk/ipc/DocumentChannelParent.cpp b/netwerk/ipc/DocumentChannelParent.cpp index d14cb364f27f..1686207244bc 100644 --- a/netwerk/ipc/DocumentChannelParent.cpp +++ b/netwerk/ipc/DocumentChannelParent.cpp @@ -218,7 +218,7 @@ void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) { nsresult rv; if (mDoingProcessSwitch && CanSend()) { - Unused << SendCancelForProcessSwitch(); + Unused << SendDisconnectChildListeners(NS_BINDING_ABORTED); } nsCOMPtr redirectChannel; diff --git a/netwerk/ipc/PDocumentChannel.ipdl b/netwerk/ipc/PDocumentChannel.ipdl index 2c27c603ebe2..15fc065ef240 100644 --- a/netwerk/ipc/PDocumentChannel.ipdl +++ b/netwerk/ipc/PDocumentChannel.ipdl @@ -64,7 +64,8 @@ isThirdParty); // This message is sent to a child that has been redirected to another process. // As a consequence, it should cleanup the channel listeners and remove the // request from the loadGroup. - async CancelForProcessSwitch(); + // aStatus must be an error result. + async DisconnectChildListeners(nsresult aStatus); async RedirectToRealChannel(uint32_t aRegistrarId, nsIURI aURI,