diff --git a/netwerk/ipc/DocumentChannelParent.cpp b/netwerk/ipc/DocumentChannelParent.cpp index 9bce6c0ed9a3..9f5b1e78bcbd 100644 --- a/netwerk/ipc/DocumentChannelParent.cpp +++ b/netwerk/ipc/DocumentChannelParent.cpp @@ -144,36 +144,22 @@ void DocumentChannelParent::ActorDestroy(ActorDestroyReason why) { } } -void DocumentChannelParent::CancelChildForProcessSwitch() { - MOZ_ASSERT(!mDoingProcessSwitch, "Already in the middle of switching?"); - MOZ_ASSERT(NS_IsMainThread()); - - mDoingProcessSwitch = true; - if (CanSend()) { - Unused << SendCancelForProcessSwitch(); - } -} - bool DocumentChannelParent::RecvCancel(const nsresult& aStatusCode) { - if (mDoingProcessSwitch) { - return IPC_OK(); - } - - if (mChannel) { + if (mChannel && !mDoingProcessSwitch) { mChannel->Cancel(aStatusCode); } return true; } bool DocumentChannelParent::RecvSuspend() { - if (mChannel) { + if (mChannel && !mDoingProcessSwitch) { mChannel->Suspend(); } return true; } bool DocumentChannelParent::RecvResume() { - if (mChannel) { + if (mChannel && !mDoingProcessSwitch) { mChannel->Resume(); } return true; @@ -221,6 +207,10 @@ DocumentChannelParent::ReadyToVerify(nsresult aResultCode) { void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) { nsresult rv; + if (mDoingProcessSwitch && CanSend()) { + Unused << SendCancelForProcessSwitch(); + } + nsCOMPtr redirectChannel; if (mRedirectChannelId) { nsCOMPtr registrar = @@ -360,7 +350,11 @@ void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) { void DocumentChannelParent::TriggerCrossProcessSwitch() { MOZ_ASSERT(mRedirectContentProcessIdPromise); - CancelChildForProcessSwitch(); + MOZ_ASSERT(!mDoingProcessSwitch, "Already in the middle of switching?"); + MOZ_ASSERT(NS_IsMainThread()); + + mDoingProcessSwitch = true; + RefPtr self = this; mRedirectContentProcessIdPromise->Then( GetMainThreadSerialEventTarget(), __func__, diff --git a/netwerk/ipc/DocumentChannelParent.h b/netwerk/ipc/DocumentChannelParent.h index cf7844a0afbf..9d4d5069ad40 100644 --- a/netwerk/ipc/DocumentChannelParent.h +++ b/netwerk/ipc/DocumentChannelParent.h @@ -94,11 +94,6 @@ class DocumentChannelParent : public nsIInterfaceRequestor, virtual void ActorDestroy(ActorDestroyReason why) override; - // Notify the DocumentChannelChild that we're switching - // to a different process and that it can notify listeners - // that it's finished. - void CancelChildForProcessSwitch(); - private: virtual ~DocumentChannelParent() = default;