1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef mozilla_net_DocumentChannel_h
9 #define mozilla_net_DocumentChannel_h
11 #include "mozilla/dom/ClientInfo.h"
12 #include "mozilla/net/NeckoChannelParams.h"
13 #include "nsDOMNavigationTiming.h"
14 #include "nsIChannel.h"
15 #include "nsIChildChannel.h"
19 #define DOCUMENT_CHANNEL_IID \
21 0x6977bc44, 0xb1db, 0x41b7, { \
22 0xb5, 0xc5, 0xe2, 0x13, 0x68, 0x22, 0xc9, 0x8f \
29 uint64_t InnerWindowIDForExtantDoc(nsDocShell
* docShell
);
32 * DocumentChannel is a protocol agnostic placeholder nsIChannel implementation
33 * that we use so that nsDocShell knows about a connecting load. It transfers
34 * all data into a DocumentLoadListener (running in the parent process), which
35 * will create the real channel for the connection, and decide which process to
36 * load the resulting document in. If the document is to be loaded in the
37 * current process, then we'll synthesize a redirect replacing this placeholder
38 * channel with the real one, otherwise the originating docshell will be removed
39 * during the process switch.
41 class DocumentChannel
: public nsIIdentChannel
{
46 NS_DECL_NSIIDENTCHANNEL
48 NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_CHANNEL_IID
)
50 void SetNavigationTiming(nsDOMNavigationTiming
* aTiming
) {
54 void SetInitialClientInfo(const Maybe
<dom::ClientInfo
>& aInfo
) {
55 mInitialClientInfo
= aInfo
;
58 void DisconnectChildListeners(const nsresult
& aStatus
,
59 const nsresult
& aLoadGroupStatus
);
62 * Will create the appropriate document channel:
63 * Either a DocumentChannelChild if called from the content process or
64 * a ParentProcessDocumentChannel if called from the parent process.
65 * This operation is infallible.
67 static already_AddRefed
<DocumentChannel
> CreateForDocument(
68 nsDocShellLoadState
* aLoadState
, class LoadInfo
* aLoadInfo
,
69 nsLoadFlags aLoadFlags
, nsIInterfaceRequestor
* aNotificationCallbacks
,
70 uint32_t aCacheKey
, bool aUriModified
, bool aIsEmbeddingBlockedError
);
71 static already_AddRefed
<DocumentChannel
> CreateForObject(
72 nsDocShellLoadState
* aLoadState
, class LoadInfo
* aLoadInfo
,
73 nsLoadFlags aLoadFlags
, nsIInterfaceRequestor
* aNotificationCallbacks
);
75 static bool CanUseDocumentChannel(nsIURI
* aURI
);
78 DocumentChannel(nsDocShellLoadState
* aLoadState
, class LoadInfo
* aLoadInfo
,
79 nsLoadFlags aLoadFlags
, uint32_t aCacheKey
, bool aUriModified
,
80 bool aIsEmbeddingBlockedError
);
82 void ShutdownListeners(nsresult aStatusCode
);
83 virtual void DeleteIPDL() {}
85 nsDocShell
* GetDocShell();
87 virtual ~DocumentChannel() = default;
89 const RefPtr
<nsDocShellLoadState
> mLoadState
;
90 const uint32_t mCacheKey
;
92 nsresult mStatus
= NS_OK
;
93 bool mCanceled
= false;
94 bool mIsPending
= false;
95 bool mWasOpened
= false;
97 uint32_t mLoadFlags
= LOAD_NORMAL
;
98 const nsCOMPtr
<nsIURI
> mURI
;
99 nsCOMPtr
<nsILoadGroup
> mLoadGroup
;
100 nsCOMPtr
<nsILoadInfo
> mLoadInfo
;
101 nsCOMPtr
<nsIInterfaceRequestor
> mCallbacks
;
102 nsCOMPtr
<nsIStreamListener
> mListener
;
103 nsCOMPtr
<nsISupports
> mOwner
;
104 RefPtr
<nsDOMNavigationTiming
> mTiming
;
105 Maybe
<dom::ClientInfo
> mInitialClientInfo
;
106 // mUriModified is true if we're doing a history load and the URI of the
107 // session history had been modified by pushState/replaceState.
108 bool mUriModified
= false;
109 // mIsEmbeddingBlockedError is true if we're handling a load error and the
110 // status of the failed channel is NS_ERROR_XFO_VIOLATION or
111 // NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION.
112 bool mIsEmbeddingBlockedError
= false;
115 NS_DEFINE_STATIC_IID_ACCESSOR(DocumentChannel
, DOCUMENT_CHANNEL_IID
)
118 } // namespace mozilla
120 #endif // mozilla_net_DocumentChannel_h