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 #include "mozilla/BasePrincipal.h"
9 #include "mozilla/net/PNeckoParent.h"
10 #include "mozilla/net/NeckoCommon.h"
11 #include "nsIAuthPrompt2.h"
12 #include "nsINetworkPredictor.h"
13 #include "nsNetUtil.h"
15 #ifndef mozilla_net_NeckoParent_h
16 # define mozilla_net_NeckoParent_h
21 // Used to override channel Private Browsing status if needed.
22 enum PBOverrideStatus
{
23 kPBOverride_Unset
= 0,
25 kPBOverride_NotPrivate
28 // Header file contents
29 class NeckoParent
: public PNeckoParent
{
30 friend class PNeckoParent
;
33 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NeckoParent
, override
)
37 [[nodiscard
]] static const char* GetValidatedOriginAttributes(
38 const SerializedLoadContext
& aSerialized
, PContentParent
* aBrowser
,
39 nsIPrincipal
* aRequestingPrincipal
, mozilla::OriginAttributes
& aAttrs
);
42 * Creates LoadContext for parent-side of an e10s channel.
44 * PContentParent corresponds to the process that is requesting the load.
46 * Returns null if successful, or an error string if failed.
48 [[nodiscard
]] static const char* CreateChannelLoadContext(
49 PBrowserParent
* aBrowser
, PContentParent
* aContent
,
50 const SerializedLoadContext
& aSerialized
,
51 nsIPrincipal
* aRequestingPrincipal
, nsCOMPtr
<nsILoadContext
>& aResult
);
53 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
54 PCookieServiceParent
* AllocPCookieServiceParent();
55 virtual mozilla::ipc::IPCResult
RecvPCookieServiceConstructor(
56 PCookieServiceParent
* aActor
) override
{
57 return PNeckoParent::RecvPCookieServiceConstructor(aActor
);
61 virtual ~NeckoParent() = default;
63 bool mSocketProcessBridgeInited
;
65 already_AddRefed
<PHttpChannelParent
> AllocPHttpChannelParent(
66 PBrowserParent
*, const SerializedLoadContext
&,
67 const HttpChannelCreationArgs
& aOpenArgs
);
68 virtual mozilla::ipc::IPCResult
RecvPHttpChannelConstructor(
69 PHttpChannelParent
* aActor
, PBrowserParent
* aBrowser
,
70 const SerializedLoadContext
& aSerialized
,
71 const HttpChannelCreationArgs
& aOpenArgs
) override
;
73 PStunAddrsRequestParent
* AllocPStunAddrsRequestParent();
74 bool DeallocPStunAddrsRequestParent(PStunAddrsRequestParent
* aActor
);
76 PWebrtcTCPSocketParent
* AllocPWebrtcTCPSocketParent(
77 const Maybe
<TabId
>& aTabId
);
78 bool DeallocPWebrtcTCPSocketParent(PWebrtcTCPSocketParent
* aActor
);
80 PAltDataOutputStreamParent
* AllocPAltDataOutputStreamParent(
81 const nsACString
& type
, const int64_t& predictedSize
,
82 PHttpChannelParent
* channel
);
83 bool DeallocPAltDataOutputStreamParent(PAltDataOutputStreamParent
* aActor
);
85 bool DeallocPCookieServiceParent(PCookieServiceParent
*);
86 PWebSocketParent
* AllocPWebSocketParent(
87 PBrowserParent
* browser
, const SerializedLoadContext
& aSerialized
,
88 const uint32_t& aSerial
);
89 bool DeallocPWebSocketParent(PWebSocketParent
*);
90 PTCPSocketParent
* AllocPTCPSocketParent(const nsAString
& host
,
91 const uint16_t& port
);
93 already_AddRefed
<PDocumentChannelParent
> AllocPDocumentChannelParent(
94 const dom::MaybeDiscarded
<dom::BrowsingContext
>& aContext
,
95 const DocumentChannelCreationArgs
& args
);
96 virtual mozilla::ipc::IPCResult
RecvPDocumentChannelConstructor(
97 PDocumentChannelParent
* aActor
,
98 const dom::MaybeDiscarded
<dom::BrowsingContext
>& aContext
,
99 const DocumentChannelCreationArgs
& aArgs
) override
;
100 bool DeallocPDocumentChannelParent(PDocumentChannelParent
* channel
);
102 bool DeallocPTCPSocketParent(PTCPSocketParent
*);
103 PTCPServerSocketParent
* AllocPTCPServerSocketParent(
104 const uint16_t& aLocalPort
, const uint16_t& aBacklog
,
105 const bool& aUseArrayBuffers
);
106 virtual mozilla::ipc::IPCResult
RecvPTCPServerSocketConstructor(
107 PTCPServerSocketParent
*, const uint16_t& aLocalPort
,
108 const uint16_t& aBacklog
, const bool& aUseArrayBuffers
) override
;
109 bool DeallocPTCPServerSocketParent(PTCPServerSocketParent
*);
110 PUDPSocketParent
* AllocPUDPSocketParent(nsIPrincipal
* aPrincipal
,
111 const nsACString
& aFilter
);
112 virtual mozilla::ipc::IPCResult
RecvPUDPSocketConstructor(
113 PUDPSocketParent
*, nsIPrincipal
* aPrincipal
,
114 const nsACString
& aFilter
) override
;
115 bool DeallocPUDPSocketParent(PUDPSocketParent
*);
116 already_AddRefed
<PDNSRequestParent
> AllocPDNSRequestParent(
117 const nsACString
& aHost
, const nsACString
& aTrrServer
,
118 const int32_t& aPort
, const uint16_t& aType
,
119 const OriginAttributes
& aOriginAttributes
,
120 const nsIDNSService::DNSFlags
& aFlags
);
121 virtual mozilla::ipc::IPCResult
RecvPDNSRequestConstructor(
122 PDNSRequestParent
* actor
, const nsACString
& aHost
,
123 const nsACString
& trrServer
, const int32_t& aPort
, const uint16_t& type
,
124 const OriginAttributes
& aOriginAttributes
,
125 const nsIDNSService::DNSFlags
& flags
) override
;
126 mozilla::ipc::IPCResult
RecvSpeculativeConnect(
127 nsIURI
* aURI
, nsIPrincipal
* aPrincipal
,
128 Maybe
<OriginAttributes
>&& aOriginAttributes
, const bool& aAnonymous
);
129 mozilla::ipc::IPCResult
RecvHTMLDNSPrefetch(
130 const nsAString
& hostname
, const bool& isHttps
,
131 const OriginAttributes
& aOriginAttributes
,
132 const nsIDNSService::DNSFlags
& flags
);
133 mozilla::ipc::IPCResult
RecvCancelHTMLDNSPrefetch(
134 const nsAString
& hostname
, const bool& isHttps
,
135 const OriginAttributes
& aOriginAttributes
,
136 const nsIDNSService::DNSFlags
& flags
, const nsresult
& reason
);
137 PWebSocketEventListenerParent
* AllocPWebSocketEventListenerParent(
138 const uint64_t& aInnerWindowID
);
139 bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent
*);
141 already_AddRefed
<PDataChannelParent
> AllocPDataChannelParent(
142 const uint32_t& channelId
);
144 virtual mozilla::ipc::IPCResult
RecvPDataChannelConstructor(
145 PDataChannelParent
* aActor
, const uint32_t& channelId
) override
;
146 # ifdef MOZ_WIDGET_GTK
147 PGIOChannelParent
* AllocPGIOChannelParent(
148 PBrowserParent
* aBrowser
, const SerializedLoadContext
& aSerialized
,
149 const GIOChannelCreationArgs
& aOpenArgs
);
150 bool DeallocPGIOChannelParent(PGIOChannelParent
* channel
);
152 virtual mozilla::ipc::IPCResult
RecvPGIOChannelConstructor(
153 PGIOChannelParent
* aActor
, PBrowserParent
* aBrowser
,
154 const SerializedLoadContext
& aSerialized
,
155 const GIOChannelCreationArgs
& aOpenArgs
) override
;
157 PSimpleChannelParent
* AllocPSimpleChannelParent(const uint32_t& channelId
);
158 bool DeallocPSimpleChannelParent(PSimpleChannelParent
* actor
);
160 virtual mozilla::ipc::IPCResult
RecvPSimpleChannelConstructor(
161 PSimpleChannelParent
* aActor
, const uint32_t& channelId
) override
;
163 already_AddRefed
<PFileChannelParent
> AllocPFileChannelParent(
164 const uint32_t& channelId
);
166 virtual mozilla::ipc::IPCResult
RecvPFileChannelConstructor(
167 PFileChannelParent
* aActor
, const uint32_t& channelId
) override
;
169 PTransportProviderParent
* AllocPTransportProviderParent();
170 bool DeallocPTransportProviderParent(PTransportProviderParent
* aActor
);
172 /* Predictor Messages */
173 mozilla::ipc::IPCResult
RecvPredPredict(
174 nsIURI
* aTargetURI
, nsIURI
* aSourceURI
,
175 const PredictorPredictReason
& aReason
,
176 const OriginAttributes
& aOriginAttributes
, const bool& hasVerifier
);
178 mozilla::ipc::IPCResult
RecvPredLearn(
179 nsIURI
* aTargetURI
, nsIURI
* aSourceURI
,
180 const PredictorPredictReason
& aReason
,
181 const OriginAttributes
& aOriginAttributes
);
182 mozilla::ipc::IPCResult
RecvPredReset();
184 mozilla::ipc::IPCResult
RecvRequestContextLoadBegin(const uint64_t& rcid
);
185 mozilla::ipc::IPCResult
RecvRequestContextAfterDOMContentLoaded(
186 const uint64_t& rcid
);
187 mozilla::ipc::IPCResult
RecvRemoveRequestContext(const uint64_t& rcid
);
190 mozilla::ipc::IPCResult
RecvGetExtensionStream(
191 nsIURI
* aURI
, GetExtensionStreamResolver
&& aResolve
);
193 mozilla::ipc::IPCResult
RecvGetExtensionFD(nsIURI
* aURI
,
194 GetExtensionFDResolver
&& aResolve
);
196 /* Page thumbnails remote resource loading */
197 mozilla::ipc::IPCResult
RecvGetPageThumbStream(
198 nsIURI
* aURI
, const LoadInfoArgs
& aLoadInfoArgs
,
199 GetPageThumbStreamResolver
&& aResolve
);
201 /* Page icon remote resource loading */
202 mozilla::ipc::IPCResult
RecvGetPageIconStream(
203 nsIURI
* aURI
, const LoadInfoArgs
& aLoadInfoArgs
,
204 GetPageIconStreamResolver
&& aResolve
);
206 mozilla::ipc::IPCResult
RecvInitSocketProcessBridge(
207 InitSocketProcessBridgeResolver
&& aResolver
);
208 mozilla::ipc::IPCResult
RecvResetSocketProcessBridge();
210 mozilla::ipc::IPCResult
RecvEnsureHSTSData(
211 EnsureHSTSDataResolver
&& aResolver
);
215 } // namespace mozilla
217 #endif // mozilla_net_NeckoParent_h