Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | |
michael@0 | 2 | /* vim: set sw=2 ts=8 et tw=80 : */ |
michael@0 | 3 | |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "necko-config.h" |
michael@0 | 9 | #include "nsHttp.h" |
michael@0 | 10 | #include "mozilla/net/NeckoChild.h" |
michael@0 | 11 | #include "mozilla/dom/ContentChild.h" |
michael@0 | 12 | #include "mozilla/net/HttpChannelChild.h" |
michael@0 | 13 | #include "mozilla/net/CookieServiceChild.h" |
michael@0 | 14 | #include "mozilla/net/WyciwygChannelChild.h" |
michael@0 | 15 | #include "mozilla/net/FTPChannelChild.h" |
michael@0 | 16 | #include "mozilla/net/WebSocketChannelChild.h" |
michael@0 | 17 | #include "mozilla/net/DNSRequestChild.h" |
michael@0 | 18 | #include "mozilla/net/RemoteOpenFileChild.h" |
michael@0 | 19 | #include "mozilla/net/ChannelDiverterChild.h" |
michael@0 | 20 | #include "mozilla/dom/network/TCPSocketChild.h" |
michael@0 | 21 | #include "mozilla/dom/network/TCPServerSocketChild.h" |
michael@0 | 22 | #include "mozilla/dom/network/UDPSocketChild.h" |
michael@0 | 23 | #ifdef NECKO_PROTOCOL_rtsp |
michael@0 | 24 | #include "mozilla/net/RtspControllerChild.h" |
michael@0 | 25 | #include "mozilla/net/RtspChannelChild.h" |
michael@0 | 26 | #endif |
michael@0 | 27 | #include "SerializedLoadContext.h" |
michael@0 | 28 | |
michael@0 | 29 | using mozilla::dom::TCPSocketChild; |
michael@0 | 30 | using mozilla::dom::TCPServerSocketChild; |
michael@0 | 31 | using mozilla::dom::UDPSocketChild; |
michael@0 | 32 | |
michael@0 | 33 | namespace mozilla { |
michael@0 | 34 | namespace net { |
michael@0 | 35 | |
michael@0 | 36 | PNeckoChild *gNeckoChild = nullptr; |
michael@0 | 37 | |
michael@0 | 38 | // C++ file contents |
michael@0 | 39 | NeckoChild::NeckoChild() |
michael@0 | 40 | { |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | NeckoChild::~NeckoChild() |
michael@0 | 44 | { |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | void NeckoChild::InitNeckoChild() |
michael@0 | 48 | { |
michael@0 | 49 | NS_ABORT_IF_FALSE(IsNeckoChild(), "InitNeckoChild called by non-child!"); |
michael@0 | 50 | |
michael@0 | 51 | if (!gNeckoChild) { |
michael@0 | 52 | mozilla::dom::ContentChild * cpc = |
michael@0 | 53 | mozilla::dom::ContentChild::GetSingleton(); |
michael@0 | 54 | NS_ASSERTION(cpc, "Content Protocol is NULL!"); |
michael@0 | 55 | gNeckoChild = cpc->SendPNeckoConstructor(); |
michael@0 | 56 | NS_ASSERTION(gNeckoChild, "PNecko Protocol init failed!"); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | // Note: not actually called; has some lifespan as child process, so |
michael@0 | 61 | // automatically destroyed at exit. |
michael@0 | 62 | void NeckoChild::DestroyNeckoChild() |
michael@0 | 63 | { |
michael@0 | 64 | NS_ABORT_IF_FALSE(IsNeckoChild(), "DestroyNeckoChild called by non-child!"); |
michael@0 | 65 | static bool alreadyDestroyed = false; |
michael@0 | 66 | NS_ABORT_IF_FALSE(!alreadyDestroyed, "DestroyNeckoChild already called!"); |
michael@0 | 67 | |
michael@0 | 68 | if (!alreadyDestroyed) { |
michael@0 | 69 | Send__delete__(gNeckoChild); |
michael@0 | 70 | gNeckoChild = nullptr; |
michael@0 | 71 | alreadyDestroyed = true; |
michael@0 | 72 | } |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | PHttpChannelChild* |
michael@0 | 76 | NeckoChild::AllocPHttpChannelChild(PBrowserChild* browser, |
michael@0 | 77 | const SerializedLoadContext& loadContext, |
michael@0 | 78 | const HttpChannelCreationArgs& aOpenArgs) |
michael@0 | 79 | { |
michael@0 | 80 | // We don't allocate here: instead we always use IPDL constructor that takes |
michael@0 | 81 | // an existing HttpChildChannel |
michael@0 | 82 | NS_NOTREACHED("AllocPHttpChannelChild should not be called on child"); |
michael@0 | 83 | return nullptr; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | bool |
michael@0 | 87 | NeckoChild::DeallocPHttpChannelChild(PHttpChannelChild* channel) |
michael@0 | 88 | { |
michael@0 | 89 | NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPHttpChannelChild called by non-child!"); |
michael@0 | 90 | |
michael@0 | 91 | HttpChannelChild* child = static_cast<HttpChannelChild*>(channel); |
michael@0 | 92 | child->ReleaseIPDLReference(); |
michael@0 | 93 | return true; |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | PFTPChannelChild* |
michael@0 | 97 | NeckoChild::AllocPFTPChannelChild(PBrowserChild* aBrowser, |
michael@0 | 98 | const SerializedLoadContext& aSerialized, |
michael@0 | 99 | const FTPChannelCreationArgs& aOpenArgs) |
michael@0 | 100 | { |
michael@0 | 101 | // We don't allocate here: see FTPChannelChild::AsyncOpen() |
michael@0 | 102 | NS_RUNTIMEABORT("AllocPFTPChannelChild should not be called"); |
michael@0 | 103 | return nullptr; |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | bool |
michael@0 | 107 | NeckoChild::DeallocPFTPChannelChild(PFTPChannelChild* channel) |
michael@0 | 108 | { |
michael@0 | 109 | NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPFTPChannelChild called by non-child!"); |
michael@0 | 110 | |
michael@0 | 111 | FTPChannelChild* child = static_cast<FTPChannelChild*>(channel); |
michael@0 | 112 | child->ReleaseIPDLReference(); |
michael@0 | 113 | return true; |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | PCookieServiceChild* |
michael@0 | 117 | NeckoChild::AllocPCookieServiceChild() |
michael@0 | 118 | { |
michael@0 | 119 | // We don't allocate here: see nsCookieService::GetSingleton() |
michael@0 | 120 | NS_NOTREACHED("AllocPCookieServiceChild should not be called"); |
michael@0 | 121 | return nullptr; |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | bool |
michael@0 | 125 | NeckoChild::DeallocPCookieServiceChild(PCookieServiceChild* cs) |
michael@0 | 126 | { |
michael@0 | 127 | NS_ASSERTION(IsNeckoChild(), "DeallocPCookieServiceChild called by non-child!"); |
michael@0 | 128 | |
michael@0 | 129 | CookieServiceChild *p = static_cast<CookieServiceChild*>(cs); |
michael@0 | 130 | p->Release(); |
michael@0 | 131 | return true; |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | PWyciwygChannelChild* |
michael@0 | 135 | NeckoChild::AllocPWyciwygChannelChild() |
michael@0 | 136 | { |
michael@0 | 137 | WyciwygChannelChild *p = new WyciwygChannelChild(); |
michael@0 | 138 | p->AddIPDLReference(); |
michael@0 | 139 | return p; |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | bool |
michael@0 | 143 | NeckoChild::DeallocPWyciwygChannelChild(PWyciwygChannelChild* channel) |
michael@0 | 144 | { |
michael@0 | 145 | NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPWyciwygChannelChild called by non-child!"); |
michael@0 | 146 | |
michael@0 | 147 | WyciwygChannelChild *p = static_cast<WyciwygChannelChild*>(channel); |
michael@0 | 148 | p->ReleaseIPDLReference(); |
michael@0 | 149 | return true; |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | PWebSocketChild* |
michael@0 | 153 | NeckoChild::AllocPWebSocketChild(PBrowserChild* browser, |
michael@0 | 154 | const SerializedLoadContext& aSerialized) |
michael@0 | 155 | { |
michael@0 | 156 | NS_NOTREACHED("AllocPWebSocketChild should not be called"); |
michael@0 | 157 | return nullptr; |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | bool |
michael@0 | 161 | NeckoChild::DeallocPWebSocketChild(PWebSocketChild* child) |
michael@0 | 162 | { |
michael@0 | 163 | WebSocketChannelChild* p = static_cast<WebSocketChannelChild*>(child); |
michael@0 | 164 | p->ReleaseIPDLReference(); |
michael@0 | 165 | return true; |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | PRtspControllerChild* |
michael@0 | 169 | NeckoChild::AllocPRtspControllerChild() |
michael@0 | 170 | { |
michael@0 | 171 | NS_NOTREACHED("AllocPRtspController should not be called"); |
michael@0 | 172 | return nullptr; |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | bool |
michael@0 | 176 | NeckoChild::DeallocPRtspControllerChild(PRtspControllerChild* child) |
michael@0 | 177 | { |
michael@0 | 178 | #ifdef NECKO_PROTOCOL_rtsp |
michael@0 | 179 | RtspControllerChild* p = static_cast<RtspControllerChild*>(child); |
michael@0 | 180 | p->ReleaseIPDLReference(); |
michael@0 | 181 | #endif |
michael@0 | 182 | return true; |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | PRtspChannelChild* |
michael@0 | 186 | NeckoChild::AllocPRtspChannelChild(const RtspChannelConnectArgs& aArgs) |
michael@0 | 187 | { |
michael@0 | 188 | NS_NOTREACHED("AllocPRtspController should not be called"); |
michael@0 | 189 | return nullptr; |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | bool |
michael@0 | 193 | NeckoChild::DeallocPRtspChannelChild(PRtspChannelChild* child) |
michael@0 | 194 | { |
michael@0 | 195 | #ifdef NECKO_PROTOCOL_rtsp |
michael@0 | 196 | RtspChannelChild* p = static_cast<RtspChannelChild*>(child); |
michael@0 | 197 | p->ReleaseIPDLReference(); |
michael@0 | 198 | #endif |
michael@0 | 199 | return true; |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | PTCPSocketChild* |
michael@0 | 203 | NeckoChild::AllocPTCPSocketChild() |
michael@0 | 204 | { |
michael@0 | 205 | TCPSocketChild* p = new TCPSocketChild(); |
michael@0 | 206 | p->AddIPDLReference(); |
michael@0 | 207 | return p; |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | bool |
michael@0 | 211 | NeckoChild::DeallocPTCPSocketChild(PTCPSocketChild* child) |
michael@0 | 212 | { |
michael@0 | 213 | TCPSocketChild* p = static_cast<TCPSocketChild*>(child); |
michael@0 | 214 | p->ReleaseIPDLReference(); |
michael@0 | 215 | return true; |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | PTCPServerSocketChild* |
michael@0 | 219 | NeckoChild::AllocPTCPServerSocketChild(const uint16_t& aLocalPort, |
michael@0 | 220 | const uint16_t& aBacklog, |
michael@0 | 221 | const nsString& aBinaryType) |
michael@0 | 222 | { |
michael@0 | 223 | NS_NOTREACHED("AllocPTCPServerSocket should not be called"); |
michael@0 | 224 | return nullptr; |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | bool |
michael@0 | 228 | NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child) |
michael@0 | 229 | { |
michael@0 | 230 | TCPServerSocketChild* p = static_cast<TCPServerSocketChild*>(child); |
michael@0 | 231 | p->ReleaseIPDLReference(); |
michael@0 | 232 | return true; |
michael@0 | 233 | } |
michael@0 | 234 | |
michael@0 | 235 | PUDPSocketChild* |
michael@0 | 236 | NeckoChild::AllocPUDPSocketChild(const nsCString& aHost, |
michael@0 | 237 | const uint16_t& aPort, |
michael@0 | 238 | const nsCString& aFilter) |
michael@0 | 239 | { |
michael@0 | 240 | NS_NOTREACHED("AllocPUDPSocket should not be called"); |
michael@0 | 241 | return nullptr; |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | bool |
michael@0 | 245 | NeckoChild::DeallocPUDPSocketChild(PUDPSocketChild* child) |
michael@0 | 246 | { |
michael@0 | 247 | |
michael@0 | 248 | UDPSocketChild* p = static_cast<UDPSocketChild*>(child); |
michael@0 | 249 | p->ReleaseIPDLReference(); |
michael@0 | 250 | return true; |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | PDNSRequestChild* |
michael@0 | 254 | NeckoChild::AllocPDNSRequestChild(const nsCString& aHost, |
michael@0 | 255 | const uint32_t& aFlags) |
michael@0 | 256 | { |
michael@0 | 257 | // We don't allocate here: instead we always use IPDL constructor that takes |
michael@0 | 258 | // an existing object |
michael@0 | 259 | NS_NOTREACHED("AllocPDNSRequestChild should not be called on child"); |
michael@0 | 260 | return nullptr; |
michael@0 | 261 | } |
michael@0 | 262 | |
michael@0 | 263 | bool |
michael@0 | 264 | NeckoChild::DeallocPDNSRequestChild(PDNSRequestChild* aChild) |
michael@0 | 265 | { |
michael@0 | 266 | DNSRequestChild *p = static_cast<DNSRequestChild*>(aChild); |
michael@0 | 267 | p->ReleaseIPDLReference(); |
michael@0 | 268 | return true; |
michael@0 | 269 | } |
michael@0 | 270 | |
michael@0 | 271 | PRemoteOpenFileChild* |
michael@0 | 272 | NeckoChild::AllocPRemoteOpenFileChild(const URIParams&, const OptionalURIParams&) |
michael@0 | 273 | { |
michael@0 | 274 | // We don't allocate here: instead we always use IPDL constructor that takes |
michael@0 | 275 | // an existing RemoteOpenFileChild |
michael@0 | 276 | NS_NOTREACHED("AllocPRemoteOpenFileChild should not be called on child"); |
michael@0 | 277 | return nullptr; |
michael@0 | 278 | } |
michael@0 | 279 | |
michael@0 | 280 | bool |
michael@0 | 281 | NeckoChild::DeallocPRemoteOpenFileChild(PRemoteOpenFileChild* aChild) |
michael@0 | 282 | { |
michael@0 | 283 | RemoteOpenFileChild *p = static_cast<RemoteOpenFileChild*>(aChild); |
michael@0 | 284 | p->ReleaseIPDLReference(); |
michael@0 | 285 | return true; |
michael@0 | 286 | } |
michael@0 | 287 | |
michael@0 | 288 | PChannelDiverterChild* |
michael@0 | 289 | NeckoChild::AllocPChannelDiverterChild(const ChannelDiverterArgs& channel) |
michael@0 | 290 | { |
michael@0 | 291 | return new ChannelDiverterChild();; |
michael@0 | 292 | } |
michael@0 | 293 | |
michael@0 | 294 | bool |
michael@0 | 295 | NeckoChild::DeallocPChannelDiverterChild(PChannelDiverterChild* child) |
michael@0 | 296 | { |
michael@0 | 297 | delete static_cast<ChannelDiverterChild*>(child); |
michael@0 | 298 | return true; |
michael@0 | 299 | } |
michael@0 | 300 | |
michael@0 | 301 | }} // mozilla::net |
michael@0 | 302 |