1 /* vim: set sw=2 ts=8 et tw=80 : */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_net_DocumentLoadListener_h
8 #define mozilla_net_DocumentLoadListener_h
10 #include "mozilla/MozPromise.h"
11 #include "mozilla/Variant.h"
12 #include "mozilla/WeakPtr.h"
13 #include "mozilla/ipc/Endpoint.h"
14 #include "mozilla/dom/SessionHistoryEntry.h"
15 #include "EarlyHintsService.h"
16 #include "mozilla/net/NeckoCommon.h"
17 #include "mozilla/net/NeckoParent.h"
18 #include "mozilla/net/PDocumentChannelParent.h"
19 #include "mozilla/net/ParentChannelListener.h"
20 #include "nsDOMNavigationTiming.h"
21 #include "nsIBrowser.h"
22 #include "nsIChannelEventSink.h"
23 #include "nsIEarlyHintObserver.h"
24 #include "nsIInterfaceRequestor.h"
25 #include "nsIMultiPartChannel.h"
26 #include "nsIParentChannel.h"
27 #include "nsIParentRedirectingChannel.h"
28 #include "nsIProgressEventSink.h"
29 #include "nsIRedirectResultListener.h"
31 #define DOCUMENT_LOAD_LISTENER_IID \
33 0x3b393c56, 0x9e01, 0x11e9, { \
34 0xa2, 0xa3, 0x2a, 0x2a, 0xe2, 0xdb, 0xcc, 0xe4 \
40 class CanonicalBrowsingContext
;
41 struct NavigationIsolationOptions
;
44 using ChildEndpointPromise
=
45 MozPromise
<mozilla::ipc::Endpoint
<extensions::PStreamFilterChild
>, bool,
48 // If we've been asked to attach a stream filter to our channel,
49 // then we return this promise and defer until we know the final
50 // content process. At that point we setup Endpoints between
51 // mStramFilterProcessId and the new content process, and send
52 // the parent Endpoint to the new process.
53 // Once we have confirmation of that being bound in the content
54 // process, we resolve the promise the child Endpoint.
55 struct StreamFilterRequest
{
56 StreamFilterRequest() = default;
57 StreamFilterRequest(StreamFilterRequest
&&) = default;
58 ~StreamFilterRequest() {
60 mPromise
->Reject(false, __func__
);
63 RefPtr
<ChildEndpointPromise::Private
> mPromise
;
64 mozilla::ipc::Endpoint
<extensions::PStreamFilterChild
> mChildEndpoint
;
67 } // namespace mozilla
68 MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR(mozilla::net::StreamFilterRequest
)
76 * DocumentLoadListener represents a connecting document load for a
77 * CanonicalBrowsingContext (in the parent process).
79 * It creates a network channel for the document load and then waits for it to
80 * receive a response (after all redirects are resolved). It then decides where
81 * to handle that load (could be in a different process from the initiator),
82 * and then sets up a real network nsIChannel to deliver the data to the final
83 * destination docshell, maybe through an nsIParentChannel/nsIChildChannel IPDL
86 * In the case where this was initiated from an nsDocShell, we also create an
87 * nsIChannel to act as a placeholder within the docshell while this process
88 * completes, and then notify the docshell of a 'redirect' when we replace this
89 * channel with the real one.
92 // TODO: We currently don't implement nsIProgressEventSink and forward those
93 // to the child. Should we? We get the interface requested.
94 class DocumentLoadListener
: public nsIInterfaceRequestor
,
95 public nsIAsyncVerifyRedirectReadyCallback
,
96 public nsIParentChannel
,
97 public nsIChannelEventSink
,
98 public HttpChannelSecurityWarningReporter
,
99 public nsIMultiPartChannelListener
,
100 public nsIProgressEventSink
,
101 public nsIEarlyHintObserver
{
103 // See the comment on GetLoadingBrowsingContext for explanation of
104 // aLoadingBrowsingContext.
105 DocumentLoadListener(dom::CanonicalBrowsingContext
* aLoadingBrowsingContext
,
106 bool aIsDocumentLoad
);
108 struct OpenPromiseSucceededType
{
109 nsTArray
<mozilla::ipc::Endpoint
<extensions::PStreamFilterParent
>>
110 mStreamFilterEndpoints
;
111 uint32_t mRedirectFlags
;
113 uint32_t mEarlyHintLinkType
;
114 RefPtr
<PDocumentChannelParent::RedirectToRealChannelPromise::Private
>
117 struct OpenPromiseFailedType
{
119 nsresult mLoadGroupStatus
;
120 // This is set to true if the navigation in the content process should not
121 // be cancelled, as the load is logically continuing within the current
122 // browsing session, just within a different process or browsing context.
123 bool mContinueNavigating
= false;
127 MozPromise
<OpenPromiseSucceededType
, OpenPromiseFailedType
, true>;
129 // Interface which may be provided when performing an <object> or <embed> load
130 // with `DocumentLoadListener`, to allow upgrading the Object load to a proper
132 struct ObjectUpgradeHandler
: public SupportsWeakPtr
{
133 using ObjectUpgradePromise
=
134 MozPromise
<RefPtr
<dom::CanonicalBrowsingContext
>, nsresult
,
135 true /* isExclusive */>;
137 // Upgrade an object load to be a potentially remote document.
139 // The returned promise will resolve with the BrowsingContext which has been
140 // created in the <object> or <embed> element to finish the load with.
141 virtual RefPtr
<ObjectUpgradePromise
> UpgradeObjectLoad() = 0;
145 // Creates the channel, and then calls AsyncOpen on it.
146 // The DocumentLoadListener will require additional process from the consumer
147 // in order to complete the redirect to the end channel. This is done by
148 // returning a RedirectToRealChannelPromise and then waiting for it to be
149 // resolved or rejected accordingly.
150 // Once that promise is resolved; the consumer no longer needs to hold a
151 // reference to the DocumentLoadListener nor will the consumer required to be
153 RefPtr
<OpenPromise
> Open(nsDocShellLoadState
* aLoadState
, LoadInfo
* aLoadInfo
,
154 nsLoadFlags aLoadFlags
, uint32_t aCacheKey
,
155 const Maybe
<uint64_t>& aChannelId
,
156 const TimeStamp
& aAsyncOpenTime
,
157 nsDOMNavigationTiming
* aTiming
,
158 Maybe
<dom::ClientInfo
>&& aInfo
, bool aUrgentStart
,
159 dom::ContentParent
* aContentParent
, nsresult
* aRv
);
162 RefPtr
<OpenPromise
> OpenDocument(
163 nsDocShellLoadState
* aLoadState
, uint32_t aCacheKey
,
164 const Maybe
<uint64_t>& aChannelId
, const TimeStamp
& aAsyncOpenTime
,
165 nsDOMNavigationTiming
* aTiming
, Maybe
<dom::ClientInfo
>&& aInfo
,
166 Maybe
<bool> aUriModified
, Maybe
<bool> aIsEmbeddingBlockedError
,
167 dom::ContentParent
* aContentParent
, nsresult
* aRv
);
169 RefPtr
<OpenPromise
> OpenObject(
170 nsDocShellLoadState
* aLoadState
, uint32_t aCacheKey
,
171 const Maybe
<uint64_t>& aChannelId
, const TimeStamp
& aAsyncOpenTime
,
172 nsDOMNavigationTiming
* aTiming
, Maybe
<dom::ClientInfo
>&& aInfo
,
173 uint64_t aInnerWindowId
, nsLoadFlags aLoadFlags
,
174 nsContentPolicyType aContentPolicyType
, bool aUrgentStart
,
175 dom::ContentParent
* aContentParent
,
176 ObjectUpgradeHandler
* aObjectUpgradeHandler
, nsresult
* aRv
);
178 // Creates a DocumentLoadListener entirely in the parent process and opens it,
179 // and never needs a DocumentChannel to connect to an existing docshell.
180 // Once we get a response it takes the 'process switch' path to find the right
181 // process and docshell, and delivers the response there directly.
182 static bool LoadInParent(dom::CanonicalBrowsingContext
* aBrowsingContext
,
183 nsDocShellLoadState
* aLoadState
,
184 bool aSetNavigating
);
186 // Creates a DocumentLoadListener directly in the parent process and opens it,
187 // without needing an existing DocumentChannel.
188 // If successful it registers a unique identifier (return in aOutIdent) to
189 // keep it alive until a future DocumentChannel can attach to it, or we fail
191 static bool SpeculativeLoadInParent(
192 dom::CanonicalBrowsingContext
* aBrowsingContext
,
193 nsDocShellLoadState
* aLoadState
);
195 // Ensures that a load identifier allocated by OpenFromParent has
196 // been deregistered if it hasn't already been claimed.
197 // This also cancels the load.
198 static void CleanupParentLoadAttempt(uint64_t aLoadIdent
);
200 // Looks up aLoadIdent to find the associated, cleans up the registration
201 static RefPtr
<OpenPromise
> ClaimParentLoad(DocumentLoadListener
** aListener
,
203 Maybe
<uint64_t> aChannelId
);
205 // Called by the DocumentChannelParent if actor got destroyed or the parent
206 // channel got deleted.
210 NS_DECL_NSIREQUESTOBSERVER
211 NS_DECL_NSISTREAMLISTENER
212 NS_DECL_NSIPARENTCHANNEL
213 NS_DECL_NSIINTERFACEREQUESTOR
214 NS_DECL_NSIASYNCVERIFYREDIRECTREADYCALLBACK
215 NS_DECL_NSICHANNELEVENTSINK
216 NS_DECL_NSIMULTIPARTCHANNELLISTENER
217 NS_DECL_NSIPROGRESSEVENTSINK
218 NS_DECL_NSIEARLYHINTOBSERVER
220 // We suspend the underlying channel when replacing ourselves with
221 // the real listener channel.
222 // This helper resumes the underlying channel again, and manually
223 // forwards any nsIStreamListener messages that arrived while we
224 // were suspended (which might have failed).
225 // Returns true if the channel was finished before we could resume it.
226 bool ResumeSuspendedChannel(nsIStreamListener
* aListener
);
228 NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_LOAD_LISTENER_IID
)
230 // Called by the DocumentChannel if cancelled.
231 void Cancel(const nsresult
& aStatusCode
, const nsACString
& aReason
);
233 nsIChannel
* GetChannel() const { return mChannel
; }
235 uint32_t GetRedirectChannelId() const { return mRedirectChannelId
; }
237 nsresult
ReportSecurityMessage(const nsAString
& aMessageTag
,
238 const nsAString
& aMessageCategory
) override
{
239 ReportSecurityMessageParams params
;
240 params
.mMessageTag
= aMessageTag
;
241 params
.mMessageCategory
= aMessageCategory
;
242 mSecurityWarningFunctions
.AppendElement(
243 SecurityWarningFunction
{VariantIndex
<0>{}, std::move(params
)});
247 nsresult
LogBlockedCORSRequest(const nsAString
& aMessage
,
248 const nsACString
& aCategory
,
249 bool aIsWarning
) override
{
250 LogBlockedCORSRequestParams params
;
251 params
.mMessage
= aMessage
;
252 params
.mCategory
= aCategory
;
253 params
.mIsWarning
= aIsWarning
;
254 mSecurityWarningFunctions
.AppendElement(
255 SecurityWarningFunction
{VariantIndex
<1>{}, std::move(params
)});
259 nsresult
LogMimeTypeMismatch(const nsACString
& aMessageName
, bool aWarning
,
260 const nsAString
& aURL
,
261 const nsAString
& aContentType
) override
{
262 LogMimeTypeMismatchParams params
;
263 params
.mMessageName
= aMessageName
;
264 params
.mWarning
= aWarning
;
266 params
.mContentType
= aContentType
;
267 mSecurityWarningFunctions
.AppendElement(
268 SecurityWarningFunction
{VariantIndex
<2>{}, std::move(params
)});
272 // The content process corresponding to this DocumentLoadListener, or nullptr
273 // if connected to the parent process.
274 dom::ContentParent
* GetContentParent() const { return mContentParent
; }
276 // The process id of the content process that we are being called from
277 // or 0 initiated from a parent process load.
278 base::ProcessId
OtherPid() const;
280 [[nodiscard
]] RefPtr
<ChildEndpointPromise
> AttachStreamFilter();
282 // EarlyHints aren't supported on ParentProcessDocumentChannels yet, allow
283 // EarlyHints to be cancelled from there (Bug 1819886)
284 void CancelEarlyHintPreloads();
286 // Gets the EarlyHint preloads for this document to pass them to the
287 // ContentProcess. Registers them in the EarlyHintRegister
288 void RegisterEarlyHintLinksAndGetConnectArgs(
289 dom::ContentParentId aCpId
, nsTArray
<EarlyHintConnectArgs
>& aOutLinks
);
291 // Serializes all data needed to setup the new replacement channel
292 // in the content process into the RedirectToRealChannelArgs struct.
293 void SerializeRedirectData(RedirectToRealChannelArgs
& aArgs
,
294 bool aIsCrossProcess
, uint32_t aRedirectFlags
,
296 nsTArray
<EarlyHintConnectArgs
>&& aEarlyHints
,
297 uint32_t aEarlyHintLinkType
) const;
299 uint64_t GetLoadIdentifier() const { return mLoadIdentifier
; }
300 uint32_t GetLoadType() const { return mLoadStateLoadType
; }
301 bool IsDownload() const { return mIsDownload
; }
302 bool IsLoadingJSURI() const { return mIsLoadingJSURI
; }
303 nsDOMNavigationTiming
* GetTiming() { return mTiming
; }
305 mozilla::dom::LoadingSessionHistoryInfo
* GetLoadingSessionHistoryInfo() {
306 return mLoadingSessionHistoryInfo
.get();
309 bool IsDocumentLoad() const { return mIsDocumentLoad
; }
311 // Determine what process switching behavior a browser element should have.
312 enum ProcessBehavior
: uint8_t {
313 // Gecko won't automatically change which process this frame, or it's
314 // subframes, are loaded in.
315 PROCESS_BEHAVIOR_DISABLED
,
317 // If `useRemoteTabs` is enabled, Gecko will change which process this frame
318 // is loaded in automatically, without calling `performProcessSwitch`.
319 // When `useRemoteSubframes` is enabled, subframes will change processes.
320 PROCESS_BEHAVIOR_STANDARD
,
322 // Gecko won't automatically change which process this frame is loaded, but
323 // when `useRemoteSubframes` is enabled, subframes will change processes.
325 // NOTE: This configuration is included only for backwards compatibility,
326 // and will be removed, as it can easily lead to invalid behavior.
327 PROCESS_BEHAVIOR_SUBFRAME_ONLY
,
331 virtual ~DocumentLoadListener();
334 RefPtr
<OpenPromise
> OpenInParent(nsDocShellLoadState
* aLoadState
,
335 bool aSupportsRedirectToRealChannel
);
337 friend class ParentProcessDocumentOpenInfo
;
339 // Will reject the promise to notify the DLL consumer that we are done.
341 // If `aContinueNavigating` is true, the navigation in the content process
342 // will not be aborted, as navigation is logically continuing in the existing
343 // browsing session (e.g. due to a process switch or entering the bfcache).
344 void DisconnectListeners(nsresult aStatus
, nsresult aLoadGroupStatus
,
345 bool aContinueNavigating
= false);
347 // Called when we were created without a document channel, and creation has
348 // failed, and won't ever be attached.
349 void NotifyDocumentChannelFailed();
351 // Initiates the switch from DocumentChannel to the real protocol-specific
352 // channel, and ensures that RedirectToRealChannelFinished is called when
354 void TriggerRedirectToRealChannel(
355 const Maybe
<dom::ContentParent
*>& aDestinationProcess
,
356 nsTArray
<StreamFilterRequest
> aStreamFilterRequests
);
358 // Called once the content-process side on setting up a replacement
359 // channel is complete. May wait for the new parent channel to
360 // finish, and then calls into FinishReplacementChannelSetup.
361 void RedirectToRealChannelFinished(nsresult aRv
);
363 // Completes the replacement of the new channel.
364 // This redirects the ParentChannelListener to forward any future
365 // messages to the new channel, manually forwards any being held
366 // by us, and resumes the underlying source channel.
367 void FinishReplacementChannelSetup(nsresult aResult
);
369 // Called from `OnStartRequest` to make the decision about whether or not to
370 // change process. This method will return `nullptr` if the current target
371 // process is appropriate.
372 // aWillSwitchToRemote is set to true if we initiate a process switch,
373 // and that the new remote type will be something other than NOT_REMOTE
374 bool MaybeTriggerProcessSwitch(bool* aWillSwitchToRemote
);
376 // Called when the process switch is going to happen, potentially
377 // asynchronously, from `MaybeTriggerProcessSwitch`.
379 // aContext should be the target context for the navigation. This will either
380 // be the loading BrowsingContext, the newly created BrowsingContext for an
381 // object or embed element load, or a newly created tab for new tab load.
383 // If `aIsNewTab` is specified, the navigation in the original process will be
384 // aborted immediately, rather than waiting for a process switch to happen and
385 // the previous page to be unloaded or hidden.
386 void TriggerProcessSwitch(dom::CanonicalBrowsingContext
* aContext
,
387 const dom::NavigationIsolationOptions
& aOptions
,
388 bool aIsNewTab
= false);
390 // A helper for TriggerRedirectToRealChannel that abstracts over
391 // the same-process and cross-process switch cases and returns
392 // a single promise to wait on.
393 using ParentEndpoint
=
394 mozilla::ipc::Endpoint
<extensions::PStreamFilterParent
>;
395 RefPtr
<PDocumentChannelParent::RedirectToRealChannelPromise
>
396 RedirectToRealChannel(uint32_t aRedirectFlags
, uint32_t aLoadFlags
,
397 const Maybe
<dom::ContentParent
*>& aDestinationProcess
,
398 nsTArray
<ParentEndpoint
>&& aStreamFilterEndpoints
);
400 // A helper for RedirectToRealChannel that handles the case where we started
401 // from a content process and are process switching into the parent process.
402 RefPtr
<PDocumentChannelParent::RedirectToRealChannelPromise
>
403 RedirectToParentProcess(uint32_t aRedirectFlags
, uint32_t aLoadFlags
);
405 // Return the Browsing Context that is performing the load.
406 // For document loads, the BC is the one that the (sub)doc
407 // will load into. For <object>/<embed>, it's the embedder document's BC.
408 dom::CanonicalBrowsingContext
* GetLoadingBrowsingContext() const;
410 // Return the Browsing Context that document is being loaded into. For
411 // non-document loads, this will return nullptr.
412 dom::CanonicalBrowsingContext
* GetDocumentBrowsingContext() const;
413 dom::CanonicalBrowsingContext
* GetTopBrowsingContext() const;
415 // Return the Window Context which which contains the element which the load
416 // is being performed in. For toplevel loads, this will return `nullptr`.
417 dom::WindowGlobalParent
* GetParentWindowContext() const;
419 void AddURIVisit(nsIChannel
* aChannel
, uint32_t aLoadFlags
);
420 bool HasCrossOriginOpenerPolicyMismatch() const;
421 void ApplyPendingFunctions(nsIParentChannel
* aChannel
) const;
423 void Disconnect(bool aContinueNavigating
);
425 void MaybeReportBlockedByURLClassifier(nsresult aStatus
);
427 // Returns true if a channel with aStatus will display
428 // some sort of content (could be the actual channel data,
429 // attempt a uri fixup and new load, or an error page).
430 // Returns false if the docshell will ignore the load entirely.
431 bool DocShellWillDisplayContent(nsresult aStatus
);
433 void FireStateChange(uint32_t aStateFlags
, nsresult aStatus
);
435 // Returns true if this is a failed load, where we have successfully
436 // created a fixed URI to attempt loading instead.
437 // If successful, this calls DisconnectListeners to completely finish
438 // the current load, and calls BrowsingContext::LoadURI to start the new one.
439 bool MaybeHandleLoadErrorWithURIFixup(nsresult aStatus
);
441 // This defines a variant that describes all the attribute setters (and their
442 // parameters) from nsIParentChannel
444 // SetClassifierMatchedInfo(const nsACString& aList, const nsACString&
445 // aProvider, const nsACString& aFullHash) = 0;
446 // SetClassifierMatchedTrackingInfo(const nsACString& aLists, const
447 // nsACString& aFullHashes) = 0; NotifyClassificationFlags(uint32_t
448 // aClassificationFlags, bool aIsThirdParty) = 0;
449 struct ClassifierMatchedInfoParams
{
455 struct ClassifierMatchedTrackingInfoParams
{
457 nsCString mFullHashes
;
460 struct ClassificationFlagsParams
{
461 uint32_t mClassificationFlags
;
465 using IParentChannelFunction
=
466 mozilla::Variant
<ClassifierMatchedInfoParams
,
467 ClassifierMatchedTrackingInfoParams
,
468 ClassificationFlagsParams
>;
470 // Store a list of all the attribute setters that have been called on this
471 // channel, so that we can repeat them on the real channel that we redirect
473 nsTArray
<IParentChannelFunction
> mIParentChannelFunctions
;
475 // This defines a variant this describes all the functions
476 // from HttpChannelSecurityWarningReporter so that we can forward
477 // them on to the real channel.
479 struct ReportSecurityMessageParams
{
480 nsString mMessageTag
;
481 nsString mMessageCategory
;
484 struct LogBlockedCORSRequestParams
{
490 struct LogMimeTypeMismatchParams
{
491 nsCString mMessageName
;
492 bool mWarning
= false;
494 nsString mContentType
;
497 using SecurityWarningFunction
=
498 mozilla::Variant
<ReportSecurityMessageParams
, LogBlockedCORSRequestParams
,
499 LogMimeTypeMismatchParams
>;
500 nsTArray
<SecurityWarningFunction
> mSecurityWarningFunctions
;
502 // TODO Backtrack this.
503 // The set of nsIStreamListener functions that got called on this
504 // listener, so that we can replay them onto the replacement channel's
505 // listener. This should generally only be OnStartRequest, since we
506 // Suspend() the channel at that point, but it can fail sometimes
507 // so we have to support holding a list.
508 nsTArray
<StreamListenerFunction
> mStreamListenerFunctions
;
510 nsCOMPtr
<nsIChannel
> mChannel
;
512 Maybe
<uint64_t> mDocumentChannelId
;
514 // An instance of ParentChannelListener that we use as a listener
515 // between mChannel (and any future redirected mChannels) and us.
516 // This handles service worker interception, and retargetting
517 // OnDataAvailable/OnStopRequest messages onto the listener that
519 RefPtr
<ParentChannelListener
> mParentChannelListener
;
521 // Get the channel creation URI for constructing the channel in the content
522 // process. See the function for more details.
523 nsIURI
* GetChannelCreationURI() const;
525 // The original navigation timing information containing various timestamps
526 // such as when the original load started.
527 // This will be passed back to the new content process should a process
529 RefPtr
<nsDOMNavigationTiming
> mTiming
;
531 net::EarlyHintsService mEarlyHintsService
;
533 // An optional ObjectUpgradeHandler which can be used to upgrade an <object>
534 // or <embed> element to contain a nsFrameLoader, allowing us to switch them
535 // into a different process.
537 // A weak pointer is held in order to avoid reference cycles.
538 WeakPtr
<ObjectUpgradeHandler
> mObjectUpgradeHandler
;
540 // Used to identify an internal redirect in redirect chain.
541 // True when we have seen at least one non-interal redirect.
542 bool mHaveVisibleRedirect
= false;
544 // Pending stream filter requests which should be attached when redirecting to
545 // the real channel. Moved into `TriggerRedirectToRealChannel` when the
546 // connection is ready.
547 nsTArray
<StreamFilterRequest
> mStreamFilterRequests
;
549 nsString mSrcdocData
;
550 nsCOMPtr
<nsIURI
> mBaseURI
;
552 mozilla::UniquePtr
<mozilla::dom::LoadingSessionHistoryInfo
>
553 mLoadingSessionHistoryInfo
;
555 RefPtr
<dom::WindowGlobalParent
> mParentWindowContext
;
557 // Flags from nsDocShellLoadState::LoadFlags/Type that we want to make
558 // available to the new docshell if we switch processes.
559 uint32_t mLoadStateExternalLoadFlags
= 0;
560 uint32_t mLoadStateInternalLoadFlags
= 0;
561 uint32_t mLoadStateLoadType
= 0;
563 // Indicates if this load is a download.
564 bool mIsDownload
= false;
566 // Indicates if we are loading a javascript URI.
567 bool mIsLoadingJSURI
= false;
569 // Corresponding redirect channel registrar Id for the final channel that
570 // we want to use when redirecting the child, or doing a process switch.
571 // 0 means redirection is not started.
572 uint64_t mRedirectChannelId
= 0;
573 // Set to true once we initiate the redirect to a real channel (either
574 // via a process switch or a same-process redirect, and Suspend the
575 // underlying channel.
576 bool mInitiatedRedirectToRealChannel
= false;
577 // The value of GetApplyConversion on mChannel when OnStartRequest
578 // was called. We override it to false to prevent a conversion
579 // helper from being installed, but we need to restore the value
581 bool mOldApplyConversion
= false;
582 // Set to true if any previous channel that we redirected away
583 // from had a COOP mismatch.
584 bool mHasCrossOriginOpenerPolicyMismatch
= false;
585 // Set to true if we've received OnStopRequest, and shouldn't
586 // setup a reference from the ParentChannelListener to the replacement
588 bool mIsFinished
= false;
590 // The id of the currently pending load which is
591 // passed to the childChannel in order to identify it in the new process.
592 uint64_t mLoadIdentifier
= 0;
594 Maybe
<nsCString
> mOriginalUriString
;
596 // Parent-initiated loads do not support redirects to real channels.
597 bool mSupportsRedirectToRealChannel
= true;
599 Maybe
<nsCString
> mRemoteTypeOverride
;
601 // The ContentParent which this channel is currently connected to, or nullptr
602 // if connected to the parent process.
603 RefPtr
<dom::ContentParent
> mContentParent
;
605 void RejectOpenPromise(nsresult aStatus
, nsresult aLoadGroupStatus
,
606 bool aContinueNavigating
, StaticString aLocation
) {
607 // It is possible for mOpenPromise to not be set if AsyncOpen failed and
608 // the DocumentChannel got canceled.
609 if (!mOpenPromiseResolved
&& mOpenPromise
) {
610 mOpenPromise
->Reject(OpenPromiseFailedType({aStatus
, aLoadGroupStatus
,
611 aContinueNavigating
}),
613 mOpenPromiseResolved
= true;
616 RefPtr
<OpenPromise::Private
> mOpenPromise
;
617 bool mOpenPromiseResolved
= false;
619 const bool mIsDocumentLoad
;
621 RefPtr
<HTTPSFirstDowngradeData
> mHTTPSFirstDowngradeData
;
624 NS_DEFINE_STATIC_IID_ACCESSOR(DocumentLoadListener
, DOCUMENT_LOAD_LISTENER_IID
)
626 inline nsISupports
* ToSupports(DocumentLoadListener
* aObj
) {
627 return static_cast<nsIInterfaceRequestor
*>(aObj
);
631 } // namespace mozilla
633 #endif // mozilla_net_DocumentChannelParent_h