NeckoParent.h (9583B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et tw=80 : */ 3 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/. */ 7 8 #include "mozilla/BasePrincipal.h" 9 #include "mozilla/net/PNeckoParent.h" 10 #include "mozilla/net/NeckoCommon.h" 11 #include "mozilla/MozPromise.h" 12 #include "nsIAuthPrompt2.h" 13 #include "nsNetUtil.h" 14 15 #ifndef mozilla_net_NeckoParent_h 16 # define mozilla_net_NeckoParent_h 17 18 namespace mozilla { 19 namespace net { 20 21 class RemoteStreamInfo; 22 using RemoteStreamPromise = 23 mozilla::MozPromise<RemoteStreamInfo, nsresult, false>; 24 25 // Used to override channel Private Browsing status if needed. 26 enum PBOverrideStatus { 27 kPBOverride_Unset = 0, 28 kPBOverride_Private, 29 kPBOverride_NotPrivate 30 }; 31 32 // Header file contents 33 class NeckoParent : public PNeckoParent { 34 friend class PNeckoParent; 35 36 public: 37 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NeckoParent, override) 38 39 NeckoParent(); 40 41 static void GetValidatedOriginAttributes( 42 const SerializedLoadContext& aSerialized, PContentParent* aContent, 43 nsIPrincipal* aRequestingPrincipal, mozilla::OriginAttributes& aAttrs); 44 45 /* 46 * Creates LoadContext for parent-side of an e10s channel. 47 * 48 * PContentParent corresponds to the process that is requesting the load. 49 */ 50 static void CreateChannelLoadContext(PBrowserParent* aBrowser, 51 PContentParent* aContent, 52 const SerializedLoadContext& aSerialized, 53 nsIPrincipal* aRequestingPrincipal, 54 nsCOMPtr<nsILoadContext>& aResult); 55 56 virtual void ActorDestroy(ActorDestroyReason aWhy) override; 57 PCookieServiceParent* AllocPCookieServiceParent(); 58 virtual mozilla::ipc::IPCResult RecvPCookieServiceConstructor( 59 PCookieServiceParent* aActor) override { 60 return PNeckoParent::RecvPCookieServiceConstructor(aActor); 61 } 62 63 /* 64 * Helper method to create a remote stream from a resolved file URI. 65 * Shared by PageThumbProtocolHandler and MozNewTabWallpaperProtocolHandler. 66 */ 67 static RefPtr<RemoteStreamPromise> CreateRemoteStreamForResolvedURI( 68 nsIURI* aChildURI, const nsACString& aResolvedSpec, 69 const nsACString& aDefaultMimeType); 70 71 protected: 72 virtual ~NeckoParent() = default; 73 74 bool mSocketProcessBridgeInited; 75 76 already_AddRefed<PHttpChannelParent> AllocPHttpChannelParent( 77 PBrowserParent*, const SerializedLoadContext&, 78 const HttpChannelCreationArgs& aOpenArgs); 79 virtual mozilla::ipc::IPCResult RecvPHttpChannelConstructor( 80 PHttpChannelParent* aActor, PBrowserParent* aBrowser, 81 const SerializedLoadContext& aSerialized, 82 const HttpChannelCreationArgs& aOpenArgs) override; 83 84 PStunAddrsRequestParent* AllocPStunAddrsRequestParent(); 85 bool DeallocPStunAddrsRequestParent(PStunAddrsRequestParent* aActor); 86 87 PWebrtcTCPSocketParent* AllocPWebrtcTCPSocketParent( 88 const Maybe<TabId>& aTabId); 89 bool DeallocPWebrtcTCPSocketParent(PWebrtcTCPSocketParent* aActor); 90 91 PCacheEntryWriteHandleParent* AllocPCacheEntryWriteHandleParent( 92 PHttpChannelParent* channel); 93 bool DeallocPCacheEntryWriteHandleParent( 94 PCacheEntryWriteHandleParent* aActor); 95 96 PAltDataOutputStreamParent* AllocPAltDataOutputStreamParent( 97 const nsACString& type, const int64_t& predictedSize, 98 mozilla::Maybe<mozilla::NotNull<mozilla::net::PHttpChannelParent*>>& 99 channel, 100 mozilla::Maybe<mozilla::NotNull<PCacheEntryWriteHandleParent*>>& handle); 101 bool DeallocPAltDataOutputStreamParent(PAltDataOutputStreamParent* aActor); 102 103 bool DeallocPCookieServiceParent(PCookieServiceParent*); 104 PWebSocketParent* AllocPWebSocketParent( 105 PBrowserParent* browser, const SerializedLoadContext& aSerialized, 106 const uint32_t& aSerial); 107 bool DeallocPWebSocketParent(PWebSocketParent*); 108 PTCPSocketParent* AllocPTCPSocketParent(const nsAString& host, 109 const uint16_t& port); 110 111 already_AddRefed<PDocumentChannelParent> AllocPDocumentChannelParent( 112 const dom::MaybeDiscarded<dom::BrowsingContext>& aContext, 113 const DocumentChannelCreationArgs& args); 114 virtual mozilla::ipc::IPCResult RecvPDocumentChannelConstructor( 115 PDocumentChannelParent* aActor, 116 const dom::MaybeDiscarded<dom::BrowsingContext>& aContext, 117 const DocumentChannelCreationArgs& aArgs) override; 118 bool DeallocPDocumentChannelParent(PDocumentChannelParent* channel); 119 120 bool DeallocPTCPSocketParent(PTCPSocketParent*); 121 PTCPServerSocketParent* AllocPTCPServerSocketParent( 122 const uint16_t& aLocalPort, const uint16_t& aBacklog, 123 const bool& aUseArrayBuffers); 124 virtual mozilla::ipc::IPCResult RecvPTCPServerSocketConstructor( 125 PTCPServerSocketParent*, const uint16_t& aLocalPort, 126 const uint16_t& aBacklog, const bool& aUseArrayBuffers) override; 127 bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*); 128 PUDPSocketParent* AllocPUDPSocketParent(nsIPrincipal* aPrincipal, 129 const nsACString& aFilter); 130 virtual mozilla::ipc::IPCResult RecvPUDPSocketConstructor( 131 PUDPSocketParent*, nsIPrincipal* aPrincipal, 132 const nsACString& aFilter) override; 133 bool DeallocPUDPSocketParent(PUDPSocketParent*); 134 already_AddRefed<PDNSRequestParent> AllocPDNSRequestParent( 135 const nsACString& aHost, const nsACString& aTrrServer, 136 const int32_t& aPort, const uint16_t& aType, 137 const OriginAttributes& aOriginAttributes, 138 const nsIDNSService::DNSFlags& aFlags); 139 virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor( 140 PDNSRequestParent* actor, const nsACString& aHost, 141 const nsACString& trrServer, const int32_t& aPort, const uint16_t& type, 142 const OriginAttributes& aOriginAttributes, 143 const nsIDNSService::DNSFlags& flags) override; 144 mozilla::ipc::IPCResult RecvSpeculativeConnect( 145 nsIURI* aURI, nsIPrincipal* aPrincipal, 146 Maybe<OriginAttributes>&& aOriginAttributes, const bool& aAnonymous); 147 mozilla::ipc::IPCResult RecvHTMLDNSPrefetch( 148 const nsAString& hostname, const bool& isHttps, 149 const OriginAttributes& aOriginAttributes, 150 const nsIDNSService::DNSFlags& flags); 151 mozilla::ipc::IPCResult RecvCancelHTMLDNSPrefetch( 152 const nsAString& hostname, const bool& isHttps, 153 const OriginAttributes& aOriginAttributes, 154 const nsIDNSService::DNSFlags& flags, const nsresult& reason); 155 PWebSocketEventListenerParent* AllocPWebSocketEventListenerParent( 156 const uint64_t& aInnerWindowID); 157 bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*); 158 159 mozilla::ipc::IPCResult RecvConnectBaseChannel(const uint32_t& channelId); 160 161 # ifdef MOZ_WIDGET_GTK 162 PGIOChannelParent* AllocPGIOChannelParent( 163 PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, 164 const GIOChannelCreationArgs& aOpenArgs); 165 bool DeallocPGIOChannelParent(PGIOChannelParent* channel); 166 167 virtual mozilla::ipc::IPCResult RecvPGIOChannelConstructor( 168 PGIOChannelParent* aActor, PBrowserParent* aBrowser, 169 const SerializedLoadContext& aSerialized, 170 const GIOChannelCreationArgs& aOpenArgs) override; 171 # endif 172 # ifdef MOZ_WIDGET_ANDROID 173 already_AddRefed<PGeckoViewContentChannelParent> 174 AllocPGeckoViewContentChannelParent( 175 PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, 176 const GeckoViewContentChannelArgs& aOpenArgs); 177 178 virtual mozilla::ipc::IPCResult RecvPGeckoViewContentChannelConstructor( 179 PGeckoViewContentChannelParent* aActor, PBrowserParent* aBrowser, 180 const SerializedLoadContext& aSerialized, 181 const GeckoViewContentChannelArgs& args) override; 182 # endif 183 184 mozilla::ipc::IPCResult RecvNotifyFileChannelOpened( 185 const FileChannelInfo& aInfo); 186 187 PTransportProviderParent* AllocPTransportProviderParent(); 188 bool DeallocPTransportProviderParent(PTransportProviderParent* aActor); 189 190 mozilla::ipc::IPCResult RecvRequestContextLoadBegin(const uint64_t& rcid); 191 mozilla::ipc::IPCResult RecvRequestContextAfterDOMContentLoaded( 192 const uint64_t& rcid); 193 mozilla::ipc::IPCResult RecvRemoveRequestContext(const uint64_t& rcid); 194 195 /* WebExtensions */ 196 mozilla::ipc::IPCResult RecvGetExtensionStream( 197 nsIURI* aURI, GetExtensionStreamResolver&& aResolve); 198 199 mozilla::ipc::IPCResult RecvGetExtensionFD(nsIURI* aURI, 200 GetExtensionFDResolver&& aResolve); 201 202 /* Page thumbnails remote resource loading */ 203 mozilla::ipc::IPCResult RecvGetPageThumbStream( 204 nsIURI* aURI, const LoadInfoArgs& aLoadInfoArgs, 205 GetPageThumbStreamResolver&& aResolve); 206 207 /* Page icon remote resource loading */ 208 mozilla::ipc::IPCResult RecvGetPageIconStream( 209 nsIURI* aURI, const LoadInfoArgs& aLoadInfoArgs, 210 GetPageIconStreamResolver&& aResolve); 211 212 /* New Tab wallpaper remote resource loading */ 213 mozilla::ipc::IPCResult RecvGetMozNewTabWallpaperStream( 214 nsIURI* aURI, const LoadInfoArgs& aLoadInfoArgs, 215 GetMozNewTabWallpaperStreamResolver&& aResolve); 216 217 mozilla::ipc::IPCResult RecvInitSocketProcessBridge( 218 InitSocketProcessBridgeResolver&& aResolver); 219 mozilla::ipc::IPCResult RecvResetSocketProcessBridge(); 220 221 mozilla::ipc::IPCResult RecvEnsureHSTSData( 222 EnsureHSTSDataResolver&& aResolver); 223 }; 224 225 } // namespace net 226 } // namespace mozilla 227 228 #endif // mozilla_net_NeckoParent_h