|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
Packit |
f0b94e |
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
Packit |
f0b94e |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#include "necko-config.h"
|
|
Packit |
f0b94e |
#include "nsHttp.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/NeckoChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/ContentChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/TabChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/HttpChannelChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/CookieServiceChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/WyciwygChannelChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/FTPChannelChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/WebSocketChannelChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/WebSocketEventListenerChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/DNSRequestChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/ChannelDiverterChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/IPCTransportProvider.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/network/TCPSocketChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/network/TCPServerSocketChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/network/UDPSocketChild.h"
|
|
Packit |
f0b94e |
#include "mozilla/net/AltDataOutputStreamChild.h"
|
|
Packit |
f0b94e |
#ifdef MOZ_WEBRTC
|
|
Packit |
f0b94e |
#include "mozilla/net/StunAddrsRequestChild.h"
|
|
Packit |
f0b94e |
#endif
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#include "SerializedLoadContext.h"
|
|
Packit |
f0b94e |
#include "nsGlobalWindow.h"
|
|
Packit |
f0b94e |
#include "nsIOService.h"
|
|
Packit |
f0b94e |
#include "nsINetworkPredictor.h"
|
|
Packit |
f0b94e |
#include "nsINetworkPredictorVerifier.h"
|
|
Packit |
f0b94e |
#include "mozilla/ipc/URIUtils.h"
|
|
Packit |
f0b94e |
#include "nsNetUtil.h"
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
using mozilla::dom::TCPServerSocketChild;
|
|
Packit |
f0b94e |
using mozilla::dom::TCPSocketChild;
|
|
Packit |
f0b94e |
using mozilla::dom::UDPSocketChild;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
namespace mozilla {
|
|
Packit |
f0b94e |
namespace net {
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PNeckoChild* gNeckoChild = nullptr;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// C++ file contents
|
|
Packit |
f0b94e |
NeckoChild::NeckoChild() {}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NeckoChild::~NeckoChild() {
|
|
Packit |
f0b94e |
// Send__delete__(gNeckoChild);
|
|
Packit |
f0b94e |
gNeckoChild = nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
void NeckoChild::InitNeckoChild() {
|
|
Packit |
f0b94e |
MOZ_ASSERT(IsNeckoChild(), "InitNeckoChild called by non-child!");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
if (!gNeckoChild) {
|
|
Packit |
f0b94e |
mozilla::dom::ContentChild* cpc =
|
|
Packit |
f0b94e |
mozilla::dom::ContentChild::GetSingleton();
|
|
Packit |
f0b94e |
NS_ASSERTION(cpc, "Content Protocol is NULL!");
|
|
Packit |
f0b94e |
if (NS_WARN_IF(cpc->IsShuttingDown())) {
|
|
Packit |
f0b94e |
return;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
gNeckoChild = cpc->SendPNeckoConstructor();
|
|
Packit |
f0b94e |
NS_ASSERTION(gNeckoChild, "PNecko Protocol init failed!");
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PHttpChannelChild* NeckoChild::AllocPHttpChannelChild(
|
|
Packit |
f0b94e |
const PBrowserOrId& browser, const SerializedLoadContext& loadContext,
|
|
Packit |
f0b94e |
const HttpChannelCreationArgs& aOpenArgs) {
|
|
Packit |
f0b94e |
// We don't allocate here: instead we always use IPDL constructor that takes
|
|
Packit |
f0b94e |
// an existing HttpChildChannel
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPHttpChannelChild should not be called on child");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPHttpChannelChild(PHttpChannelChild* channel) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(IsNeckoChild(), "DeallocPHttpChannelChild called by non-child!");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
HttpChannelChild* child = static_cast<HttpChannelChild*>(channel);
|
|
Packit |
f0b94e |
child->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PStunAddrsRequestChild* NeckoChild::AllocPStunAddrsRequestChild() {
|
|
Packit |
f0b94e |
// We don't allocate here: instead we always use IPDL constructor that takes
|
|
Packit |
f0b94e |
// an existing object
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPStunAddrsRequestChild should not be called on child");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPStunAddrsRequestChild(PStunAddrsRequestChild* aActor) {
|
|
Packit |
f0b94e |
#ifdef MOZ_WEBRTC
|
|
Packit |
f0b94e |
StunAddrsRequestChild* p = static_cast<StunAddrsRequestChild*>(aActor);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
#endif
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PAltDataOutputStreamChild* NeckoChild::AllocPAltDataOutputStreamChild(
|
|
Packit |
f0b94e |
const nsCString& type, PHttpChannelChild* channel) {
|
|
Packit |
f0b94e |
// We don't allocate here: see HttpChannelChild::OpenAlternativeOutputStream()
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPAltDataOutputStreamChild should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPAltDataOutputStreamChild(
|
|
Packit |
f0b94e |
PAltDataOutputStreamChild* aActor) {
|
|
Packit |
f0b94e |
AltDataOutputStreamChild* child =
|
|
Packit |
f0b94e |
static_cast<AltDataOutputStreamChild*>(aActor);
|
|
Packit |
f0b94e |
child->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PFTPChannelChild* NeckoChild::AllocPFTPChannelChild(
|
|
Packit |
f0b94e |
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
|
|
Packit |
f0b94e |
const FTPChannelCreationArgs& aOpenArgs) {
|
|
Packit |
f0b94e |
// We don't allocate here: see FTPChannelChild::AsyncOpen()
|
|
Packit |
f0b94e |
MOZ_CRASH("AllocPFTPChannelChild should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPFTPChannelChild(PFTPChannelChild* channel) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(IsNeckoChild(), "DeallocPFTPChannelChild called by non-child!");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
FTPChannelChild* child = static_cast<FTPChannelChild*>(channel);
|
|
Packit |
f0b94e |
child->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PCookieServiceChild* NeckoChild::AllocPCookieServiceChild() {
|
|
Packit |
f0b94e |
// We don't allocate here: see nsCookieService::GetSingleton()
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPCookieServiceChild should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPCookieServiceChild(PCookieServiceChild* cs) {
|
|
Packit |
f0b94e |
NS_ASSERTION(IsNeckoChild(),
|
|
Packit |
f0b94e |
"DeallocPCookieServiceChild called by non-child!");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
CookieServiceChild* p = static_cast<CookieServiceChild*>(cs);
|
|
Packit |
f0b94e |
p->Release();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PWyciwygChannelChild* NeckoChild::AllocPWyciwygChannelChild() {
|
|
Packit |
f0b94e |
// We don't allocate here: see nsWyciwygProtocolHandler::NewChannel2()
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPWyciwygChannelChild should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPWyciwygChannelChild(PWyciwygChannelChild* channel) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(IsNeckoChild(),
|
|
Packit |
f0b94e |
"DeallocPWyciwygChannelChild called by non-child!");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
WyciwygChannelChild* p = static_cast<WyciwygChannelChild*>(channel);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PWebSocketChild* NeckoChild::AllocPWebSocketChild(
|
|
Packit |
f0b94e |
const PBrowserOrId& browser, const SerializedLoadContext& aSerialized,
|
|
Packit |
f0b94e |
const uint32_t& aSerial) {
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPWebSocketChild should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPWebSocketChild(PWebSocketChild* child) {
|
|
Packit |
f0b94e |
WebSocketChannelChild* p = static_cast<WebSocketChannelChild*>(child);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PWebSocketEventListenerChild* NeckoChild::AllocPWebSocketEventListenerChild(
|
|
Packit |
f0b94e |
const uint64_t& aInnerWindowID) {
|
|
Packit |
f0b94e |
nsCOMPtr<nsIEventTarget> target;
|
|
Packit |
f0b94e |
if (nsGlobalWindowInner* win =
|
|
Packit |
f0b94e |
nsGlobalWindowInner::GetInnerWindowWithId(aInnerWindowID)) {
|
|
Packit |
f0b94e |
target = win->EventTargetFor(TaskCategory::Other);
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
RefPtr<WebSocketEventListenerChild> c =
|
|
Packit |
f0b94e |
new WebSocketEventListenerChild(aInnerWindowID, target);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
if (target) {
|
|
Packit |
f0b94e |
gNeckoChild->SetEventTargetForActor(c, target);
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
return c.forget().take();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPWebSocketEventListenerChild(
|
|
Packit |
f0b94e |
PWebSocketEventListenerChild* aActor) {
|
|
Packit |
f0b94e |
RefPtr<WebSocketEventListenerChild> c =
|
|
Packit |
f0b94e |
dont_AddRef(static_cast<WebSocketEventListenerChild*>(aActor));
|
|
Packit |
f0b94e |
MOZ_ASSERT(c);
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PDataChannelChild* NeckoChild::AllocPDataChannelChild(
|
|
Packit |
f0b94e |
const uint32_t& channelId) {
|
|
Packit |
f0b94e |
MOZ_ASSERT_UNREACHABLE("Should never get here");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPDataChannelChild(PDataChannelChild* child) {
|
|
Packit |
f0b94e |
// NB: See DataChannelChild::ActorDestroy.
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PFileChannelChild* NeckoChild::AllocPFileChannelChild(
|
|
Packit |
f0b94e |
const uint32_t& channelId) {
|
|
Packit |
f0b94e |
MOZ_ASSERT_UNREACHABLE("Should never get here");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPFileChannelChild(PFileChannelChild* child) {
|
|
Packit |
f0b94e |
// NB: See FileChannelChild::ActorDestroy.
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PSimpleChannelChild* NeckoChild::AllocPSimpleChannelChild(
|
|
Packit |
f0b94e |
const uint32_t& channelId) {
|
|
Packit |
f0b94e |
MOZ_ASSERT_UNREACHABLE("Should never get here");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPSimpleChannelChild(PSimpleChannelChild* child) {
|
|
Packit |
f0b94e |
// NB: See SimpleChannelChild::ActorDestroy.
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PTCPSocketChild* NeckoChild::AllocPTCPSocketChild(const nsString& host,
|
|
Packit |
f0b94e |
const uint16_t& port) {
|
|
Packit |
f0b94e |
TCPSocketChild* p = new TCPSocketChild(host, port, nullptr);
|
|
Packit |
f0b94e |
p->AddIPDLReference();
|
|
Packit |
f0b94e |
return p;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPTCPSocketChild(PTCPSocketChild* child) {
|
|
Packit |
f0b94e |
TCPSocketChild* p = static_cast<TCPSocketChild*>(child);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PTCPServerSocketChild* NeckoChild::AllocPTCPServerSocketChild(
|
|
Packit |
f0b94e |
const uint16_t& aLocalPort, const uint16_t& aBacklog,
|
|
Packit |
f0b94e |
const bool& aUseArrayBuffers) {
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPTCPServerSocket should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child) {
|
|
Packit |
f0b94e |
TCPServerSocketChild* p = static_cast<TCPServerSocketChild*>(child);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PUDPSocketChild* NeckoChild::AllocPUDPSocketChild(const Principal& aPrincipal,
|
|
Packit |
f0b94e |
const nsCString& aFilter) {
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPUDPSocket should not be called");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPUDPSocketChild(PUDPSocketChild* child) {
|
|
Packit |
f0b94e |
UDPSocketChild* p = static_cast<UDPSocketChild*>(child);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PDNSRequestChild* NeckoChild::AllocPDNSRequestChild(
|
|
Packit |
f0b94e |
const nsCString& aHost, const OriginAttributes& aOriginAttributes,
|
|
Packit |
f0b94e |
const uint32_t& aFlags, const nsCString& aNetworkInterface) {
|
|
Packit |
f0b94e |
// We don't allocate here: instead we always use IPDL constructor that takes
|
|
Packit |
f0b94e |
// an existing object
|
|
Packit |
f0b94e |
NS_NOTREACHED("AllocPDNSRequestChild should not be called on child");
|
|
Packit |
f0b94e |
return nullptr;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPDNSRequestChild(PDNSRequestChild* aChild) {
|
|
Packit |
f0b94e |
DNSRequestChild* p = static_cast<DNSRequestChild*>(aChild);
|
|
Packit |
f0b94e |
p->ReleaseIPDLReference();
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PChannelDiverterChild* NeckoChild::AllocPChannelDiverterChild(
|
|
Packit |
f0b94e |
const ChannelDiverterArgs& channel) {
|
|
Packit |
f0b94e |
return new ChannelDiverterChild();
|
|
Packit |
f0b94e |
;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPChannelDiverterChild(PChannelDiverterChild* child) {
|
|
Packit |
f0b94e |
delete static_cast<ChannelDiverterChild*>(child);
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
PTransportProviderChild* NeckoChild::AllocPTransportProviderChild() {
|
|
Packit |
f0b94e |
// This refcount is transferred to the receiver of the message that
|
|
Packit |
f0b94e |
// includes the PTransportProviderChild actor.
|
|
Packit |
f0b94e |
RefPtr<TransportProviderChild> res = new TransportProviderChild();
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
return res.forget().take();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool NeckoChild::DeallocPTransportProviderChild(
|
|
Packit |
f0b94e |
PTransportProviderChild* aActor) {
|
|
Packit |
f0b94e |
return true;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
mozilla::ipc::IPCResult NeckoChild::RecvAsyncAuthPromptForNestedFrame(
|
|
Packit |
f0b94e |
const TabId& aNestedFrameId, const nsCString& aUri, const nsString& aRealm,
|
|
Packit |
f0b94e |
const uint64_t& aCallbackId) {
|
|
Packit |
f0b94e |
RefPtr<dom::TabChild> tabChild = dom::TabChild::FindTabChild(aNestedFrameId);
|
|
Packit |
f0b94e |
if (!tabChild) {
|
|
Packit |
f0b94e |
MOZ_CRASH();
|
|
Packit |
f0b94e |
return IPC_FAIL_NO_REASON(this);
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
tabChild->SendAsyncAuthPrompt(aUri, aRealm, aCallbackId);
|
|
Packit |
f0b94e |
return IPC_OK();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/* Predictor Messages */
|
|
Packit |
f0b94e |
mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictPrefetch(
|
|
Packit |
f0b94e |
const URIParams& aURI, const uint32_t& aHttpStatus) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(NS_IsMainThread(),
|
|
Packit |
f0b94e |
"PredictorChild::RecvOnPredictPrefetch "
|
|
Packit |
f0b94e |
"off main thread.");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// Get the current predictor
|
|
Packit |
f0b94e |
nsresult rv = NS_OK;
|
|
Packit |
f0b94e |
nsCOMPtr<nsINetworkPredictorVerifier> predictor =
|
|
Packit |
f0b94e |
do_GetService("@mozilla.org/network/predictor;1", &rv;;
|
|
Packit |
f0b94e |
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
predictor->OnPredictPrefetch(uri, aHttpStatus);
|
|
Packit |
f0b94e |
return IPC_OK();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictPreconnect(
|
|
Packit |
f0b94e |
const URIParams& aURI) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(NS_IsMainThread(),
|
|
Packit |
f0b94e |
"PredictorChild::RecvOnPredictPreconnect "
|
|
Packit |
f0b94e |
"off main thread.");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// Get the current predictor
|
|
Packit |
f0b94e |
nsresult rv = NS_OK;
|
|
Packit |
f0b94e |
nsCOMPtr<nsINetworkPredictorVerifier> predictor =
|
|
Packit |
f0b94e |
do_GetService("@mozilla.org/network/predictor;1", &rv;;
|
|
Packit |
f0b94e |
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
predictor->OnPredictPreconnect(uri);
|
|
Packit |
f0b94e |
return IPC_OK();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictDNS(
|
|
Packit |
f0b94e |
const URIParams& aURI) {
|
|
Packit |
f0b94e |
MOZ_ASSERT(NS_IsMainThread(),
|
|
Packit |
f0b94e |
"PredictorChild::RecvOnPredictDNS off "
|
|
Packit |
f0b94e |
"main thread.");
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// Get the current predictor
|
|
Packit |
f0b94e |
nsresult rv = NS_OK;
|
|
Packit |
f0b94e |
nsCOMPtr<nsINetworkPredictorVerifier> predictor =
|
|
Packit |
f0b94e |
do_GetService("@mozilla.org/network/predictor;1", &rv;;
|
|
Packit |
f0b94e |
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
predictor->OnPredictDNS(uri);
|
|
Packit |
f0b94e |
return IPC_OK();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
mozilla::ipc::IPCResult NeckoChild::RecvSpeculativeConnectRequest() {
|
|
Packit |
f0b94e |
nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
|
|
Packit |
f0b94e |
if (obsService) {
|
|
Packit |
f0b94e |
obsService->NotifyObservers(nullptr, "speculative-connect-request",
|
|
Packit |
f0b94e |
nullptr);
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
return IPC_OK();
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
} // namespace net
|
|
Packit |
f0b94e |
} // namespace mozilla
|