From 94a3210fdf38535904d783932ddeb4ab3e7013c8 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 28 Apr 2020 22:31:55 +0000 Subject: [PATCH] Bug 1633644 - P2. Do not call RedirectToRealChannel if the channel got cancelled. r=mattwoodrow. Depends on D72795 Differential Revision: https://phabricator.services.mozilla.com/D72809 --- netwerk/ipc/DocumentLoadListener.cpp | 9 ++++++++- netwerk/ipc/DocumentLoadListener.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/netwerk/ipc/DocumentLoadListener.cpp b/netwerk/ipc/DocumentLoadListener.cpp index a478b1c081a3..0c56b2bdbd29 100644 --- a/netwerk/ipc/DocumentLoadListener.cpp +++ b/netwerk/ipc/DocumentLoadListener.cpp @@ -700,6 +700,8 @@ void DocumentLoadListener::Cancel(const nsresult& aStatusCode) { ("DocumentLoadListener Cancel [this=%p, " "aStatusCode=%" PRIx32 " ]", this, static_cast(aStatusCode))); + mCancelled = true; + if (mDoingProcessSwitch) { // If we've already initiated process-switching // then we can no longer be cancelled and we'll @@ -1431,8 +1433,13 @@ DocumentLoadListener::RedirectToRealChannel( return EnsureBridge()->Then( GetCurrentThreadSerialEventTarget(), __func__, - [endpoints = std::move(aStreamFilterEndpoints), aRedirectFlags, + [self = RefPtr(this), + endpoints = std::move(aStreamFilterEndpoints), aRedirectFlags, aLoadFlags](ADocumentChannelBridge* aBridge) mutable { + if (self->mCancelled) { + return PDocumentChannelParent::RedirectToRealChannelPromise:: + CreateAndResolve(NS_BINDING_ABORTED, __func__); + } return aBridge->RedirectToRealChannel(std::move(endpoints), aRedirectFlags, aLoadFlags); }, diff --git a/netwerk/ipc/DocumentLoadListener.h b/netwerk/ipc/DocumentLoadListener.h index 37bf41f57e64..5658b7969420 100644 --- a/netwerk/ipc/DocumentLoadListener.h +++ b/netwerk/ipc/DocumentLoadListener.h @@ -434,6 +434,9 @@ class DocumentLoadListener : public nsIInterfaceRequestor, // This identifier is set by MaybeTriggerProcessSwitch, and is later // passed to the childChannel in order to identify it in the new process. uint64_t mCrossProcessRedirectIdentifier = 0; + + // True if cancelled. + bool mCancelled = false; }; NS_DEFINE_STATIC_IID_ACCESSOR(DocumentLoadListener, DOCUMENT_LOAD_LISTENER_IID)