2009-08-18 23:05:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
|
|
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-08-18 23:05:15 +04:00
|
|
|
|
2013-11-12 02:52:33 +04:00
|
|
|
#include "necko-config.h"
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 22:55:33 +04:00
|
|
|
#include "nsHttp.h"
|
2016-11-29 09:19:08 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
2018-07-17 22:38:48 +03:00
|
|
|
#include "mozilla/ContentPrincipal.h"
|
2017-06-24 03:10:54 +03:00
|
|
|
#include "mozilla/ipc/IPCStreamUtils.h"
|
|
|
|
#include "mozilla/net/ExtensionProtocolHandler.h"
|
2009-08-18 23:05:15 +04:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
|
|
|
#include "mozilla/net/HttpChannelParent.h"
|
2010-03-26 02:02:28 +03:00
|
|
|
#include "mozilla/net/CookieServiceParent.h"
|
2010-08-10 22:47:00 +04:00
|
|
|
#include "mozilla/net/FTPChannelParent.h"
|
2011-05-04 17:36:23 +04:00
|
|
|
#include "mozilla/net/WebSocketChannelParent.h"
|
2015-10-28 22:10:20 +03:00
|
|
|
#include "mozilla/net/WebSocketEventListenerParent.h"
|
2015-03-27 23:12:37 +03:00
|
|
|
#include "mozilla/net/DataChannelParent.h"
|
2017-07-27 23:34:54 +03:00
|
|
|
#include "mozilla/net/SimpleChannelParent.h"
|
2016-04-11 06:17:02 +03:00
|
|
|
#include "mozilla/net/AltDataOutputStreamParent.h"
|
|
|
|
#include "mozilla/Unused.h"
|
2017-04-12 21:43:50 +03:00
|
|
|
#include "mozilla/net/FileChannelParent.h"
|
2013-12-11 23:03:51 +04:00
|
|
|
#include "mozilla/net/DNSRequestParent.h"
|
2014-03-11 02:04:28 +04:00
|
|
|
#include "mozilla/net/ChannelDiverterParent.h"
|
2016-06-07 12:46:03 +03:00
|
|
|
#include "mozilla/net/IPCTransportProvider.h"
|
2018-10-23 23:07:17 +03:00
|
|
|
#include "mozilla/net/RequestContextService.h"
|
2018-10-12 12:40:36 +03:00
|
|
|
#include "mozilla/net/TrackingDummyChannelParent.h"
|
2019-01-11 23:55:07 +03:00
|
|
|
#include "mozilla/net/SocketProcessParent.h"
|
|
|
|
#include "mozilla/net/PSocketProcessBridgeParent.h"
|
2017-03-24 04:04:41 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2017-03-22 03:59:05 +03:00
|
|
|
# include "mozilla/net/StunAddrsRequestParent.h"
|
2018-06-05 20:10:16 +03:00
|
|
|
# include "mozilla/net/WebrtcProxyChannelParent.h"
|
2017-03-24 04:04:41 +03:00
|
|
|
#endif
|
2016-11-17 16:52:16 +03:00
|
|
|
#include "mozilla/dom/ChromeUtils.h"
|
2013-08-21 10:49:41 +04:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2014-12-09 19:34:00 +03:00
|
|
|
#include "mozilla/dom/TabContext.h"
|
2011-05-04 17:36:23 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2012-09-24 22:53:49 +04:00
|
|
|
#include "mozilla/dom/network/TCPSocketParent.h"
|
2013-07-29 21:36:43 +04:00
|
|
|
#include "mozilla/dom/network/TCPServerSocketParent.h"
|
2013-05-10 16:00:28 +04:00
|
|
|
#include "mozilla/dom/network/UDPSocketParent.h"
|
2018-01-27 00:08:59 +03:00
|
|
|
#include "mozilla/dom/ServiceWorkerManager.h"
|
2012-12-29 13:02:16 +04:00
|
|
|
#include "mozilla/LoadContext.h"
|
2017-06-24 03:10:54 +03:00
|
|
|
#include "mozilla/MozPromise.h"
|
2012-12-29 13:02:16 +04:00
|
|
|
#include "nsPrintfCString.h"
|
2010-07-26 22:49:09 +04:00
|
|
|
#include "nsHTMLDNSPrefetch.h"
|
2012-12-22 17:56:21 +04:00
|
|
|
#include "nsEscape.h"
|
2013-10-19 00:57:55 +04:00
|
|
|
#include "SerializedLoadContext.h"
|
2014-06-11 09:44:36 +04:00
|
|
|
#include "nsAuthInformationHolder.h"
|
|
|
|
#include "nsIAuthPromptCallback.h"
|
2015-06-18 12:23:00 +03:00
|
|
|
#include "nsINetworkPredictor.h"
|
2016-01-09 04:20:50 +03:00
|
|
|
#include "nsINetworkPredictorVerifier.h"
|
2015-02-21 01:01:36 +03:00
|
|
|
#include "nsISpeculativeConnect.h"
|
2017-03-10 03:32:00 +03:00
|
|
|
#include "nsNetUtil.h"
|
2010-07-26 22:49:09 +04:00
|
|
|
|
2012-12-29 13:02:16 +04:00
|
|
|
using IPC::SerializedLoadContext;
|
2017-01-12 19:38:48 +03:00
|
|
|
using mozilla::OriginAttributes;
|
2016-11-17 16:52:16 +03:00
|
|
|
using mozilla::dom::ChromeUtils;
|
2013-08-21 10:49:41 +04:00
|
|
|
using mozilla::dom::ContentParent;
|
2018-01-27 00:08:59 +03:00
|
|
|
using mozilla::dom::ServiceWorkerManager;
|
2014-12-09 19:34:00 +03:00
|
|
|
using mozilla::dom::TabContext;
|
2011-05-04 17:36:23 +04:00
|
|
|
using mozilla::dom::TabParent;
|
2013-07-29 21:36:43 +04:00
|
|
|
using mozilla::dom::TCPServerSocketParent;
|
2013-05-10 16:00:28 +04:00
|
|
|
using mozilla::dom::TCPSocketParent;
|
|
|
|
using mozilla::dom::UDPSocketParent;
|
2017-06-24 03:10:54 +03:00
|
|
|
using mozilla::ipc::LoadInfoArgsToLoadInfo;
|
2016-11-03 10:18:51 +03:00
|
|
|
using mozilla::ipc::OptionalPrincipalInfo;
|
|
|
|
using mozilla::ipc::PrincipalInfo;
|
2017-06-24 03:10:54 +03:00
|
|
|
using mozilla::net::PTCPServerSocketParent;
|
|
|
|
using mozilla::net::PTCPSocketParent;
|
2012-12-29 13:02:16 +04:00
|
|
|
using mozilla::net::PUDPSocketParent;
|
2011-05-04 17:36:23 +04:00
|
|
|
|
2009-08-18 23:05:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
// C++ file contents
|
2019-01-11 23:55:07 +03:00
|
|
|
NeckoParent::NeckoParent() : mSocketProcessBridgeInited(false) {
|
2013-06-22 20:09:19 +04:00
|
|
|
// Init HTTP protocol handler now since we need atomTable up and running very
|
|
|
|
// early (IPDL argument handling for PHttpChannel constructor needs it) so
|
|
|
|
// normal init (during 1st Http channel request) isn't early enough.
|
|
|
|
nsCOMPtr<nsIProtocolHandler> proto =
|
|
|
|
do_GetService("@mozilla.org/network/protocol;1?name=http");
|
|
|
|
|
2016-08-19 04:55:00 +03:00
|
|
|
// only register once--we will have multiple NeckoParents if there are
|
|
|
|
// multiple child processes.
|
|
|
|
static bool registeredBool = false;
|
|
|
|
if (!registeredBool) {
|
|
|
|
Preferences::AddBoolVarCache(&NeckoCommonInternal::gSecurityDisabled,
|
|
|
|
"network.disable.ipc.security");
|
|
|
|
registeredBool = true;
|
|
|
|
}
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
static PBOverrideStatus PBOverrideStatusFromLoadContext(
|
|
|
|
const SerializedLoadContext& aSerialized) {
|
2012-12-29 13:02:16 +04:00
|
|
|
if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) {
|
2016-08-24 01:07:56 +03:00
|
|
|
return (aSerialized.mOriginAttributes.mPrivateBrowsingId > 0)
|
2012-12-29 13:02:16 +04:00
|
|
|
? kPBOverride_Private
|
|
|
|
: kPBOverride_NotPrivate;
|
|
|
|
}
|
|
|
|
return kPBOverride_Unset;
|
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
|
2019-03-04 09:30:00 +03:00
|
|
|
const Maybe<LoadInfoArgs>& aOptionalLoadInfoArgs) {
|
|
|
|
if (aOptionalLoadInfoArgs.isNothing()) {
|
2016-11-03 10:18:51 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-03-04 09:30:00 +03:00
|
|
|
const LoadInfoArgs& loadInfoArgs = aOptionalLoadInfoArgs.ref();
|
2016-11-03 10:18:51 +03:00
|
|
|
const OptionalPrincipalInfo& optionalPrincipalInfo =
|
|
|
|
loadInfoArgs.requestingPrincipalInfo();
|
|
|
|
|
|
|
|
if (optionalPrincipalInfo.type() != OptionalPrincipalInfo::TPrincipalInfo) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PrincipalInfo& principalInfo =
|
|
|
|
optionalPrincipalInfo.get_PrincipalInfo();
|
|
|
|
|
|
|
|
return PrincipalInfoToPrincipal(principalInfo);
|
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
|
|
|
|
const HttpChannelCreationArgs& aArgs) {
|
2016-11-03 10:18:51 +03:00
|
|
|
if (aArgs.type() != HttpChannelCreationArgs::THttpChannelOpenArgs) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const HttpChannelOpenArgs& args = aArgs.get_HttpChannelOpenArgs();
|
|
|
|
return GetRequestingPrincipal(args.loadInfo());
|
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
static already_AddRefed<nsIPrincipal> GetRequestingPrincipal(
|
|
|
|
const FTPChannelCreationArgs& aArgs) {
|
2016-11-03 10:18:51 +03:00
|
|
|
if (aArgs.type() != FTPChannelCreationArgs::TFTPChannelOpenArgs) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FTPChannelOpenArgs& args = aArgs.get_FTPChannelOpenArgs();
|
|
|
|
return GetRequestingPrincipal(args.loadInfo());
|
|
|
|
}
|
|
|
|
|
2016-11-17 16:52:16 +03:00
|
|
|
// Bug 1289001 - If GetValidatedOriginAttributes returns an error string, that
|
|
|
|
// usually leads to a content crash with very little info about the cause.
|
2016-10-05 19:50:08 +03:00
|
|
|
// We prefer to crash on the parent, so we get the reason in the crash report.
|
|
|
|
static MOZ_COLD void CrashWithReason(const char* reason) {
|
2016-10-08 12:14:49 +03:00
|
|
|
#ifndef RELEASE_OR_BETA
|
2019-02-03 11:09:37 +03:00
|
|
|
MOZ_CRASH_UNSAFE(reason);
|
2016-10-05 19:50:08 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-11-17 16:52:16 +03:00
|
|
|
const char* NeckoParent::GetValidatedOriginAttributes(
|
|
|
|
const SerializedLoadContext& aSerialized, PContentParent* aContent,
|
|
|
|
nsIPrincipal* aRequestingPrincipal, OriginAttributes& aAttrs) {
|
2016-11-25 12:53:59 +03:00
|
|
|
if (!UsingNeckoIPCSecurity()) {
|
|
|
|
if (!aSerialized.IsNotNull()) {
|
|
|
|
// If serialized is null, we cannot validate anything. We have to assume
|
|
|
|
// that this requests comes from a SystemPrincipal.
|
2017-01-12 19:38:48 +03:00
|
|
|
aAttrs = OriginAttributes(NECKO_NO_APP_ID, false);
|
2016-11-25 12:53:59 +03:00
|
|
|
} else {
|
|
|
|
aAttrs = aSerialized.mOriginAttributes;
|
2013-08-21 10:49:41 +04:00
|
|
|
}
|
2016-10-29 23:04:38 +03:00
|
|
|
return nullptr;
|
2013-08-21 10:49:41 +04:00
|
|
|
}
|
|
|
|
|
2016-11-25 12:53:59 +03:00
|
|
|
if (!aSerialized.IsNotNull()) {
|
|
|
|
CrashWithReason(
|
|
|
|
"GetValidatedOriginAttributes | SerializedLoadContext from child is "
|
|
|
|
"null");
|
|
|
|
return "SerializedLoadContext from child is null";
|
|
|
|
}
|
|
|
|
|
2014-12-09 19:34:00 +03:00
|
|
|
nsTArray<TabContext> contextArray =
|
|
|
|
static_cast<ContentParent*>(aContent)->GetManagedTabContext();
|
2016-10-29 23:04:38 +03:00
|
|
|
|
2016-11-17 16:52:16 +03:00
|
|
|
nsAutoCString serializedSuffix;
|
|
|
|
aSerialized.mOriginAttributes.CreateAnonymizedSuffix(serializedSuffix);
|
|
|
|
|
2016-10-29 23:04:38 +03:00
|
|
|
nsAutoCString debugString;
|
2014-12-09 19:34:00 +03:00
|
|
|
for (uint32_t i = 0; i < contextArray.Length(); i++) {
|
2016-11-17 16:52:16 +03:00
|
|
|
const TabContext& tabContext = contextArray[i];
|
2012-12-29 13:02:16 +04:00
|
|
|
|
2016-11-17 16:52:16 +03:00
|
|
|
if (!ChromeUtils::IsOriginAttributesEqual(
|
|
|
|
aSerialized.mOriginAttributes, tabContext.OriginAttributesRef())) {
|
2017-09-04 08:14:11 +03:00
|
|
|
debugString.AppendLiteral("(");
|
2016-11-17 16:52:16 +03:00
|
|
|
debugString.Append(serializedSuffix);
|
2017-09-04 08:14:11 +03:00
|
|
|
debugString.AppendLiteral(",");
|
2016-11-17 16:52:16 +03:00
|
|
|
|
|
|
|
nsAutoCString tabSuffix;
|
|
|
|
tabContext.OriginAttributesRef().CreateAnonymizedSuffix(tabSuffix);
|
|
|
|
debugString.Append(tabSuffix);
|
|
|
|
|
2017-09-04 08:14:11 +03:00
|
|
|
debugString.AppendLiteral(")");
|
2016-01-20 02:28:00 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-11-17 16:52:16 +03:00
|
|
|
aAttrs = aSerialized.mOriginAttributes;
|
2014-06-27 19:12:03 +04:00
|
|
|
return nullptr;
|
2013-08-21 10:49:44 +04:00
|
|
|
}
|
|
|
|
|
2016-11-03 10:18:51 +03:00
|
|
|
// This may be a ServiceWorker: when a push notification is received, FF wakes
|
|
|
|
// up the corrisponding service worker so that it can manage the PushEvent. At
|
|
|
|
// that time we probably don't have any valid tabcontext, but still, we want
|
|
|
|
// to support http channel requests coming from that ServiceWorker.
|
|
|
|
if (aRequestingPrincipal) {
|
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
|
|
|
if (swm &&
|
|
|
|
swm->MayHaveActiveServiceWorkerInstance(
|
|
|
|
static_cast<ContentParent*>(aContent), aRequestingPrincipal)) {
|
|
|
|
aAttrs = aSerialized.mOriginAttributes;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-29 23:04:38 +03:00
|
|
|
nsAutoCString errorString;
|
2017-09-04 08:14:11 +03:00
|
|
|
errorString.AppendLiteral(
|
|
|
|
"GetValidatedOriginAttributes | App does not have permission -");
|
2016-10-29 23:04:38 +03:00
|
|
|
errorString.Append(debugString);
|
2014-06-27 19:12:03 +04:00
|
|
|
|
2016-10-29 23:04:38 +03:00
|
|
|
// Leak the buffer on the heap to make sure that it lives long enough, as
|
|
|
|
// MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to the end of
|
|
|
|
// the program.
|
|
|
|
char* error = strdup(errorString.BeginReading());
|
|
|
|
CrashWithReason(error);
|
|
|
|
return "App does not have permission";
|
2012-12-29 13:02:16 +04:00
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
const char* NeckoParent::CreateChannelLoadContext(
|
2013-08-21 10:49:44 +04:00
|
|
|
const PBrowserOrId& aBrowser, PContentParent* aContent,
|
2012-12-29 13:02:16 +04:00
|
|
|
const SerializedLoadContext& aSerialized,
|
2016-11-03 10:18:51 +03:00
|
|
|
nsIPrincipal* aRequestingPrincipal, nsCOMPtr<nsILoadContext>& aResult) {
|
2017-01-12 19:38:48 +03:00
|
|
|
OriginAttributes attrs;
|
2016-11-17 16:52:16 +03:00
|
|
|
const char* error = GetValidatedOriginAttributes(aSerialized, aContent,
|
|
|
|
aRequestingPrincipal, attrs);
|
2012-12-29 13:02:16 +04:00
|
|
|
if (error) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2013-01-24 23:22:00 +04:00
|
|
|
// if !UsingNeckoIPCSecurity(), we may not have a LoadContext to set. This is
|
2012-12-29 13:02:16 +04:00
|
|
|
// the common case for most xpcshell tests.
|
|
|
|
if (aSerialized.IsNotNull()) {
|
2016-08-24 01:07:56 +03:00
|
|
|
attrs.SyncAttributesWithPrivateBrowsing(
|
|
|
|
aSerialized.mOriginAttributes.mPrivateBrowsingId > 0);
|
2014-06-11 09:44:36 +04:00
|
|
|
switch (aBrowser.type()) {
|
|
|
|
case PBrowserOrId::TPBrowserParent: {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tabParent =
|
2015-02-06 00:47:32 +03:00
|
|
|
TabParent::GetFrom(aBrowser.get_PBrowserParent());
|
2014-06-11 09:44:36 +04:00
|
|
|
dom::Element* topFrameElement = nullptr;
|
|
|
|
if (tabParent) {
|
|
|
|
topFrameElement = tabParent->GetOwnerElement();
|
|
|
|
}
|
2015-09-23 11:10:21 +03:00
|
|
|
aResult = new LoadContext(aSerialized, topFrameElement, attrs);
|
2014-06-11 09:44:36 +04:00
|
|
|
break;
|
|
|
|
}
|
2014-10-24 04:29:00 +04:00
|
|
|
case PBrowserOrId::TTabId: {
|
2015-09-23 11:10:21 +03:00
|
|
|
aResult = new LoadContext(aSerialized, aBrowser.get_TabId(), attrs);
|
2014-06-11 09:44:36 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
2012-12-29 13:02:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-05-02 22:44:13 +04:00
|
|
|
void NeckoParent::ActorDestroy(ActorDestroyReason aWhy) {
|
2016-08-23 23:21:00 +03:00
|
|
|
// Nothing needed here. Called right before destructor since this is a
|
|
|
|
// non-refcounted class.
|
2014-05-02 22:44:13 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
PHttpChannelParent* NeckoParent::AllocPHttpChannelParent(
|
|
|
|
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
|
|
|
|
const HttpChannelCreationArgs& aOpenArgs) {
|
|
|
|
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
|
|
|
GetRequestingPrincipal(aOpenArgs);
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext;
|
|
|
|
const char* error = CreateChannelLoadContext(
|
|
|
|
aBrowser, Manager(), aSerialized, requestingPrincipal, loadContext);
|
|
|
|
if (error) {
|
|
|
|
printf_stderr(
|
|
|
|
"NeckoParent::AllocPHttpChannelParent: "
|
|
|
|
"FATAL error: %s: KILLING CHILD PROCESS\n",
|
|
|
|
error);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
PBOverrideStatus overrideStatus =
|
|
|
|
PBOverrideStatusFromLoadContext(aSerialized);
|
|
|
|
HttpChannelParent* p =
|
|
|
|
new HttpChannelParent(aBrowser, loadContext, overrideStatus);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 22:55:33 +04:00
|
|
|
p->AddRef();
|
|
|
|
return p;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool NeckoParent::DeallocPHttpChannelParent(PHttpChannelParent* channel) {
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 22:55:33 +04:00
|
|
|
HttpChannelParent* p = static_cast<HttpChannelParent*>(channel);
|
|
|
|
p->Release();
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 23:40:35 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPHttpChannelConstructor(
|
|
|
|
PHttpChannelParent* aActor, const PBrowserOrId& aBrowser,
|
|
|
|
const SerializedLoadContext& aSerialized,
|
|
|
|
const HttpChannelCreationArgs& aOpenArgs) {
|
|
|
|
HttpChannelParent* p = static_cast<HttpChannelParent*>(aActor);
|
|
|
|
if (!p->Init(aOpenArgs)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-03-22 03:59:05 +03:00
|
|
|
PStunAddrsRequestParent* NeckoParent::AllocPStunAddrsRequestParent() {
|
2017-03-24 04:04:41 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2017-03-22 03:59:05 +03:00
|
|
|
StunAddrsRequestParent* p = new StunAddrsRequestParent();
|
|
|
|
p->AddRef();
|
|
|
|
return p;
|
2017-03-24 04:04:41 +03:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2017-03-22 03:59:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPStunAddrsRequestParent(
|
|
|
|
PStunAddrsRequestParent* aActor) {
|
2017-03-24 04:04:41 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2017-03-22 03:59:05 +03:00
|
|
|
StunAddrsRequestParent* p = static_cast<StunAddrsRequestParent*>(aActor);
|
|
|
|
p->Release();
|
2017-03-24 04:04:41 +03:00
|
|
|
#endif
|
2017-03-22 03:59:05 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-06-05 20:10:16 +03:00
|
|
|
PWebrtcProxyChannelParent* NeckoParent::AllocPWebrtcProxyChannelParent(
|
|
|
|
const PBrowserOrId& aBrowser) {
|
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
RefPtr<TabParent> tab = TabParent::GetFrom(aBrowser.get_PBrowserParent());
|
|
|
|
WebrtcProxyChannelParent* parent = new WebrtcProxyChannelParent(tab);
|
|
|
|
parent->AddRef();
|
|
|
|
return parent;
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPWebrtcProxyChannelParent(
|
|
|
|
PWebrtcProxyChannelParent* aActor) {
|
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
WebrtcProxyChannelParent* parent =
|
|
|
|
static_cast<WebrtcProxyChannelParent*>(aActor);
|
|
|
|
parent->Release();
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-11 06:17:02 +03:00
|
|
|
PAltDataOutputStreamParent* NeckoParent::AllocPAltDataOutputStreamParent(
|
2018-04-25 07:01:00 +03:00
|
|
|
const nsCString& type, const int64_t& predictedSize,
|
2016-04-11 06:17:02 +03:00
|
|
|
PHttpChannelParent* channel) {
|
|
|
|
HttpChannelParent* chan = static_cast<HttpChannelParent*>(channel);
|
|
|
|
nsCOMPtr<nsIOutputStream> stream;
|
2018-04-25 07:01:00 +03:00
|
|
|
nsresult rv = chan->OpenAlternativeOutputStream(type, predictedSize,
|
|
|
|
getter_AddRefs(stream));
|
2016-04-11 06:17:02 +03:00
|
|
|
AltDataOutputStreamParent* parent = new AltDataOutputStreamParent(stream);
|
|
|
|
parent->AddRef();
|
|
|
|
// If the return value was not NS_OK, the error code will be sent
|
|
|
|
// asynchronously to the child, after receiving the first message.
|
|
|
|
parent->SetError(rv);
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPAltDataOutputStreamParent(
|
|
|
|
PAltDataOutputStreamParent* aActor) {
|
|
|
|
AltDataOutputStreamParent* parent =
|
|
|
|
static_cast<AltDataOutputStreamParent*>(aActor);
|
|
|
|
parent->Release();
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-22 20:09:19 +04:00
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
PFTPChannelParent* NeckoParent::AllocPFTPChannelParent(
|
2013-07-08 19:48:39 +04:00
|
|
|
const PBrowserOrId& aBrowser, const SerializedLoadContext& aSerialized,
|
|
|
|
const FTPChannelCreationArgs& aOpenArgs) {
|
2016-11-03 10:18:51 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
|
|
|
GetRequestingPrincipal(aOpenArgs);
|
|
|
|
|
2012-12-29 13:02:16 +04:00
|
|
|
nsCOMPtr<nsILoadContext> loadContext;
|
2015-07-31 00:53:38 +03:00
|
|
|
const char* error = CreateChannelLoadContext(
|
2016-11-03 10:18:51 +03:00
|
|
|
aBrowser, Manager(), aSerialized, requestingPrincipal, loadContext);
|
2012-12-29 13:02:16 +04:00
|
|
|
if (error) {
|
2013-07-08 19:48:39 +04:00
|
|
|
printf_stderr(
|
|
|
|
"NeckoParent::AllocPFTPChannelParent: "
|
2013-01-03 08:15:19 +04:00
|
|
|
"FATAL error: %s: KILLING CHILD PROCESS\n",
|
|
|
|
error);
|
2012-12-29 13:02:16 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
PBOverrideStatus overrideStatus =
|
|
|
|
PBOverrideStatusFromLoadContext(aSerialized);
|
2015-07-21 18:15:00 +03:00
|
|
|
FTPChannelParent* p =
|
|
|
|
new FTPChannelParent(aBrowser, loadContext, overrideStatus);
|
2010-08-10 22:47:00 +04:00
|
|
|
p->AddRef();
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool NeckoParent::DeallocPFTPChannelParent(PFTPChannelParent* channel) {
|
2010-08-10 22:47:00 +04:00
|
|
|
FTPChannelParent* p = static_cast<FTPChannelParent*>(channel);
|
|
|
|
p->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-22 20:09:19 +04:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPFTPChannelConstructor(
|
2014-06-11 09:44:36 +04:00
|
|
|
PFTPChannelParent* aActor, const PBrowserOrId& aBrowser,
|
2013-06-22 20:09:19 +04:00
|
|
|
const SerializedLoadContext& aSerialized,
|
|
|
|
const FTPChannelCreationArgs& aOpenArgs) {
|
|
|
|
FTPChannelParent* p = static_cast<FTPChannelParent*>(aActor);
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!p->Init(aOpenArgs)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2013-06-22 20:09:19 +04:00
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
PCookieServiceParent* NeckoParent::AllocPCookieServiceParent() {
|
2010-03-26 02:02:28 +03:00
|
|
|
return new CookieServiceParent();
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool NeckoParent::DeallocPCookieServiceParent(PCookieServiceParent* cs) {
|
2010-03-26 02:02:28 +03:00
|
|
|
delete cs;
|
2010-10-11 15:35:10 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
PWebSocketParent* NeckoParent::AllocPWebSocketParent(
|
2015-10-28 22:10:42 +03:00
|
|
|
const PBrowserOrId& browser, const SerializedLoadContext& serialized,
|
|
|
|
const uint32_t& aSerial) {
|
2012-12-29 13:02:16 +04:00
|
|
|
nsCOMPtr<nsILoadContext> loadContext;
|
2015-07-31 00:53:38 +03:00
|
|
|
const char* error = CreateChannelLoadContext(browser, Manager(), serialized,
|
2016-11-03 10:18:51 +03:00
|
|
|
nullptr, loadContext);
|
2012-12-29 13:02:16 +04:00
|
|
|
if (error) {
|
2013-07-08 19:48:39 +04:00
|
|
|
printf_stderr(
|
|
|
|
"NeckoParent::AllocPWebSocketParent: "
|
2013-01-03 08:15:19 +04:00
|
|
|
"FATAL error: %s: KILLING CHILD PROCESS\n",
|
|
|
|
error);
|
2012-12-29 13:02:16 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tabParent =
|
|
|
|
TabParent::GetFrom(browser.get_PBrowserParent());
|
2012-12-29 13:02:16 +04:00
|
|
|
PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(serialized);
|
|
|
|
WebSocketChannelParent* p = new WebSocketChannelParent(
|
|
|
|
tabParent, loadContext, overrideStatus, aSerial);
|
2011-05-04 17:36:23 +04:00
|
|
|
p->AddRef();
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool NeckoParent::DeallocPWebSocketParent(PWebSocketParent* actor) {
|
2011-05-04 17:36:23 +04:00
|
|
|
WebSocketChannelParent* p = static_cast<WebSocketChannelParent*>(actor);
|
|
|
|
p->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:10:20 +03:00
|
|
|
PWebSocketEventListenerParent* NeckoParent::AllocPWebSocketEventListenerParent(
|
|
|
|
const uint64_t& aInnerWindowID) {
|
|
|
|
RefPtr<WebSocketEventListenerParent> c =
|
|
|
|
new WebSocketEventListenerParent(aInnerWindowID);
|
2015-10-26 18:31:00 +03:00
|
|
|
return c.forget().take();
|
|
|
|
}
|
|
|
|
|
2015-10-28 22:10:20 +03:00
|
|
|
bool NeckoParent::DeallocPWebSocketEventListenerParent(
|
|
|
|
PWebSocketEventListenerParent* aActor) {
|
|
|
|
RefPtr<WebSocketEventListenerParent> c =
|
|
|
|
dont_AddRef(static_cast<WebSocketEventListenerParent*>(aActor));
|
2015-10-26 18:31:00 +03:00
|
|
|
MOZ_ASSERT(c);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-27 23:12:37 +03:00
|
|
|
PDataChannelParent* NeckoParent::AllocPDataChannelParent(
|
|
|
|
const uint32_t& channelId) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataChannelParent> p = new DataChannelParent();
|
2015-03-27 23:12:37 +03:00
|
|
|
return p.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPDataChannelParent(PDataChannelParent* actor) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataChannelParent> p =
|
|
|
|
dont_AddRef(static_cast<DataChannelParent*>(actor));
|
2015-03-27 23:12:37 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPDataChannelConstructor(
|
|
|
|
PDataChannelParent* actor, const uint32_t& channelId) {
|
|
|
|
DataChannelParent* p = static_cast<DataChannelParent*>(actor);
|
2017-01-04 09:40:56 +03:00
|
|
|
DebugOnly<bool> rv = p->Init(channelId);
|
|
|
|
MOZ_ASSERT(rv);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-27 23:12:37 +03:00
|
|
|
}
|
|
|
|
|
2017-07-27 23:34:54 +03:00
|
|
|
PSimpleChannelParent* NeckoParent::AllocPSimpleChannelParent(
|
|
|
|
const uint32_t& channelId) {
|
|
|
|
RefPtr<SimpleChannelParent> p = new SimpleChannelParent();
|
|
|
|
return p.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPSimpleChannelParent(PSimpleChannelParent* actor) {
|
|
|
|
RefPtr<SimpleChannelParent> p =
|
|
|
|
dont_AddRef(actor).downcast<SimpleChannelParent>();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPSimpleChannelConstructor(
|
|
|
|
PSimpleChannelParent* actor, const uint32_t& channelId) {
|
|
|
|
SimpleChannelParent* p = static_cast<SimpleChannelParent*>(actor);
|
|
|
|
MOZ_ALWAYS_TRUE(p->Init(channelId));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-04-12 21:43:50 +03:00
|
|
|
PFileChannelParent* NeckoParent::AllocPFileChannelParent(
|
|
|
|
const uint32_t& channelId) {
|
|
|
|
RefPtr<FileChannelParent> p = new FileChannelParent();
|
|
|
|
return p.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPFileChannelParent(PFileChannelParent* actor) {
|
|
|
|
RefPtr<FileChannelParent> p =
|
|
|
|
dont_AddRef(static_cast<FileChannelParent*>(actor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPFileChannelConstructor(
|
|
|
|
PFileChannelParent* actor, const uint32_t& channelId) {
|
|
|
|
FileChannelParent* p = static_cast<FileChannelParent*>(actor);
|
|
|
|
DebugOnly<bool> rv = p->Init(channelId);
|
|
|
|
MOZ_ASSERT(rv);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2013-12-19 07:21:12 +04:00
|
|
|
PTCPSocketParent* NeckoParent::AllocPTCPSocketParent(
|
|
|
|
const nsString& /* host */, const uint16_t& /* port */) {
|
|
|
|
// We actually don't need host/port to construct a TCPSocketParent since
|
|
|
|
// TCPSocketParent will maintain an internal nsIDOMTCPSocket instance which
|
2015-10-28 19:52:40 +03:00
|
|
|
// can be delegated to get the host/port.
|
2012-09-24 22:53:49 +04:00
|
|
|
TCPSocketParent* p = new TCPSocketParent();
|
2013-07-29 21:36:43 +04:00
|
|
|
p->AddIPDLReference();
|
2012-09-24 22:53:49 +04:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2013-07-29 21:36:43 +04:00
|
|
|
bool NeckoParent::DeallocPTCPSocketParent(PTCPSocketParent* actor) {
|
|
|
|
TCPSocketParent* p = static_cast<TCPSocketParent*>(actor);
|
|
|
|
p->ReleaseIPDLReference();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
PTCPServerSocketParent* NeckoParent::AllocPTCPServerSocketParent(
|
2015-03-25 17:36:56 +03:00
|
|
|
const uint16_t& aLocalPort, const uint16_t& aBacklog,
|
|
|
|
const bool& aUseArrayBuffers) {
|
|
|
|
TCPServerSocketParent* p =
|
|
|
|
new TCPServerSocketParent(this, aLocalPort, aBacklog, aUseArrayBuffers);
|
2013-07-29 21:36:43 +04:00
|
|
|
p->AddIPDLReference();
|
|
|
|
return p;
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 21:36:43 +04:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPTCPServerSocketConstructor(
|
|
|
|
PTCPServerSocketParent* aActor, const uint16_t& aLocalPort,
|
2015-03-25 17:36:56 +03:00
|
|
|
const uint16_t& aBacklog, const bool& aUseArrayBuffers) {
|
|
|
|
static_cast<TCPServerSocketParent*>(aActor)->Init();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-07-29 21:36:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor) {
|
|
|
|
TCPServerSocketParent* p = static_cast<TCPServerSocketParent*>(actor);
|
|
|
|
p->ReleaseIPDLReference();
|
2012-09-24 22:53:49 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:35:00 +03:00
|
|
|
PUDPSocketParent* NeckoParent::AllocPUDPSocketParent(
|
|
|
|
const Principal& /* unused */, const nsCString& /* unused */) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<UDPSocketParent> p = new UDPSocketParent(this);
|
2013-05-10 16:00:28 +04:00
|
|
|
|
2014-05-06 14:32:25 +04:00
|
|
|
return p.forget().take();
|
2013-05-10 16:00:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPUDPSocketConstructor(
|
2015-04-08 22:35:00 +03:00
|
|
|
PUDPSocketParent* aActor, const Principal& aPrincipal,
|
2013-11-29 20:13:44 +04:00
|
|
|
const nsCString& aFilter) {
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!static_cast<UDPSocketParent*>(aActor)->Init(aPrincipal, aFilter)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2013-05-10 16:00:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPUDPSocketParent(PUDPSocketParent* actor) {
|
|
|
|
UDPSocketParent* p = static_cast<UDPSocketParent*>(actor);
|
|
|
|
p->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
PDNSRequestParent* NeckoParent::AllocPDNSRequestParent(
|
2017-02-14 07:25:35 +03:00
|
|
|
const nsCString& aHost, const OriginAttributes& aOriginAttributes,
|
2018-05-16 23:05:03 +03:00
|
|
|
const uint32_t& aFlags) {
|
2013-12-11 23:03:51 +04:00
|
|
|
DNSRequestParent* p = new DNSRequestParent();
|
|
|
|
p->AddRef();
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPDNSRequestConstructor(
|
|
|
|
PDNSRequestParent* aActor, const nsCString& aHost,
|
2017-02-14 07:25:35 +03:00
|
|
|
const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) {
|
|
|
|
static_cast<DNSRequestParent*>(aActor)->DoAsyncResolve(
|
|
|
|
aHost, aOriginAttributes, aFlags);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPDNSRequestParent(PDNSRequestParent* aParent) {
|
|
|
|
DNSRequestParent* p = static_cast<DNSRequestParent*>(aParent);
|
|
|
|
p->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-24 07:18:25 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvSpeculativeConnect(
|
|
|
|
const URIParams& aURI, const Principal& aPrincipal,
|
|
|
|
const bool& aAnonymous) {
|
2015-02-21 01:01:36 +03:00
|
|
|
nsCOMPtr<nsISpeculativeConnect> speculator(gIOService);
|
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
2016-10-24 07:18:25 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> principal(aPrincipal);
|
2015-02-21 01:01:36 +03:00
|
|
|
if (uri && speculator) {
|
2015-05-06 04:15:36 +03:00
|
|
|
if (aAnonymous) {
|
2019-02-24 22:26:56 +03:00
|
|
|
speculator->SpeculativeAnonymousConnect(uri, principal, nullptr);
|
2015-05-06 04:15:36 +03:00
|
|
|
} else {
|
2019-02-24 22:26:56 +03:00
|
|
|
speculator->SpeculativeConnect(uri, principal, nullptr);
|
2015-05-06 04:15:36 +03:00
|
|
|
}
|
2015-02-21 01:01:36 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-21 01:01:36 +03:00
|
|
|
}
|
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvHTMLDNSPrefetch(
|
|
|
|
const nsString& hostname, const bool& isHttps,
|
2017-02-15 12:48:15 +03:00
|
|
|
const OriginAttributes& aOriginAttributes, const uint16_t& flags) {
|
2018-09-22 23:54:11 +03:00
|
|
|
nsHTMLDNSPrefetch::Prefetch(hostname, isHttps, aOriginAttributes, flags);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-01-21 03:14:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvCancelHTMLDNSPrefetch(
|
|
|
|
const nsString& hostname, const bool& isHttps,
|
2017-02-15 12:48:15 +03:00
|
|
|
const OriginAttributes& aOriginAttributes, const uint16_t& flags,
|
|
|
|
const nsresult& reason) {
|
2018-09-22 23:54:11 +03:00
|
|
|
nsHTMLDNSPrefetch::CancelPrefetch(hostname, isHttps, aOriginAttributes, flags,
|
|
|
|
reason);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-07-26 22:49:09 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 02:04:28 +04:00
|
|
|
PChannelDiverterParent* NeckoParent::AllocPChannelDiverterParent(
|
|
|
|
const ChannelDiverterArgs& channel) {
|
|
|
|
return new ChannelDiverterParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPChannelDiverterConstructor(
|
|
|
|
PChannelDiverterParent* actor, const ChannelDiverterArgs& channel) {
|
|
|
|
auto parent = static_cast<ChannelDiverterParent*>(actor);
|
|
|
|
parent->Init(channel);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-03-11 02:04:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPChannelDiverterParent(
|
|
|
|
PChannelDiverterParent* parent) {
|
|
|
|
delete static_cast<ChannelDiverterParent*>(parent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-07 12:46:03 +03:00
|
|
|
PTransportProviderParent* NeckoParent::AllocPTransportProviderParent() {
|
|
|
|
RefPtr<TransportProviderParent> res = new TransportProviderParent();
|
|
|
|
return res.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPTransportProviderParent(
|
|
|
|
PTransportProviderParent* aActor) {
|
|
|
|
RefPtr<TransportProviderParent> provider =
|
|
|
|
dont_AddRef(static_cast<TransportProviderParent*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:36 +04:00
|
|
|
namespace {
|
|
|
|
std::map<uint64_t, nsCOMPtr<nsIAuthPromptCallback> >& CallbackMap() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
static std::map<uint64_t, nsCOMPtr<nsIAuthPromptCallback> > sCallbackMap;
|
|
|
|
return sCallbackMap;
|
|
|
|
}
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2014-06-11 09:44:36 +04:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(NeckoParent::NestedFrameAuthPrompt, nsIAuthPrompt2)
|
|
|
|
|
|
|
|
NeckoParent::NestedFrameAuthPrompt::NestedFrameAuthPrompt(PNeckoParent* aParent,
|
2014-10-24 04:29:00 +04:00
|
|
|
TabId aNestedFrameId)
|
2014-06-11 09:44:36 +04:00
|
|
|
: mNeckoParent(aParent), mNestedFrameId(aNestedFrameId) {}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
NeckoParent::NestedFrameAuthPrompt::AsyncPromptAuth(
|
|
|
|
nsIChannel* aChannel, nsIAuthPromptCallback* callback, nsISupports*,
|
|
|
|
uint32_t, nsIAuthInformation* aInfo, nsICancelable**) {
|
|
|
|
static uint64_t callbackId = 0;
|
2015-07-04 04:29:00 +03:00
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
2014-06-11 09:44:36 +04:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsAutoCString spec;
|
|
|
|
if (uri) {
|
|
|
|
rv = uri->GetSpec(spec);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
nsString realm;
|
|
|
|
rv = aInfo->GetRealm(realm);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
callbackId++;
|
|
|
|
if (mNeckoParent->SendAsyncAuthPromptForNestedFrame(mNestedFrameId, spec,
|
|
|
|
realm, callbackId)) {
|
|
|
|
CallbackMap()[callbackId] = callback;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvOnAuthAvailable(
|
|
|
|
const uint64_t& aCallbackId, const nsString& aUser,
|
|
|
|
const nsString& aPassword, const nsString& aDomain) {
|
|
|
|
nsCOMPtr<nsIAuthPromptCallback> callback = CallbackMap()[aCallbackId];
|
|
|
|
if (!callback) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
|
|
|
CallbackMap().erase(aCallbackId);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsAuthInformationHolder> holder =
|
2014-06-11 09:44:36 +04:00
|
|
|
new nsAuthInformationHolder(0, EmptyString(), EmptyCString());
|
|
|
|
holder->SetUsername(aUser);
|
|
|
|
holder->SetPassword(aPassword);
|
|
|
|
holder->SetDomain(aDomain);
|
|
|
|
|
|
|
|
callback->OnAuthAvailable(nullptr, holder);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvOnAuthCancelled(
|
|
|
|
const uint64_t& aCallbackId, const bool& aUserCancel) {
|
|
|
|
nsCOMPtr<nsIAuthPromptCallback> callback = CallbackMap()[aCallbackId];
|
|
|
|
if (!callback) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
|
|
|
CallbackMap().erase(aCallbackId);
|
|
|
|
callback->OnAuthCancelled(nullptr, aUserCancel);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
|
|
|
|
2015-06-18 12:23:00 +03:00
|
|
|
/* Predictor Messages */
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPredPredict(
|
|
|
|
const ipc::OptionalURIParams& aTargetURI,
|
|
|
|
const ipc::OptionalURIParams& aSourceURI, const uint32_t& aReason,
|
2017-02-03 06:16:00 +03:00
|
|
|
const OriginAttributes& aOriginAttributes, const bool& hasVerifier) {
|
2015-06-18 12:23:00 +03:00
|
|
|
nsCOMPtr<nsIURI> targetURI = DeserializeURI(aTargetURI);
|
|
|
|
nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI);
|
|
|
|
|
|
|
|
// Get the current predictor
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsINetworkPredictor> predictor =
|
|
|
|
do_GetService("@mozilla.org/network/predictor;1", &rv);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
2015-06-18 12:23:00 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsINetworkPredictorVerifier> verifier;
|
|
|
|
if (hasVerifier) {
|
|
|
|
verifier = do_QueryInterface(predictor);
|
|
|
|
}
|
2017-02-03 06:16:00 +03:00
|
|
|
predictor->PredictNative(targetURI, sourceURI, aReason, aOriginAttributes,
|
|
|
|
verifier);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-18 12:23:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPredLearn(
|
|
|
|
const ipc::URIParams& aTargetURI, const ipc::OptionalURIParams& aSourceURI,
|
2017-02-03 06:16:00 +03:00
|
|
|
const uint32_t& aReason, const OriginAttributes& aOriginAttributes) {
|
2015-06-18 12:23:00 +03:00
|
|
|
nsCOMPtr<nsIURI> targetURI = DeserializeURI(aTargetURI);
|
|
|
|
nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI);
|
|
|
|
|
|
|
|
// Get the current predictor
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsINetworkPredictor> predictor =
|
|
|
|
do_GetService("@mozilla.org/network/predictor;1", &rv);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
2015-06-18 12:23:00 +03:00
|
|
|
|
2017-02-03 06:16:00 +03:00
|
|
|
predictor->LearnNative(targetURI, sourceURI, aReason, aOriginAttributes);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-18 12:23:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPredReset() {
|
|
|
|
// Get the current predictor
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsINetworkPredictor> predictor =
|
|
|
|
do_GetService("@mozilla.org/network/predictor;1", &rv);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
|
2015-06-18 12:23:00 +03:00
|
|
|
|
|
|
|
predictor->Reset();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-06-18 12:23:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-30 16:32:00 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvRequestContextLoadBegin(
|
|
|
|
const uint64_t& rcid) {
|
|
|
|
nsCOMPtr<nsIRequestContextService> rcsvc =
|
2018-10-23 23:07:17 +03:00
|
|
|
RequestContextService::GetOrCreate();
|
2017-08-30 16:32:00 +03:00
|
|
|
if (!rcsvc) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIRequestContext> rc;
|
|
|
|
rcsvc->GetRequestContext(rcid, getter_AddRefs(rc));
|
|
|
|
if (rc) {
|
|
|
|
rc->BeginLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvRequestContextAfterDOMContentLoaded(
|
|
|
|
const uint64_t& rcid) {
|
|
|
|
nsCOMPtr<nsIRequestContextService> rcsvc =
|
2018-10-23 23:07:17 +03:00
|
|
|
RequestContextService::GetOrCreate();
|
2017-08-30 16:32:00 +03:00
|
|
|
if (!rcsvc) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIRequestContext> rc;
|
|
|
|
rcsvc->GetRequestContext(rcid, getter_AddRefs(rc));
|
|
|
|
if (rc) {
|
|
|
|
rc->DOMContentLoaded();
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-03-23 17:40:36 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvRemoveRequestContext(
|
|
|
|
const uint64_t& rcid) {
|
2016-04-21 17:59:17 +03:00
|
|
|
nsCOMPtr<nsIRequestContextService> rcsvc =
|
2018-10-23 23:07:17 +03:00
|
|
|
RequestContextService::GetOrCreate();
|
2016-04-21 17:59:17 +03:00
|
|
|
if (!rcsvc) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-07-31 23:50:08 +03:00
|
|
|
}
|
|
|
|
|
2017-03-23 17:40:36 +03:00
|
|
|
rcsvc->RemoveRequestContext(rcid);
|
2015-07-31 23:50:08 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-07-31 23:50:08 +03:00
|
|
|
}
|
|
|
|
|
2017-06-24 03:10:54 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvGetExtensionStream(
|
|
|
|
const URIParams& aURI, GetExtensionStreamResolver&& aResolve) {
|
|
|
|
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
|
|
|
|
if (!deserializedURI) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
|
|
|
|
MOZ_ASSERT(ph);
|
|
|
|
|
|
|
|
// Ask the ExtensionProtocolHandler to give us a new input stream for
|
|
|
|
// this URI. The request comes from an ExtensionProtocolHandler in the
|
|
|
|
// child process, but is not guaranteed to be a valid moz-extension URI,
|
|
|
|
// and not guaranteed to represent a resource that the child should be
|
|
|
|
// allowed to access. The ExtensionProtocolHandler is responsible for
|
|
|
|
// validating the request. Specifically, only URI's for local files that
|
|
|
|
// an extension is allowed to access via moz-extension URI's should be
|
|
|
|
// accepted.
|
|
|
|
nsCOMPtr<nsIInputStream> inputStream;
|
|
|
|
bool terminateSender = true;
|
2017-07-20 21:49:29 +03:00
|
|
|
auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender);
|
2017-06-24 03:10:54 +03:00
|
|
|
if (inputStreamOrReason.isOk()) {
|
|
|
|
inputStream = inputStreamOrReason.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If NewStream failed, we send back an invalid stream to the child so
|
|
|
|
// it can handle the error. MozPromise rejection is reserved for channel
|
|
|
|
// errors/disconnects.
|
2018-02-23 23:29:54 +03:00
|
|
|
aResolve(inputStream);
|
2017-06-24 03:10:54 +03:00
|
|
|
|
|
|
|
if (terminateSender) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
2018-04-30 19:46:04 +03:00
|
|
|
return IPC_OK();
|
2017-06-24 03:10:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvGetExtensionFD(
|
|
|
|
const URIParams& aURI, GetExtensionFDResolver&& aResolve) {
|
|
|
|
nsCOMPtr<nsIURI> deserializedURI = DeserializeURI(aURI);
|
|
|
|
if (!deserializedURI) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<ExtensionProtocolHandler> ph(ExtensionProtocolHandler::GetSingleton());
|
|
|
|
MOZ_ASSERT(ph);
|
|
|
|
|
|
|
|
// Ask the ExtensionProtocolHandler to give us a new input stream for
|
|
|
|
// this URI. The request comes from an ExtensionProtocolHandler in the
|
|
|
|
// child process, but is not guaranteed to be a valid moz-extension URI,
|
|
|
|
// and not guaranteed to represent a resource that the child should be
|
|
|
|
// allowed to access. The ExtensionProtocolHandler is responsible for
|
|
|
|
// validating the request. Specifically, only URI's for local files that
|
|
|
|
// an extension is allowed to access via moz-extension URI's should be
|
|
|
|
// accepted.
|
|
|
|
bool terminateSender = true;
|
2017-07-20 21:49:29 +03:00
|
|
|
auto result = ph->NewFD(deserializedURI, &terminateSender, aResolve);
|
2017-06-24 03:10:54 +03:00
|
|
|
|
|
|
|
if (result.isErr() && terminateSender) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isErr()) {
|
|
|
|
FileDescriptor invalidFD;
|
|
|
|
aResolve(invalidFD);
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-10-12 12:40:36 +03:00
|
|
|
PTrackingDummyChannelParent* NeckoParent::AllocPTrackingDummyChannelParent(
|
2018-10-25 11:44:12 +03:00
|
|
|
nsIURI* aURI, nsIURI* aTopWindowURI, const nsresult& aTopWindowURIResult,
|
2019-03-04 09:30:00 +03:00
|
|
|
const Maybe<LoadInfoArgs>& aLoadInfo) {
|
2018-10-12 12:40:36 +03:00
|
|
|
RefPtr<TrackingDummyChannelParent> c = new TrackingDummyChannelParent();
|
|
|
|
return c.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvPTrackingDummyChannelConstructor(
|
|
|
|
PTrackingDummyChannelParent* aActor, nsIURI* aURI, nsIURI* aTopWindowURI,
|
2019-03-04 09:30:00 +03:00
|
|
|
const nsresult& aTopWindowURIResult, const Maybe<LoadInfoArgs>& aLoadInfo) {
|
2018-10-12 12:40:36 +03:00
|
|
|
TrackingDummyChannelParent* p =
|
|
|
|
static_cast<TrackingDummyChannelParent*>(aActor);
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!aURI)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo;
|
|
|
|
nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfo, getter_AddRefs(loadInfo));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv)) || !loadInfo) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
2018-10-25 11:44:12 +03:00
|
|
|
p->Init(aURI, aTopWindowURI, aTopWindowURIResult, loadInfo);
|
2018-10-12 12:40:36 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeckoParent::DeallocPTrackingDummyChannelParent(
|
|
|
|
PTrackingDummyChannelParent* aActor) {
|
|
|
|
RefPtr<TrackingDummyChannelParent> c =
|
|
|
|
dont_AddRef(static_cast<TrackingDummyChannelParent*>(aActor));
|
|
|
|
MOZ_ASSERT(c);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-11 23:55:07 +03:00
|
|
|
mozilla::ipc::IPCResult NeckoParent::RecvInitSocketProcessBridge(
|
|
|
|
InitSocketProcessBridgeResolver&& aResolver) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
Endpoint<PSocketProcessBridgeChild> invalidEndpoint;
|
|
|
|
if (NS_WARN_IF(mSocketProcessBridgeInited)) {
|
|
|
|
aResolver(std::move(invalidEndpoint));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
SocketProcessParent* parent = SocketProcessParent::GetSingleton();
|
|
|
|
if (NS_WARN_IF(!parent)) {
|
|
|
|
aResolver(std::move(invalidEndpoint));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
Endpoint<PSocketProcessBridgeParent> parentEndpoint;
|
|
|
|
Endpoint<PSocketProcessBridgeChild> childEndpoint;
|
|
|
|
if (NS_WARN_IF(NS_FAILED(PSocketProcessBridge::CreateEndpoints(
|
|
|
|
parent->OtherPid(), Manager()->OtherPid(), &parentEndpoint,
|
|
|
|
&childEndpoint)))) {
|
|
|
|
aResolver(std::move(invalidEndpoint));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!parent->SendInitSocketProcessBridgeParent(
|
|
|
|
Manager()->OtherPid(), std::move(parentEndpoint)))) {
|
|
|
|
aResolver(std::move(invalidEndpoint));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
aResolver(std::move(childEndpoint));
|
|
|
|
mSocketProcessBridgeInited = true;
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|