Backed out 3 changesets (bug 1650163) for causing bustages in nsContentSecurityManager.cpp

CLOSED TREE

Backed out changeset 51d7c644a1e6 (bug 1650163)
Backed out changeset 3d2b6908447a (bug 1650163)
Backed out changeset 79141707d47b (bug 1650163)
This commit is contained in:
Mihai Alexandru Michis 2020-07-08 21:18:44 +03:00
parent 48c6c034ee
commit 1ba2a3f6f6
76 changed files with 368 additions and 341 deletions

View File

@ -156,7 +156,7 @@ AboutRedirector::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
// startup cache. // startup cache.
if (XRE_IsContentProcess() && path.EqualsLiteral("home")) { if (XRE_IsContentProcess() && path.EqualsLiteral("home")) {
auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType(); auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType();
if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) { if (remoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) {
nsCOMPtr<nsIAboutNewTabService> aboutNewTabService = nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv); do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -938,7 +938,7 @@ nsresult nsScriptSecurityManager::CheckLoadURIFlags(
} }
auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType(); auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType();
if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) { if (remoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) {
return NS_OK; return NS_OK;
} }
} }

View File

@ -1047,8 +1047,9 @@ bool BrowsingContext::CrossOriginIsolated() {
nsILoadInfo:: nsILoadInfo::
OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP && OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP &&
XRE_IsContentProcess() && XRE_IsContentProcess() &&
StringBeginsWith(ContentChild::GetSingleton()->GetRemoteType(), StringBeginsWith(
WITH_COOP_COEP_REMOTE_TYPE_PREFIX); ContentChild::GetSingleton()->GetRemoteType(),
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
} }
BrowsingContext::~BrowsingContext() { BrowsingContext::~BrowsingContext() {

View File

@ -94,11 +94,11 @@ ContentParent* CanonicalBrowsingContext::GetContentParent() const {
return cpm->GetContentProcessById(ContentParentId(mProcessId)); return cpm->GetContentProcessById(ContentParentId(mProcessId));
} }
void CanonicalBrowsingContext::GetCurrentRemoteType(nsACString& aRemoteType, void CanonicalBrowsingContext::GetCurrentRemoteType(nsAString& aRemoteType,
ErrorResult& aRv) const { ErrorResult& aRv) const {
// If we're in the parent process, dump out the void string. // If we're in the parent process, dump out the void string.
if (mProcessId == 0) { if (mProcessId == 0) {
aRemoteType = NOT_REMOTE_TYPE; aRemoteType.Assign(VoidString());
return; return;
} }
@ -108,7 +108,7 @@ void CanonicalBrowsingContext::GetCurrentRemoteType(nsACString& aRemoteType,
return; return;
} }
aRemoteType = cp->GetRemoteType(); aRemoteType.Assign(cp->GetRemoteType());
} }
void CanonicalBrowsingContext::SetOwnerProcessId(uint64_t aProcessId) { void CanonicalBrowsingContext::SetOwnerProcessId(uint64_t aProcessId) {
@ -822,7 +822,7 @@ CanonicalBrowsingContext::PendingRemotenessChange::~PendingRemotenessChange() {
} }
RefPtr<CanonicalBrowsingContext::RemotenessPromise> RefPtr<CanonicalBrowsingContext::RemotenessPromise>
CanonicalBrowsingContext::ChangeRemoteness(const nsACString& aRemoteType, CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType,
uint64_t aPendingSwitchId, uint64_t aPendingSwitchId,
bool aReplaceBrowsingContext, bool aReplaceBrowsingContext,
uint64_t aSpecificGroupId) { uint64_t aSpecificGroupId) {

View File

@ -59,7 +59,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
uint64_t EmbedderProcessId() const { return mEmbedderProcessId; } uint64_t EmbedderProcessId() const { return mEmbedderProcessId; }
ContentParent* GetContentParent() const; ContentParent* GetContentParent() const;
void GetCurrentRemoteType(nsACString& aRemoteType, ErrorResult& aRv) const; void GetCurrentRemoteType(nsAString& aRemoteType, ErrorResult& aRv) const;
void SetOwnerProcessId(uint64_t aProcessId); void SetOwnerProcessId(uint64_t aProcessId);
@ -150,10 +150,10 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// Internal method to change which process a BrowsingContext is being loaded // Internal method to change which process a BrowsingContext is being loaded
// in. The returned promise will resolve when the process switch is completed. // in. The returned promise will resolve when the process switch is completed.
// //
// A NOT_REMOTE_TYPE aRemoteType argument will perform a process switch into // A VoidString() aRemoteType argument will perform a process switch into the
// the parent process, and the method will resolve with a null BrowserParent. // parent process, and the method will resolve with a null BrowserParent.
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>; using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
RefPtr<RemotenessPromise> ChangeRemoteness(const nsACString& aRemoteType, RefPtr<RemotenessPromise> ChangeRemoteness(const nsAString& aRemoteType,
uint64_t aPendingSwitchId, uint64_t aPendingSwitchId,
bool aReplaceBrowsingContext, bool aReplaceBrowsingContext,
uint64_t aSpecificGroupId); uint64_t aSpecificGroupId);

View File

@ -795,7 +795,7 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
global->EventTargetFor(TaskCategory::Performance); global->EventTargetFor(TaskCategory::Performance);
// Getting the parent proc info // Getting the parent proc info
mozilla::GetProcInfo(parentPid, 0, mozilla::ProcType::Browser, ""_ns) mozilla::GetProcInfo(parentPid, 0, mozilla::ProcType::Browser, u""_ns)
->Then( ->Then(
target, __func__, target, __func__,
[target, domPromise, parentPid](ProcInfo aParentInfo) { [target, domPromise, parentPid](ProcInfo aParentInfo) {
@ -809,7 +809,7 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
if (!aGeckoProcess->GetChildProcessHandle()) { if (!aGeckoProcess->GetChildProcessHandle()) {
return; return;
} }
nsAutoCString origin; nsAutoString origin;
base::ProcessId childPid = base::ProcessId childPid =
base::GetProcId(aGeckoProcess->GetChildProcessHandle()); base::GetProcId(aGeckoProcess->GetChildProcessHandle());
int32_t childId = 0; int32_t childId = 0;
@ -832,42 +832,50 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// Converting the remoteType into a ProcType. // Converting the remoteType into a ProcType.
// Ideally, the remoteType should be strongly typed // Ideally, the remoteType should be strongly typed
// upstream, this would make the conversion less brittle. // upstream, this would make the conversion less brittle.
nsAutoCString remoteType(contentParent->GetRemoteType()); nsAutoString remoteType(contentParent->GetRemoteType());
if (StringBeginsWith(remoteType, if (StringBeginsWith(remoteType,
FISSION_WEB_REMOTE_TYPE)) { NS_LITERAL_STRING_FROM_CSTRING(
FISSION_WEB_REMOTE_TYPE))) {
// WARNING: Do not change the order, as // WARNING: Do not change the order, as
// `DEFAULT_REMOTE_TYPE` is a prefix of // `DEFAULT_REMOTE_TYPE` is a prefix of
// `FISSION_WEB_REMOTE_TYPE`. // `FISSION_WEB_REMOTE_TYPE`.
type = mozilla::ProcType::WebIsolated; type = mozilla::ProcType::WebIsolated;
} else if (StringBeginsWith(remoteType, } else if (StringBeginsWith(
DEFAULT_REMOTE_TYPE)) { remoteType, NS_LITERAL_STRING_FROM_CSTRING(
DEFAULT_REMOTE_TYPE))) {
type = mozilla::ProcType::Web; type = mozilla::ProcType::Web;
} else if (remoteType == FILE_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(FILE_REMOTE_TYPE)) {
type = mozilla::ProcType::File; type = mozilla::ProcType::File;
} else if (remoteType == EXTENSION_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(
EXTENSION_REMOTE_TYPE)) {
type = mozilla::ProcType::Extension; type = mozilla::ProcType::Extension;
} else if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(
PRIVILEGEDABOUT_REMOTE_TYPE)) {
type = mozilla::ProcType::PrivilegedAbout; type = mozilla::ProcType::PrivilegedAbout;
} else if (remoteType == PRIVILEGEDMOZILLA_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(
PRIVILEGEDMOZILLA_REMOTE_TYPE)) {
type = mozilla::ProcType::PrivilegedMozilla; type = mozilla::ProcType::PrivilegedMozilla;
} else if (StringBeginsWith( } else if (StringBeginsWith(
remoteType, remoteType,
WITH_COOP_COEP_REMOTE_TYPE_PREFIX)) { NS_LITERAL_STRING_FROM_CSTRING(
WITH_COOP_COEP_REMOTE_TYPE_PREFIX))) {
type = mozilla::ProcType::WebCOOPCOEP; type = mozilla::ProcType::WebCOOPCOEP;
} else if (remoteType == LARGE_ALLOCATION_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(
LARGE_ALLOCATION_REMOTE_TYPE)) {
type = mozilla::ProcType::WebLargeAllocation; type = mozilla::ProcType::WebLargeAllocation;
} else if (remoteType == PREALLOC_REMOTE_TYPE) { } else if (remoteType.EqualsLiteral(
PREALLOC_REMOTE_TYPE)) {
type = mozilla::ProcType::Preallocated; type = mozilla::ProcType::Preallocated;
} else { } else {
MOZ_CRASH("Unknown remoteType"); MOZ_CRASH("Unknown remoteType");
} }
// By convention, everything after '=' is the origin. // By convention, everything after '=' is the origin.
nsACString::const_iterator cursor; nsAString::const_iterator cursor;
nsACString::const_iterator end; nsAString::const_iterator end;
remoteType.BeginReading(cursor); remoteType.BeginReading(cursor);
remoteType.EndReading(end); remoteType.EndReading(end);
if (FindCharInReadable('=', cursor, end)) { if (FindCharInReadable(u'=', cursor, end)) {
origin = Substring(++cursor, end); origin = Substring(++cursor, end);
} }
childId = contentParent->ChildID(); childId = contentParent->ChildID();

View File

@ -75,7 +75,7 @@ class MessageManagerGlobal {
return mMessageManager->GetProcessMessageManager(aError); return mMessageManager->GetProcessMessageManager(aError);
} }
void GetRemoteType(nsACString& aRemoteType, mozilla::ErrorResult& aError) { void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) {
if (!mMessageManager) { if (!mMessageManager) {
aError.Throw(NS_ERROR_NOT_INITIALIZED); aError.Throw(NS_ERROR_NOT_INITIALIZED);
return; return;

View File

@ -169,7 +169,7 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, BrowsingContext* aBrowsingContext,
mDetachedSubdocFrame(nullptr), mDetachedSubdocFrame(nullptr),
mPendingSwitchID(0), mPendingSwitchID(0),
mChildID(0), mChildID(0),
mRemoteType(NOT_REMOTE_TYPE), mRemoteType(VoidString()),
mDepthTooGreat(false), mDepthTooGreat(false),
mIsTopLevelContent(false), mIsTopLevelContent(false),
mDestroyCalled(false), mDestroyCalled(false),
@ -351,20 +351,17 @@ static bool InitialLoadIsRemote(Element* aOwner) {
} }
static void GetInitialRemoteTypeAndProcess(Element* aOwner, static void GetInitialRemoteTypeAndProcess(Element* aOwner,
nsACString& aRemoteType, nsAString& aRemoteType,
uint64_t* aChildID) { uint64_t* aChildID) {
MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(XRE_IsParentProcess());
*aChildID = 0; *aChildID = 0;
// Check if there is an explicit `remoteType` attribute which we should use. // Check if there is an explicit `remoteType` attribute which we should use.
nsAutoString remoteType;
bool hasRemoteType = bool hasRemoteType =
aOwner->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType, remoteType); aOwner->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType, aRemoteType);
if (!hasRemoteType || remoteType.IsEmpty()) { if (!hasRemoteType || aRemoteType.IsEmpty()) {
hasRemoteType = false; hasRemoteType = false;
aRemoteType = DEFAULT_REMOTE_TYPE; aRemoteType.AssignLiteral(DEFAULT_REMOTE_TYPE);
} else {
aRemoteType = NS_ConvertUTF16toUTF8(remoteType);
} }
// Check if `sameProcessAsFrameLoader` was used to override the process. // Check if `sameProcessAsFrameLoader` was used to override the process.
@ -531,7 +528,7 @@ void nsFrameLoader::LoadFrame(bool aOriginalSrc) {
} }
} }
void nsFrameLoader::ConfigRemoteProcess(const nsACString& aRemoteType, void nsFrameLoader::ConfigRemoteProcess(const nsAString& aRemoteType,
ContentParent* aContentParent) { ContentParent* aContentParent) {
MOZ_DIAGNOSTIC_ASSERT(IsRemoteFrame(), "Must be a remote frame"); MOZ_DIAGNOSTIC_ASSERT(IsRemoteFrame(), "Must be a remote frame");
MOZ_DIAGNOSTIC_ASSERT(!mRemoteBrowser, "Must not have a browser yet"); MOZ_DIAGNOSTIC_ASSERT(!mRemoteBrowser, "Must not have a browser yet");

View File

@ -398,7 +398,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
// `TryRemoteBrowser`, and a script blocker must be on the stack. // `TryRemoteBrowser`, and a script blocker must be on the stack.
// //
// |aContentParent|, if set, must have the remote type |aRemoteType|. // |aContentParent|, if set, must have the remote type |aRemoteType|.
void ConfigRemoteProcess(const nsACString& aRemoteType, void ConfigRemoteProcess(const nsAString& aRemoteType,
mozilla::dom::ContentParent* aContentParent); mozilla::dom::ContentParent* aContentParent);
void MaybeNotifyCrashed(mozilla::dom::BrowsingContext* aBrowsingContext, void MaybeNotifyCrashed(mozilla::dom::BrowsingContext* aBrowsingContext,
@ -515,7 +515,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
RefPtr<mozilla::dom::TabListener> mSessionStoreListener; RefPtr<mozilla::dom::TabListener> mSessionStoreListener;
nsCString mRemoteType; nsString mRemoteType;
bool mDepthTooGreat : 1; bool mDepthTooGreat : 1;
bool mIsTopLevelContent : 1; bool mIsTopLevelContent : 1;

View File

@ -152,7 +152,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameMessageManager) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameMessageManager)
void MessageManagerCallback::DoGetRemoteType(nsACString& aRemoteType, void MessageManagerCallback::DoGetRemoteType(nsAString& aRemoteType,
ErrorResult& aError) const { ErrorResult& aError) const {
aRemoteType.Truncate(); aRemoteType.Truncate();
mozilla::dom::ProcessMessageManager* parent = GetProcessMessageManager(); mozilla::dom::ProcessMessageManager* parent = GetProcessMessageManager();
@ -917,7 +917,7 @@ nsFrameMessageManager::GetProcessMessageManager(ErrorResult& aError) {
return pmm.forget(); return pmm.forget();
} }
void nsFrameMessageManager::GetRemoteType(nsACString& aRemoteType, void nsFrameMessageManager::GetRemoteType(nsAString& aRemoteType,
ErrorResult& aError) const { ErrorResult& aError) const {
aRemoteType.Truncate(); aRemoteType.Truncate();
if (mCallback) { if (mCallback) {

View File

@ -99,7 +99,7 @@ class MessageManagerCallback {
return nullptr; return nullptr;
} }
virtual void DoGetRemoteType(nsACString& aRemoteType, virtual void DoGetRemoteType(nsAString& aRemoteType,
ErrorResult& aError) const; ErrorResult& aError) const;
protected: protected:
@ -178,7 +178,7 @@ class nsFrameMessageManager : public nsIMessageSender {
} }
already_AddRefed<mozilla::dom::ProcessMessageManager> already_AddRefed<mozilla::dom::ProcessMessageManager>
GetProcessMessageManager(mozilla::ErrorResult& aError); GetProcessMessageManager(mozilla::ErrorResult& aError);
void GetRemoteType(nsACString& aRemoteType, void GetRemoteType(nsAString& aRemoteType,
mozilla::ErrorResult& aError) const; mozilla::ErrorResult& aError) const;
// SyncMessageSender // SyncMessageSender

View File

@ -136,7 +136,7 @@ interface CanonicalBrowsingContext : BrowsingContext {
// synchronously create WindowGlobalParent. It can throw if somehow the // synchronously create WindowGlobalParent. It can throw if somehow the
// content process has died. // content process has died.
[Throws] [Throws]
readonly attribute UTF8String? currentRemoteType; readonly attribute DOMString? currentRemoteType;
readonly attribute WindowGlobalParent? embedderWindowGlobal; readonly attribute WindowGlobalParent? embedderWindowGlobal;

View File

@ -555,7 +555,7 @@ dictionary ChildProcInfoDictionary {
sequence<ThreadInfoDictionary> threads = []; sequence<ThreadInfoDictionary> threads = [];
// Firefox info // Firefox info
unsigned long long ChildID = 0; unsigned long long ChildID = 0;
UTF8String origin = ""; DOMString origin = "";
WebIDLProcType type = "web"; WebIDLProcType type = "web";
}; };

View File

@ -46,7 +46,7 @@ dictionary ProcessActorOptions {
* can prefix match remote type either `web` or `webIsolated`. If not passed, * can prefix match remote type either `web` or `webIsolated`. If not passed,
* all content processes are allowed to instantiate the actor. * all content processes are allowed to instantiate the actor.
*/ */
sequence<UTF8String> remoteTypes; sequence<DOMString> remoteTypes;
/** This fields are used for configuring individual sides of the actor. */ /** This fields are used for configuring individual sides of the actor. */
ProcessActorSidedOptions parent; ProcessActorSidedOptions parent;

View File

@ -97,7 +97,7 @@ dictionary WindowActorOptions {
* can prefix match remote type either `web` or `webIsolated`. If not passed, * can prefix match remote type either `web` or `webIsolated`. If not passed,
* all content processes are allowed to instantiate the actor. * all content processes are allowed to instantiate the actor.
*/ */
sequence<UTF8String> remoteTypes; sequence<DOMString> remoteTypes;
/** /**
* An array of MessageManagerGroup values which restrict which type * An array of MessageManagerGroup values which restrict which type

View File

@ -322,7 +322,7 @@ interface mixin MessageSenderMixin {
* Otherwise, it is empty. * Otherwise, it is empty.
*/ */
[Throws] [Throws]
readonly attribute UTF8String remoteType; readonly attribute DOMString remoteType;
}; };
[ChromeOnly, Exposed=Window] [ChromeOnly, Exposed=Window]

View File

@ -45,7 +45,7 @@ interface nsIContentProcessProvider : nsISupports
* nsIContentProcessProvider.NEW_PROCESS to ask the caller to create a new * nsIContentProcessProvider.NEW_PROCESS to ask the caller to create a new
* content process. * content process.
*/ */
int32_t provideProcess(in AUTF8String aType, int32_t provideProcess(in AString aType,
in Array<nsIContentProcessInfo> aAliveProcesses, in Array<nsIContentProcessInfo> aAliveProcesses,
in uint32_t aMaxCount); in uint32_t aMaxCount);
}; };

View File

@ -1653,7 +1653,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetProcessSandbox(
// Use the prefix to avoid URIs from Fission isolated processes. // Use the prefix to avoid URIs from Fission isolated processes.
auto remoteTypePrefix = RemoteTypePrefix(GetRemoteType()); auto remoteTypePrefix = RemoteTypePrefix(GetRemoteType());
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::RemoteType, CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::RemoteType,
remoteTypePrefix); NS_ConvertUTF16toUTF8(remoteTypePrefix));
#endif /* MOZ_SANDBOX */ #endif /* MOZ_SANDBOX */
return IPC_OK(); return IPC_OK();
@ -2568,36 +2568,38 @@ mozilla::ipc::IPCResult ContentChild::RecvAppInfo(
} }
mozilla::ipc::IPCResult ContentChild::RecvRemoteType( mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
const nsCString& aRemoteType) { const nsString& aRemoteType) {
if (!mRemoteType.IsVoid()) { if (!DOMStringIsNull(mRemoteType)) {
// Preallocated processes are type PREALLOC_REMOTE_TYPE; they can become // Preallocated processes are type PREALLOC_REMOTE_TYPE; they can become
// anything except a File: process. // anything except a File: process.
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Changing remoteType of process %d from %s to %s", getpid(), ("Changing remoteType of process %d from %s to %s", getpid(),
mRemoteType.get(), aRemoteType.get())); NS_ConvertUTF16toUTF8(mRemoteType).get(),
NS_ConvertUTF16toUTF8(aRemoteType).get()));
// prealloc->anything (but file) or web->web allowed // prealloc->anything (but file) or web->web allowed
MOZ_RELEASE_ASSERT(aRemoteType != FILE_REMOTE_TYPE && MOZ_RELEASE_ASSERT(!aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE) &&
(mRemoteType == PREALLOC_REMOTE_TYPE || (mRemoteType.EqualsLiteral(PREALLOC_REMOTE_TYPE) ||
(mRemoteType == DEFAULT_REMOTE_TYPE && (mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) &&
aRemoteType == DEFAULT_REMOTE_TYPE))); aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE))));
} else { } else {
// Initial setting of remote type. Either to 'prealloc' or the actual // Initial setting of remote type. Either to 'prealloc' or the actual
// final type (if we didn't use a preallocated process) // final type (if we didn't use a preallocated process)
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Setting remoteType of process %d to %s", getpid(), ("Setting remoteType of process %d to %s", getpid(),
aRemoteType.get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
} }
// Update the process name so about:memory's process names are more obvious. // Update the process name so about:memory's process names are more obvious.
if (aRemoteType == FILE_REMOTE_TYPE) { if (aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE)) {
SetProcessName(u"file:// Content"_ns); SetProcessName(u"file:// Content"_ns);
} else if (aRemoteType == EXTENSION_REMOTE_TYPE) { } else if (aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) {
SetProcessName(u"WebExtensions"_ns); SetProcessName(u"WebExtensions"_ns);
} else if (aRemoteType == PRIVILEGEDABOUT_REMOTE_TYPE) { } else if (aRemoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) {
SetProcessName(u"Privileged Content"_ns); SetProcessName(u"Privileged Content"_ns);
} else if (aRemoteType == LARGE_ALLOCATION_REMOTE_TYPE) { } else if (aRemoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) {
SetProcessName(u"Large Allocation Web Content"_ns); SetProcessName(u"Large Allocation Web Content"_ns);
} else if (RemoteTypePrefix(aRemoteType) == FISSION_WEB_REMOTE_TYPE) { } else if (RemoteTypePrefix(aRemoteType)
.EqualsLiteral(FISSION_WEB_REMOTE_TYPE)) {
SetProcessName(u"Isolated Web Content"_ns); SetProcessName(u"Isolated Web Content"_ns);
} }
// else "prealloc", "web" or "webCOOP+COEP" type -> "Web Content" already set // else "prealloc", "web" or "webCOOP+COEP" type -> "Web Content" already set
@ -2609,7 +2611,7 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
// Call RemoteTypePrefix() on the result to remove URIs if you want to use this // Call RemoteTypePrefix() on the result to remove URIs if you want to use this
// for telemetry. // for telemetry.
const nsACString& ContentChild::GetRemoteType() const { return mRemoteType; } const nsAString& ContentChild::GetRemoteType() const { return mRemoteType; }
mozilla::ipc::IPCResult ContentChild::RecvInitServiceWorkers( mozilla::ipc::IPCResult ContentChild::RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig) { const ServiceWorkerConfiguration& aConfig) {

View File

@ -17,7 +17,6 @@
#include "mozilla/dom/MediaControllerBinding.h" #include "mozilla/dom/MediaControllerBinding.h"
#include "mozilla/dom/PContentChild.h" #include "mozilla/dom/PContentChild.h"
#include "mozilla/dom/RemoteBrowser.h" #include "mozilla/dom/RemoteBrowser.h"
#include "mozilla/dom/RemoteType.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/Shmem.h" #include "mozilla/ipc/Shmem.h"
@ -391,11 +390,11 @@ class ContentChild final : public PContentChild,
const nsCString& UAName, const nsCString& ID, const nsCString& vendor, const nsCString& UAName, const nsCString& ID, const nsCString& vendor,
const nsCString& sourceURL, const nsCString& updateURL); const nsCString& sourceURL, const nsCString& updateURL);
mozilla::ipc::IPCResult RecvRemoteType(const nsCString& aRemoteType); mozilla::ipc::IPCResult RecvRemoteType(const nsString& aRemoteType);
// Call RemoteTypePrefix() on the result to remove URIs if you want to use // Call RemoteTypePrefix() on the result to remove URIs if you want to use
// this for telemetry. // this for telemetry.
const nsACString& GetRemoteType() const override; const nsAString& GetRemoteType() const override;
mozilla::ipc::IPCResult RecvInitServiceWorkers( mozilla::ipc::IPCResult RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig); const ServiceWorkerConfiguration& aConfig);
@ -864,7 +863,7 @@ class ContentChild final : public PContentChild,
AppInfo mAppInfo; AppInfo mAppInfo;
bool mIsForBrowser; bool mIsForBrowser;
nsCString mRemoteType = NOT_REMOTE_TYPE; nsString mRemoteType = VoidString();
bool mIsAlive; bool mIsAlive;
nsString mProcessName; nsString mProcessName;

View File

@ -492,7 +492,7 @@ ContentParentsMemoryReporter::CollectReports(
// processes that are in the Preallocator cache (which would be type // processes that are in the Preallocator cache (which would be type
// 'prealloc'), and recycled processes ('web' and in the future // 'prealloc'), and recycled processes ('web' and in the future
// eTLD+1-locked) processes). // eTLD+1-locked) processes).
nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>* nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>*
ContentParent::sBrowserContentParents; ContentParent::sBrowserContentParents;
namespace { namespace {
@ -570,13 +570,13 @@ ScriptableCPInfo::GetMessageManager(nsISupports** aMessenger) {
return NS_OK; return NS_OK;
} }
ProcessID GetTelemetryProcessID(const nsACString& remoteType) { ProcessID GetTelemetryProcessID(const nsAString& remoteType) {
// OOP WebExtensions run in a content process. // OOP WebExtensions run in a content process.
// For Telemetry though we want to break out collected data from the // For Telemetry though we want to break out collected data from the
// WebExtensions process into a separate bucket, to make sure we can analyze // WebExtensions process into a separate bucket, to make sure we can analyze
// it separately and avoid skewing normal content process metrics. // it separately and avoid skewing normal content process metrics.
return remoteType == EXTENSION_REMOTE_TYPE ? ProcessID::Extension return remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) ? ProcessID::Extension
: ProcessID::Content; : ProcessID::Content;
} }
} // anonymous namespace } // anonymous namespace
@ -638,10 +638,11 @@ static const char* sObserverTopics[] = {
// ContentParent then takes this process back within GetNewOrUsedBrowserProcess. // ContentParent then takes this process back within GetNewOrUsedBrowserProcess.
/*static*/ RefPtr<ContentParent::LaunchPromise> /*static*/ RefPtr<ContentParent::LaunchPromise>
ContentParent::PreallocateProcess() { ContentParent::PreallocateProcess() {
RefPtr<ContentParent> process = new ContentParent(PREALLOC_REMOTE_TYPE); RefPtr<ContentParent> process =
new ContentParent(NS_LITERAL_STRING_FROM_CSTRING(PREALLOC_REMOTE_TYPE));
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Preallocating process of type prealloc")); ("Preallocating process of type " PREALLOC_REMOTE_TYPE));
return process->LaunchSubprocessAsync(PROCESS_PRIORITY_PREALLOC); return process->LaunchSubprocessAsync(PROCESS_PRIORITY_PREALLOC);
} }
@ -687,7 +688,7 @@ void ContentParent::ShutDown() {
} }
/*static*/ /*static*/
uint32_t ContentParent::GetPoolSize(const nsACString& aContentProcessType) { uint32_t ContentParent::GetPoolSize(const nsAString& aContentProcessType) {
if (!sBrowserContentParents) { if (!sBrowserContentParents) {
return 0; return 0;
} }
@ -699,17 +700,17 @@ uint32_t ContentParent::GetPoolSize(const nsACString& aContentProcessType) {
} }
/*static*/ nsTArray<ContentParent*>& ContentParent::GetOrCreatePool( /*static*/ nsTArray<ContentParent*>& ContentParent::GetOrCreatePool(
const nsACString& aContentProcessType) { const nsAString& aContentProcessType) {
if (!sBrowserContentParents) { if (!sBrowserContentParents) {
sBrowserContentParents = sBrowserContentParents =
new nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>; new nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>;
} }
return *sBrowserContentParents->LookupOrAdd(aContentProcessType); return *sBrowserContentParents->LookupOrAdd(aContentProcessType);
} }
const nsDependentCSubstring RemoteTypePrefix( const nsDependentSubstring RemoteTypePrefix(
const nsACString& aContentProcessType) { const nsAString& aContentProcessType) {
// The suffix after a `=` in a remoteType is dynamic, and used to control the // The suffix after a `=` in a remoteType is dynamic, and used to control the
// process pool to use. // process pool to use.
int32_t equalIdx = aContentProcessType.FindChar(L'='); int32_t equalIdx = aContentProcessType.FindChar(L'=');
@ -719,26 +720,28 @@ const nsDependentCSubstring RemoteTypePrefix(
return StringHead(aContentProcessType, equalIdx); return StringHead(aContentProcessType, equalIdx);
} }
bool IsWebRemoteType(const nsACString& aContentProcessType) { bool IsWebRemoteType(const nsAString& aContentProcessType) {
// Note: matches webIsolated as well as web (and webLargeAllocation, and // Note: matches webIsolated as well as web (and webLargeAllocation, and
// webCOOP+COEP) // webCOOP+COEP)
return StringBeginsWith(aContentProcessType, DEFAULT_REMOTE_TYPE); return StringBeginsWith(aContentProcessType,
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
} }
bool IsWebCoopCoepRemoteType(const nsACString& aContentProcessType) { bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType) {
return StringBeginsWith(aContentProcessType, return StringBeginsWith(
WITH_COOP_COEP_REMOTE_TYPE_PREFIX); aContentProcessType,
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
} }
/*static*/ /*static*/
uint32_t ContentParent::GetMaxProcessCount( uint32_t ContentParent::GetMaxProcessCount(
const nsACString& aContentProcessType) { const nsAString& aContentProcessType) {
// Max process count is based only on the prefix. // Max process count is based only on the prefix.
const nsDependentCSubstring processTypePrefix = const nsDependentSubstring processTypePrefix =
RemoteTypePrefix(aContentProcessType); RemoteTypePrefix(aContentProcessType);
// Check for the default remote type of "web", as it uses different prefs. // Check for the default remote type of "web", as it uses different prefs.
if (processTypePrefix == DEFAULT_REMOTE_TYPE) { if (processTypePrefix.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
return GetMaxWebProcessCount(); return GetMaxWebProcessCount();
} }
@ -746,7 +749,7 @@ uint32_t ContentParent::GetMaxProcessCount(
// used as a fallback, as it is intended to control the number of "web" // used as a fallback, as it is intended to control the number of "web"
// content processes, checked in `mozilla::GetMaxWebProcessCount()`. // content processes, checked in `mozilla::GetMaxWebProcessCount()`.
nsAutoCString processCountPref("dom.ipc.processCount."); nsAutoCString processCountPref("dom.ipc.processCount.");
processCountPref.Append(processTypePrefix); AppendUTF16toUTF8(processTypePrefix, processCountPref);
int32_t maxContentParents = Preferences::GetInt(processCountPref.get(), 1); int32_t maxContentParents = Preferences::GetInt(processCountPref.get(), 1);
if (maxContentParents < 1) { if (maxContentParents < 1) {
@ -758,7 +761,7 @@ uint32_t ContentParent::GetMaxProcessCount(
/*static*/ /*static*/
bool ContentParent::IsMaxProcessCountReached( bool ContentParent::IsMaxProcessCountReached(
const nsACString& aContentProcessType) { const nsAString& aContentProcessType) {
return GetPoolSize(aContentProcessType) >= return GetPoolSize(aContentProcessType) >=
GetMaxProcessCount(aContentProcessType); GetMaxProcessCount(aContentProcessType);
} }
@ -778,9 +781,10 @@ void ContentParent::ReleaseCachedProcesses() {
nsTArray<ContentParent*>* contentParents = iter.Data().get(); nsTArray<ContentParent*>* contentParents = iter.Data().get();
num += contentParents->Length(); num += contentParents->Length();
for (auto* cp : *contentParents) { for (auto* cp : *contentParents) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(
("%s: %zu processes", cp->mRemoteType.get(), ContentParent::GetLog(), LogLevel::Debug,
contentParents->Length())); ("%s: %zu processes", NS_ConvertUTF16toUTF8(cp->mRemoteType).get(),
contentParents->Length()));
break; break;
} }
} }
@ -796,12 +800,13 @@ void ContentParent::ReleaseCachedProcesses() {
for (auto* cp : *contentParents) { for (auto* cp : *contentParents) {
if (cp->ManagedPBrowserParent().Count() == 0 && if (cp->ManagedPBrowserParent().Count() == 0 &&
!cp->HasActiveWorkerOrJSPlugin() && !cp->HasActiveWorkerOrJSPlugin() &&
cp->mRemoteType == DEFAULT_REMOTE_TYPE) { cp->mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
toRelease.AppendElement(cp); toRelease.AppendElement(cp);
} else { } else {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
(" Skipping %p (%s), count %d, HasActiveWorkerOrJSPlugin %d", (" Skipping %p (%s), count %d, HasActiveWorkerOrJSPlugin %d",
cp, cp->mRemoteType.get(), cp->ManagedPBrowserParent().Count(), cp, NS_ConvertUTF16toUTF8(cp->mRemoteType).get(),
cp->ManagedPBrowserParent().Count(),
cp->HasActiveWorkerOrJSPlugin())); cp->HasActiveWorkerOrJSPlugin()));
} }
} }
@ -809,7 +814,8 @@ void ContentParent::ReleaseCachedProcesses() {
for (auto* cp : toRelease) { for (auto* cp : toRelease) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
(" Shutdown %p (%s)", cp, cp->mRemoteType.get())); (" Shutdown %p (%s)", cp,
NS_ConvertUTF16toUTF8(cp->mRemoteType).get()));
PreallocatedProcessManager::Erase(cp); PreallocatedProcessManager::Erase(cp);
// Start a soft shutdown. // Start a soft shutdown.
cp->ShutDownProcess(SEND_SHUTDOWN_MESSAGE); cp->ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
@ -857,7 +863,7 @@ already_AddRefed<ContentParent> ContentParent::MinTabSelect(
/*static*/ /*static*/
already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess( already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
const nsACString& aRemoteType, nsTArray<ContentParent*>& aContentParents, const nsAString& aRemoteType, nsTArray<ContentParent*>& aContentParents,
uint32_t aMaxContentParents, bool aPreferUsed) { uint32_t aMaxContentParents, bool aPreferUsed) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
AutoRestore ar(sInProcessSelector); AutoRestore ar(sInProcessSelector);
@ -896,7 +902,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetUsedProcess: Reused process %p (%u) for %s", retval.get(), ("GetUsedProcess: Reused process %p (%u) for %s", retval.get(),
(unsigned int)retval->ChildID(), (unsigned int)retval->ChildID(),
PromiseFlatCString(aRemoteType).get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
retval->AssertAlive(); retval->AssertAlive();
return retval.forget(); return retval.forget();
} }
@ -909,7 +915,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetUsedProcess: Reused random process %p (%d) for %s", ("GetUsedProcess: Reused random process %p (%d) for %s",
random.get(), (unsigned int)random->ChildID(), random.get(), (unsigned int)random->ChildID(),
PromiseFlatCString(aRemoteType).get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
random->AssertAlive(); random->AssertAlive();
return random.forget(); return random.forget();
} }
@ -921,8 +927,8 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
// try to reuse a process that is being shut down. // try to reuse a process that is being shut down.
RefPtr<ContentParent> p; RefPtr<ContentParent> p;
bool preallocated = false; bool preallocated = false;
if (aRemoteType != FILE_REMOTE_TYPE && if (!aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE) &&
aRemoteType != EXTENSION_REMOTE_TYPE && // Bug 1638119 !aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) && // Bug 1638119
(p = PreallocatedProcessManager::Take(aRemoteType)) && (p = PreallocatedProcessManager::Take(aRemoteType)) &&
!p->mShutdownPending) { !p->mShutdownPending) {
p->AssertAlive(); p->AssertAlive();
@ -930,7 +936,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
// p may be a preallocated process, or (if not PREALLOC_REMOTE_TYPE) // p may be a preallocated process, or (if not PREALLOC_REMOTE_TYPE)
// a perviously-used process that's being recycled. Currently this is // a perviously-used process that's being recycled. Currently this is
// only done for short-duration web (DEFAULT_REMOTE_TYPE) processes // only done for short-duration web (DEFAULT_REMOTE_TYPE) processes
preallocated = p->mRemoteType == PREALLOC_REMOTE_TYPE; preallocated = p->mRemoteType.EqualsLiteral(PREALLOC_REMOTE_TYPE);
// For pre-allocated process we have not set the opener yet. // For pre-allocated process we have not set the opener yet.
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (profiler_thread_is_being_profiled()) { if (profiler_thread_is_being_profiled()) {
@ -945,7 +951,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Adopted %s process %p for type %s", ("Adopted %s process %p for type %s",
preallocated ? "preallocated" : "reused web", p.get(), preallocated ? "preallocated" : "reused web", p.get(),
PromiseFlatCString(aRemoteType).get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
p->mActivateTS = TimeStamp::Now(); p->mActivateTS = TimeStamp::Now();
p->AddToPool(aContentParents); p->AddToPool(aContentParents);
if (preallocated) { if (preallocated) {
@ -965,8 +971,8 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
} }
} else { } else {
// we only allow "web" to "web" for security reasons // we only allow "web" to "web" for security reasons
MOZ_RELEASE_ASSERT(p->mRemoteType == DEFAULT_REMOTE_TYPE && MOZ_RELEASE_ASSERT(p->mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) &&
aRemoteType == DEFAULT_REMOTE_TYPE); aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE));
} }
return p.forget(); return p.forget();
} }
@ -976,22 +982,25 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
/*static*/ /*static*/
already_AddRefed<ContentParent> already_AddRefed<ContentParent>
ContentParent::GetNewOrUsedLaunchingBrowserProcess( ContentParent::GetNewOrUsedLaunchingBrowserProcess(Element* aFrameElement,
Element* aFrameElement, const nsACString& aRemoteType, const nsAString& aRemoteType,
ProcessPriority aPriority, bool aPreferUsed) { ProcessPriority aPriority,
bool aPreferUsed) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetNewOrUsedProcess for type %s", ("GetNewOrUsedProcess for type %s",
PromiseFlatCString(aRemoteType).get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
nsTArray<ContentParent*>& contentParents = GetOrCreatePool(aRemoteType); nsTArray<ContentParent*>& contentParents = GetOrCreatePool(aRemoteType);
uint32_t maxContentParents = GetMaxProcessCount(aRemoteType); uint32_t maxContentParents = GetMaxProcessCount(aRemoteType);
// We never want to re-use Large-Allocation processes. if (aRemoteType.EqualsLiteral(
if (aRemoteType == LARGE_ALLOCATION_REMOTE_TYPE && LARGE_ALLOCATION_REMOTE_TYPE) // We never want to re-use
contentParents.Length() >= maxContentParents) { // Large-Allocation processes.
&& contentParents.Length() >= maxContentParents) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetNewOrUsedProcess: returning Large Used process")); ("GetNewOrUsedProcess: returning Large Used process"));
return GetNewOrUsedLaunchingBrowserProcess(aFrameElement, return GetNewOrUsedLaunchingBrowserProcess(
DEFAULT_REMOTE_TYPE, aPriority, aFrameElement, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE),
/*aPreferUsed =*/false); aPriority,
/*aPreferUsed =*/false);
} }
// Let's try and reuse an existing process. // Let's try and reuse an existing process.
@ -1012,7 +1021,7 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(
// The life cycle will be set to `LifecycleState::LAUNCHING`. // The life cycle will be set to `LifecycleState::LAUNCHING`.
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Launching new process immediately for type %s", ("Launching new process immediately for type %s",
PromiseFlatCString(aRemoteType).get())); NS_ConvertUTF16toUTF8(aRemoteType).get()));
contentParent = new ContentParent(aRemoteType); contentParent = new ContentParent(aRemoteType);
if (!contentParent->BeginSubprocessLaunch(aPriority)) { if (!contentParent->BeginSubprocessLaunch(aPriority)) {
@ -1039,7 +1048,7 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(
/*static*/ /*static*/
RefPtr<ContentParent::LaunchPromise> RefPtr<ContentParent::LaunchPromise>
ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement, ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement,
const nsACString& aRemoteType, const nsAString& aRemoteType,
ProcessPriority aPriority, ProcessPriority aPriority,
bool aPreferUsed) { bool aPreferUsed) {
// Obtain a `ContentParent` launched asynchronously. // Obtain a `ContentParent` launched asynchronously.
@ -1054,7 +1063,7 @@ ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement,
/*static*/ /*static*/
already_AddRefed<ContentParent> ContentParent::GetNewOrUsedBrowserProcess( already_AddRefed<ContentParent> ContentParent::GetNewOrUsedBrowserProcess(
Element* aFrameElement, const nsACString& aRemoteType, Element* aFrameElement, const nsAString& aRemoteType,
ProcessPriority aPriority, bool aPreferUsed) { ProcessPriority aPriority, bool aPreferUsed) {
RefPtr<ContentParent> contentParent = GetNewOrUsedLaunchingBrowserProcess( RefPtr<ContentParent> contentParent = GetNewOrUsedLaunchingBrowserProcess(
aFrameElement, aRemoteType, aPriority, aPreferUsed); aFrameElement, aRemoteType, aPriority, aPreferUsed);
@ -1303,7 +1312,7 @@ mozilla::ipc::IPCResult ContentParent::RecvLaunchRDDProcess(
/*static*/ /*static*/
already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser( already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
const TabContext& aContext, Element* aFrameElement, const TabContext& aContext, Element* aFrameElement,
const nsACString& aRemoteType, BrowsingContext* aBrowsingContext, const nsAString& aRemoteType, BrowsingContext* aBrowsingContext,
ContentParent* aOpenerContentParent) { ContentParent* aOpenerContentParent) {
AUTO_PROFILER_LABEL("ContentParent::CreateBrowser", OTHER); AUTO_PROFILER_LABEL("ContentParent::CreateBrowser", OTHER);
@ -1311,9 +1320,9 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
return nullptr; return nullptr;
} }
nsAutoCString remoteType(aRemoteType); nsAutoString remoteType(aRemoteType);
if (remoteType.IsEmpty()) { if (remoteType.IsEmpty()) {
remoteType = DEFAULT_REMOTE_TYPE; remoteType.AssignLiteral(DEFAULT_REMOTE_TYPE);
} }
ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement); ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
@ -1471,7 +1480,7 @@ void ContentParent::BroadcastFontListChanged() {
} }
} }
const nsACString& ContentParent::GetRemoteType() const { return mRemoteType; } const nsAString& ContentParent::GetRemoteType() const { return mRemoteType; }
void ContentParent::Init() { void ContentParent::Init() {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@ -1931,7 +1940,7 @@ void ContentParent::ActorDealloc() { mSelfRef = nullptr; }
bool ContentParent::TryToRecycle() { bool ContentParent::TryToRecycle() {
// We can only do this if we have a separate cache for recycled // We can only do this if we have a separate cache for recycled
// 'web' processes, and handle them differently than webIsolated ones // 'web' processes, and handle them differently than webIsolated ones
if (mRemoteType != DEFAULT_REMOTE_TYPE) { if (!mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
return false; return false;
} }
// This life time check should be replaced by a memory health check (memory // This life time check should be replaced by a memory health check (memory
@ -2017,12 +2026,13 @@ bool ContentParent::ShouldKeepProcessAlive() {
nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive."); nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive.");
if (StringBeginsWith(mRemoteType, FISSION_WEB_REMOTE_TYPE) && if (StringBeginsWith(mRemoteType, NS_LITERAL_STRING_FROM_CSTRING(
FISSION_WEB_REMOTE_TYPE)) &&
xpc::IsInAutomation()) { xpc::IsInAutomation()) {
keepAlivePref.Append(FISSION_WEB_REMOTE_TYPE); keepAlivePref.Append(FISSION_WEB_REMOTE_TYPE);
keepAlivePref.AppendLiteral(".perOrigin"); keepAlivePref.AppendLiteral(".perOrigin");
} else { } else {
keepAlivePref.Append(mRemoteType); keepAlivePref.Append(NS_ConvertUTF16toUTF8(mRemoteType));
} }
if (NS_FAILED( if (NS_FAILED(
Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) { Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) {
@ -2143,7 +2153,7 @@ TestShellParent* ContentParent::GetTestShellSingleton() {
void ContentParent::AppendDynamicSandboxParams( void ContentParent::AppendDynamicSandboxParams(
std::vector<std::string>& aArgs) { std::vector<std::string>& aArgs) {
// For file content processes // For file content processes
if (GetRemoteType() == FILE_REMOTE_TYPE) { if (GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE)) {
MacSandboxInfo::AppendFileAccessParam(aArgs, true); MacSandboxInfo::AppendFileAccessParam(aArgs, true);
} }
} }
@ -2451,7 +2461,7 @@ RefPtr<ContentParent::LaunchPromise> ContentParent::LaunchSubprocessAsync(
}); });
} }
ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID) ContentParent::ContentParent(const nsAString& aRemoteType, int32_t aJSPluginID)
: mSelfRef(nullptr), : mSelfRef(nullptr),
mSubprocess(nullptr), mSubprocess(nullptr),
mLaunchTS(TimeStamp::Now()), mLaunchTS(TimeStamp::Now()),
@ -2500,7 +2510,7 @@ ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
#endif #endif
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
bool isFile = mRemoteType == FILE_REMOTE_TYPE; bool isFile = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE);
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, isFile); mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, isFile);
MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose,
("CreateSubprocess: ContentParent %p mSubprocess %p handle %" PRIuPTR, ("CreateSubprocess: ContentParent %p mSubprocess %p handle %" PRIuPTR,
@ -2807,7 +2817,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
# ifdef XP_LINUX # ifdef XP_LINUX
if (shouldSandbox) { if (shouldSandbox) {
MOZ_ASSERT(!mSandboxBroker); MOZ_ASSERT(!mSandboxBroker);
bool isFileProcess = mRemoteType == FILE_REMOTE_TYPE; bool isFileProcess = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE);
UniquePtr<SandboxBroker::Policy> policy = UniquePtr<SandboxBroker::Policy> policy =
sSandboxBrokerPolicyFactory->GetContentPolicy(Pid(), isFileProcess); sSandboxBrokerPolicyFactory->GetContentPolicy(Pid(), isFileProcess);
if (policy) { if (policy) {
@ -3191,8 +3201,8 @@ ContentParent::GetName(nsAString& aName) {
NS_IMETHODIMP NS_IMETHODIMP
ContentParent::GetState(nsIPropertyBag** aResult) { ContentParent::GetState(nsIPropertyBag** aResult) {
auto props = MakeRefPtr<nsHashPropertyBag>(); auto props = MakeRefPtr<nsHashPropertyBag>();
props->SetPropertyAsACString(u"remoteTypePrefix"_ns, props->SetPropertyAsAString(u"remoteTypePrefix"_ns,
RemoteTypePrefix(mRemoteType)); RemoteTypePrefix(mRemoteType));
*aResult = props.forget().downcast<nsIWritablePropertyBag>().take(); *aResult = props.forget().downcast<nsIWritablePropertyBag>().take();
return NS_OK; return NS_OK;
} }
@ -5228,7 +5238,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
// If we have enough data, check the schemes of the loader and loadee // If we have enough data, check the schemes of the loader and loadee
// to make sure they make sense. // to make sure they make sense.
if (aURIToLoad && aURIToLoad->SchemeIs("file") && if (aURIToLoad && aURIToLoad->SchemeIs("file") &&
GetRemoteType() != FILE_REMOTE_TYPE && !GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE) &&
Preferences::GetBool("browser.tabs.remote.enforceRemoteTypeRestrictions", Preferences::GetBool("browser.tabs.remote.enforceRemoteTypeRestrictions",
false)) { false)) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED

View File

@ -11,7 +11,6 @@
#include "mozilla/dom/ipc/IdType.h" #include "mozilla/dom/ipc/IdType.h"
#include "mozilla/dom/MediaSessionBinding.h" #include "mozilla/dom/MediaSessionBinding.h"
#include "mozilla/dom/RemoteBrowser.h" #include "mozilla/dom/RemoteBrowser.h"
#include "mozilla/dom/RemoteType.h"
#include "mozilla/dom/JSProcessActorParent.h" #include "mozilla/dom/JSProcessActorParent.h"
#include "mozilla/dom/ProcessActor.h" #include "mozilla/dom/ProcessActor.h"
#include "mozilla/gfx/gfxVarReceiver.h" #include "mozilla/gfx/gfxVarReceiver.h"
@ -50,6 +49,22 @@
#define CHILD_PROCESS_SHUTDOWN_MESSAGE u"child-process-shutdown"_ns #define CHILD_PROCESS_SHUTDOWN_MESSAGE u"child-process-shutdown"_ns
// These must match the similar ones in E10SUtils.jsm and ProcInfo.h.
// Process names as reported by about:memory are defined in
// ContentChild:RecvRemoteType. Add your value there too or it will be called
// "Web Content".
#define PREALLOC_REMOTE_TYPE "prealloc"
#define DEFAULT_REMOTE_TYPE "web"
#define FILE_REMOTE_TYPE "file"
#define EXTENSION_REMOTE_TYPE "extension"
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"
// These must start with the DEFAULT_REMOTE_TYPE above.
#define FISSION_WEB_REMOTE_TYPE "webIsolated"
#define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP="
#define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation"
class nsConsoleService; class nsConsoleService;
class nsIContentProcessInfo; class nsIContentProcessInfo;
class nsICycleCollectorLogSink; class nsICycleCollectorLogSink;
@ -164,11 +179,11 @@ class ContentParent final
/** Shut down the content-process machinery. */ /** Shut down the content-process machinery. */
static void ShutDown(); static void ShutDown();
static uint32_t GetPoolSize(const nsACString& aContentProcessType); static uint32_t GetPoolSize(const nsAString& aContentProcessType);
static uint32_t GetMaxProcessCount(const nsACString& aContentProcessType); static uint32_t GetMaxProcessCount(const nsAString& aContentProcessType);
static bool IsMaxProcessCountReached(const nsACString& aContentProcessType); static bool IsMaxProcessCountReached(const nsAString& aContentProcessType);
static void ReleaseCachedProcesses(); static void ReleaseCachedProcesses();
@ -188,12 +203,12 @@ class ContentParent final
* 3. normal iframe * 3. normal iframe
*/ */
static RefPtr<ContentParent::LaunchPromise> GetNewOrUsedBrowserProcessAsync( static RefPtr<ContentParent::LaunchPromise> GetNewOrUsedBrowserProcessAsync(
Element* aFrameElement, const nsACString& aRemoteType, Element* aFrameElement, const nsAString& aRemoteType,
hal::ProcessPriority aPriority = hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND, hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
bool aPreferUsed = false); bool aPreferUsed = false);
static already_AddRefed<ContentParent> GetNewOrUsedBrowserProcess( static already_AddRefed<ContentParent> GetNewOrUsedBrowserProcess(
Element* aFrameElement, const nsACString& aRemoteType, Element* aFrameElement, const nsAString& aRemoteType,
hal::ProcessPriority aPriority = hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND, hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
bool aPreferUsed = false); bool aPreferUsed = false);
@ -209,7 +224,7 @@ class ContentParent final
* the process to be fully launched. * the process to be fully launched.
*/ */
static already_AddRefed<ContentParent> GetNewOrUsedLaunchingBrowserProcess( static already_AddRefed<ContentParent> GetNewOrUsedLaunchingBrowserProcess(
Element* aFrameElement, const nsACString& aRemoteType, Element* aFrameElement, const nsAString& aRemoteType,
hal::ProcessPriority aPriority = hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND, hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
bool aPreferUsed = false); bool aPreferUsed = false);
@ -235,7 +250,7 @@ class ContentParent final
*/ */
static already_AddRefed<RemoteBrowser> CreateBrowser( static already_AddRefed<RemoteBrowser> CreateBrowser(
const TabContext& aContext, Element* aFrameElement, const TabContext& aContext, Element* aFrameElement,
const nsACString& aRemoteType, BrowsingContext* aBrowsingContext, const nsAString& aRemoteType, BrowsingContext* aBrowsingContext,
ContentParent* aOpenerContentParent); ContentParent* aOpenerContentParent);
static void GetAll(nsTArray<ContentParent*>& aArray); static void GetAll(nsTArray<ContentParent*>& aArray);
@ -246,9 +261,9 @@ class ContentParent final
static void BroadcastFontListChanged(); static void BroadcastFontListChanged();
const nsACString& GetRemoteType() const override; const nsAString& GetRemoteType() const override;
virtual void DoGetRemoteType(nsACString& aRemoteType, virtual void DoGetRemoteType(nsAString& aRemoteType,
ErrorResult& aError) const override { ErrorResult& aError) const override {
aRemoteType = GetRemoteType(); aRemoteType = GetRemoteType();
} }
@ -708,7 +723,7 @@ class ContentParent final
* removed from this list, but will still be in the sContentParents list for * removed from this list, but will still be in the sContentParents list for
* the GetAll/GetAllEvenIfDead APIs. * the GetAll/GetAllEvenIfDead APIs.
*/ */
static nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>* static nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>*
sBrowserContentParents; sBrowserContentParents;
static UniquePtr<nsTArray<ContentParent*>> sPrivateContent; static UniquePtr<nsTArray<ContentParent*>> sPrivateContent;
static UniquePtr<nsDataHashtable<nsUint32HashKey, ContentParent*>> static UniquePtr<nsDataHashtable<nsUint32HashKey, ContentParent*>>
@ -739,11 +754,11 @@ class ContentParent final
const OriginAttributes& aOriginAttributes); const OriginAttributes& aOriginAttributes);
explicit ContentParent(int32_t aPluginID) explicit ContentParent(int32_t aPluginID)
: ContentParent(EmptyCString(), aPluginID) {} : ContentParent(EmptyString(), aPluginID) {}
explicit ContentParent(const nsACString& aRemoteType) explicit ContentParent(const nsAString& aRemoteType)
: ContentParent(aRemoteType, nsFakePluginTag::NOT_JSPLUGIN) {} : ContentParent(aRemoteType, nsFakePluginTag::NOT_JSPLUGIN) {}
ContentParent(const nsACString& aRemoteType, int32_t aPluginID); ContentParent(const nsAString& aRemoteType, int32_t aPluginID);
// Launch the subprocess and associated initialization. // Launch the subprocess and associated initialization.
// Returns false if the process fails to start. // Returns false if the process fails to start.
@ -866,7 +881,7 @@ class ContentParent final
* |aContentProcessType|. * |aContentProcessType|.
*/ */
static nsTArray<ContentParent*>& GetOrCreatePool( static nsTArray<ContentParent*>& GetOrCreatePool(
const nsACString& aContentProcessType); const nsAString& aContentProcessType);
mozilla::ipc::IPCResult RecvInitBackground( mozilla::ipc::IPCResult RecvInitBackground(
Endpoint<mozilla::ipc::PBackgroundParent>&& aEndpoint); Endpoint<mozilla::ipc::PBackgroundParent>&& aEndpoint);
@ -1355,7 +1370,7 @@ class ContentParent final
private: private:
// Return an existing ContentParent if possible. Otherwise, `nullptr`. // Return an existing ContentParent if possible. Otherwise, `nullptr`.
static already_AddRefed<ContentParent> GetUsedBrowserProcess( static already_AddRefed<ContentParent> GetUsedBrowserProcess(
const nsACString& aRemoteType, nsTArray<ContentParent*>& aContentParents, const nsAString& aRemoteType, nsTArray<ContentParent*>& aContentParents,
uint32_t aMaxContentParents, bool aPreferUsed); uint32_t aMaxContentParents, bool aPreferUsed);
void AddToPool(nsTArray<ContentParent*>&); void AddToPool(nsTArray<ContentParent*>&);
@ -1379,7 +1394,7 @@ class ContentParent final
bool mIsAPreallocBlocker; // We called AddBlocker for this ContentParent bool mIsAPreallocBlocker; // We called AddBlocker for this ContentParent
nsCString mRemoteType; nsString mRemoteType;
ContentParentId mChildID; ContentParentId mChildID;
int32_t mGeolocationWatchID; int32_t mGeolocationWatchID;
@ -1528,13 +1543,13 @@ class ContentParent final
NS_DEFINE_STATIC_IID_ACCESSOR(ContentParent, NS_CONTENTPARENT_IID) NS_DEFINE_STATIC_IID_ACCESSOR(ContentParent, NS_CONTENTPARENT_IID)
// This is the C++ version of remoteTypePrefix in E10SUtils.jsm. // This is the C++ version of remoteTypePrefix in E10SUtils.jsm.
const nsDependentCSubstring RemoteTypePrefix( const nsDependentSubstring RemoteTypePrefix(
const nsACString& aContentProcessType); const nsAString& aContentProcessType);
// This is based on isWebRemoteType in E10SUtils.jsm. // This is based on isWebRemoteType in E10SUtils.jsm.
bool IsWebRemoteType(const nsACString& aContentProcessType); bool IsWebRemoteType(const nsAString& aContentProcessType);
bool IsWebCoopCoepRemoteType(const nsACString& aContentProcessType); bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType);
inline nsISupports* ToSupports(mozilla::dom::ContentParent* aContentParent) { inline nsISupports* ToSupports(mozilla::dom::ContentParent* aContentParent) {
return static_cast<nsIDOMProcessParent*>(aContentParent); return static_cast<nsIDOMProcessParent*>(aContentParent);

View File

@ -10,7 +10,6 @@
#include "mozilla/dom/PInProcessChild.h" #include "mozilla/dom/PInProcessChild.h"
#include "mozilla/dom/JSProcessActorChild.h" #include "mozilla/dom/JSProcessActorChild.h"
#include "mozilla/dom/ProcessActor.h" #include "mozilla/dom/ProcessActor.h"
#include "mozilla/dom/RemoteType.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "nsIDOMProcessChild.h" #include "nsIDOMProcessChild.h"
@ -46,7 +45,7 @@ class InProcessChild final : public nsIDOMProcessChild,
// |nullptr|. // |nullptr|.
static IProtocol* ParentActorFor(IProtocol* aActor); static IProtocol* ParentActorFor(IProtocol* aActor);
const nsACString& GetRemoteType() const override { return NOT_REMOTE_TYPE; } const nsAString& GetRemoteType() const override { return VoidString(); }
protected: protected:
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor, already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,

View File

@ -10,7 +10,6 @@
#include "mozilla/dom/PInProcessParent.h" #include "mozilla/dom/PInProcessParent.h"
#include "mozilla/dom/JSProcessActorParent.h" #include "mozilla/dom/JSProcessActorParent.h"
#include "mozilla/dom/ProcessActor.h" #include "mozilla/dom/ProcessActor.h"
#include "mozilla/dom/RemoteType.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "nsIDOMProcessParent.h" #include "nsIDOMProcessParent.h"
@ -48,7 +47,7 @@ class InProcessParent final : public nsIDOMProcessParent,
// |nullptr|. // |nullptr|.
static IProtocol* ChildActorFor(IProtocol* aActor); static IProtocol* ChildActorFor(IProtocol* aActor);
const nsACString& GetRemoteType() const override { return NOT_REMOTE_TYPE; }; const nsAString& GetRemoteType() const override { return VoidString(); };
protected: protected:
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor, already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,

View File

@ -259,7 +259,7 @@ struct JSWindowActorInfo
// Observer notifications this actor listens to. // Observer notifications this actor listens to.
nsCString[] observers; nsCString[] observers;
nsString[] matches; nsString[] matches;
nsCString[] remoteTypes; nsString[] remoteTypes;
nsString[] messageManagerGroups; nsString[] messageManagerGroups;
}; };
@ -272,7 +272,7 @@ struct JSProcessActorInfo
// Observer notifications this actor listens to. // Observer notifications this actor listens to.
nsCString[] observers; nsCString[] observers;
nsCString[] remoteTypes; nsString[] remoteTypes;
}; };
struct GMPAPITags struct GMPAPITags
@ -636,7 +636,7 @@ child:
/** /**
* Send the remote type associated with the content process. * Send the remote type associated with the content process.
*/ */
async RemoteType(nsCString aRemoteType); async RemoteType(nsString aRemoteType);
/** /**
* Send ServiceWorkerRegistrationData to child process. * Send ServiceWorkerRegistrationData to child process.

View File

@ -37,7 +37,7 @@ class PreallocatedProcessManagerImpl final : public nsIObserver {
// See comments on PreallocatedProcessManager for these methods. // See comments on PreallocatedProcessManager for these methods.
void AddBlocker(ContentParent* aParent); void AddBlocker(ContentParent* aParent);
void RemoveBlocker(ContentParent* aParent); void RemoveBlocker(ContentParent* aParent);
already_AddRefed<ContentParent> Take(const nsACString& aRemoteType); already_AddRefed<ContentParent> Take(const nsAString& aRemoteType);
bool Provide(ContentParent* aParent); bool Provide(ContentParent* aParent);
void Erase(ContentParent* aParent); void Erase(ContentParent* aParent);
@ -190,17 +190,17 @@ void PreallocatedProcessManagerImpl::RereadPrefs() {
} }
already_AddRefed<ContentParent> PreallocatedProcessManagerImpl::Take( already_AddRefed<ContentParent> PreallocatedProcessManagerImpl::Take(
const nsACString& aRemoteType) { const nsAString& aRemoteType) {
if (!mEnabled || sShutdown) { if (!mEnabled || sShutdown) {
return nullptr; return nullptr;
} }
RefPtr<ContentParent> process; RefPtr<ContentParent> process;
if (aRemoteType == DEFAULT_REMOTE_TYPE) { if (aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) {
// we can recycle processes via Provide() for e10s only // we can recycle processes via Provide() for e10s only
process = mPreallocatedE10SProcess.forget(); process = mPreallocatedE10SProcess.forget();
if (process) { if (process) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Reuse web process %p", process.get())); ("Reuse " DEFAULT_REMOTE_TYPE " process %p", process.get()));
} }
} }
if (!process && !mPreallocatedProcesses.empty()) { if (!process && !mPreallocatedProcesses.empty()) {
@ -210,7 +210,7 @@ already_AddRefed<ContentParent> PreallocatedProcessManagerImpl::Take(
// soon. // soon.
AllocateOnIdle(); AllocateOnIdle();
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Use prealloc process %p", process.get())); ("Use " PREALLOC_REMOTE_TYPE " process %p", process.get()));
} }
if (process) { if (process) {
ProcessPriorityManager::SetProcessPriority(process, ProcessPriorityManager::SetProcessPriority(process,
@ -220,14 +220,15 @@ already_AddRefed<ContentParent> PreallocatedProcessManagerImpl::Take(
} }
bool PreallocatedProcessManagerImpl::Provide(ContentParent* aParent) { bool PreallocatedProcessManagerImpl::Provide(ContentParent* aParent) {
MOZ_DIAGNOSTIC_ASSERT(aParent->GetRemoteType() == DEFAULT_REMOTE_TYPE); MOZ_DIAGNOSTIC_ASSERT(
aParent->GetRemoteType().EqualsLiteral(DEFAULT_REMOTE_TYPE));
// This will take the already-running process even if there's a // This will take the already-running process even if there's a
// launch in progress; if that process hasn't been taken by the // launch in progress; if that process hasn't been taken by the
// time the launch completes, the new process will be shut down. // time the launch completes, the new process will be shut down.
if (mEnabled && !sShutdown && !mPreallocatedE10SProcess) { if (mEnabled && !sShutdown && !mPreallocatedE10SProcess) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Store for reuse web process %p", aParent)); ("Store for reuse " DEFAULT_REMOTE_TYPE " process %p", aParent));
ProcessPriorityManager::SetProcessPriority(aParent, ProcessPriorityManager::SetProcessPriority(aParent,
PROCESS_PRIORITY_BACKGROUND); PROCESS_PRIORITY_BACKGROUND);
mPreallocatedE10SProcess = aParent; mPreallocatedE10SProcess = aParent;
@ -299,7 +300,8 @@ bool PreallocatedProcessManagerImpl::CanAllocate() {
return mEnabled && sNumBlockers == 0 && return mEnabled && sNumBlockers == 0 &&
mPreallocatedProcesses.size() < mNumberPreallocs && !sShutdown && mPreallocatedProcesses.size() < mNumberPreallocs && !sShutdown &&
(FissionAutostart() || (FissionAutostart() ||
!ContentParent::IsMaxProcessCountReached(DEFAULT_REMOTE_TYPE)); !ContentParent::IsMaxProcessCountReached(
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)));
} }
void PreallocatedProcessManagerImpl::AllocateAfterDelay() { void PreallocatedProcessManagerImpl::AllocateAfterDelay() {
@ -400,11 +402,11 @@ PreallocatedProcessManager::GetPPMImpl() {
} }
/* static */ /* static */
void PreallocatedProcessManager::AddBlocker(const nsACString& aRemoteType, void PreallocatedProcessManager::AddBlocker(const nsAString& aRemoteType,
ContentParent* aParent) { ContentParent* aParent) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("AddBlocker: %s %p (sNumBlockers=%d)", ("AddBlocker: %s %p (sNumBlockers=%d)",
PromiseFlatCString(aRemoteType).get(), aParent, NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent,
PreallocatedProcessManagerImpl::sNumBlockers)); PreallocatedProcessManagerImpl::sNumBlockers));
if (auto impl = GetPPMImpl()) { if (auto impl = GetPPMImpl()) {
impl->AddBlocker(aParent); impl->AddBlocker(aParent);
@ -412,11 +414,11 @@ void PreallocatedProcessManager::AddBlocker(const nsACString& aRemoteType,
} }
/* static */ /* static */
void PreallocatedProcessManager::RemoveBlocker(const nsACString& aRemoteType, void PreallocatedProcessManager::RemoveBlocker(const nsAString& aRemoteType,
ContentParent* aParent) { ContentParent* aParent) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("RemoveBlocker: %s %p (sNumBlockers=%d)", ("RemoveBlocker: %s %p (sNumBlockers=%d)",
PromiseFlatCString(aRemoteType).get(), aParent, NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent,
PreallocatedProcessManagerImpl::sNumBlockers)); PreallocatedProcessManagerImpl::sNumBlockers));
if (auto impl = GetPPMImpl()) { if (auto impl = GetPPMImpl()) {
impl->RemoveBlocker(aParent); impl->RemoveBlocker(aParent);
@ -425,7 +427,7 @@ void PreallocatedProcessManager::RemoveBlocker(const nsACString& aRemoteType,
/* static */ /* static */
already_AddRefed<ContentParent> PreallocatedProcessManager::Take( already_AddRefed<ContentParent> PreallocatedProcessManager::Take(
const nsACString& aRemoteType) { const nsAString& aRemoteType) {
if (auto impl = GetPPMImpl()) { if (auto impl = GetPPMImpl()) {
return impl->Take(aRemoteType); return impl->Take(aRemoteType);
} }

View File

@ -42,8 +42,8 @@ class PreallocatedProcessManager final {
* background. To avoid that, the PreallocatedProcessManager won't start up * background. To avoid that, the PreallocatedProcessManager won't start up
* any processes while there is a blocker active. * any processes while there is a blocker active.
*/ */
static void AddBlocker(const nsACString& aRemoteType, ContentParent* aParent); static void AddBlocker(const nsAString& aRemoteType, ContentParent* aParent);
static void RemoveBlocker(const nsACString& aRemoteType, static void RemoveBlocker(const nsAString& aRemoteType,
ContentParent* aParent); ContentParent* aParent);
/** /**
@ -56,7 +56,7 @@ class PreallocatedProcessManager final {
* If we use a preallocated process, it will schedule the start of * If we use a preallocated process, it will schedule the start of
* another on Idle (AllocateOnIdle()). * another on Idle (AllocateOnIdle()).
*/ */
static already_AddRefed<ContentParent> Take(const nsACString& aRemoteType); static already_AddRefed<ContentParent> Take(const nsAString& aRemoteType);
/** /**
* Cache a process (currently only DEFAULT_REMOTE_TYPE) for reuse later * Cache a process (currently only DEFAULT_REMOTE_TYPE) for reuse later

View File

@ -28,7 +28,7 @@ class ProcessActor : public JSActorManager {
JSActorService* aActorSvc, const nsACString& aName, JSActorService* aActorSvc, const nsACString& aName,
ErrorResult& aRv) final; ErrorResult& aRv) final;
virtual const nsACString& GetRemoteType() const = 0; virtual const nsAString& GetRemoteType() const = 0;
}; };
} // namespace dom } // namespace dom

View File

@ -734,7 +734,7 @@ ProcessPriority ParticularProcessPriorityManager::CurrentPriority() {
ProcessPriority ParticularProcessPriorityManager::ComputePriority() { ProcessPriority ParticularProcessPriorityManager::ComputePriority() {
if (!mActiveBrowserParents.IsEmpty() || if (!mActiveBrowserParents.IsEmpty() ||
mContentParent->GetRemoteType() == EXTENSION_REMOTE_TYPE || mContentParent->GetRemoteType().EqualsLiteral(EXTENSION_REMOTE_TYPE) ||
mHoldsPlayingAudioWakeLock) { mHoldsPlayingAudioWakeLock) {
return PROCESS_PRIORITY_FOREGROUND; return PROCESS_PRIORITY_FOREGROUND;
} }

View File

@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_dom_RemoteType_h
#define mozilla_dom_RemoteType_h
#include "nsString.h"
#include "nsReadableUtils.h"
// These must match the similar ones in E10SUtils.jsm and ProcInfo.h.
// Process names as reported by about:memory are defined in
// ContentChild:RecvRemoteType. Add your value there too or it will be called
// "Web Content".
#define PREALLOC_REMOTE_TYPE "prealloc"_ns
#define DEFAULT_REMOTE_TYPE "web"_ns
#define FILE_REMOTE_TYPE "file"_ns
#define EXTENSION_REMOTE_TYPE "extension"_ns
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
// These must start with the DEFAULT_REMOTE_TYPE above.
#define FISSION_WEB_REMOTE_TYPE "webIsolated"_ns
#define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP="_ns
#define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation"_ns
// Remote type value used to represent being non-remote.
#define NOT_REMOTE_TYPE VoidCString()
#endif // mozilla_dom_RemoteType_h

View File

@ -40,7 +40,7 @@ class WindowGlobalActor : public JSActorManager {
ErrorResult& aRv) final; ErrorResult& aRv) final;
virtual nsIURI* GetDocumentURI() = 0; virtual nsIURI* GetDocumentURI() = 0;
virtual const nsACString& GetRemoteType() = 0; virtual const nsAString& GetRemoteType() = 0;
virtual dom::BrowsingContext* BrowsingContext() = 0; virtual dom::BrowsingContext* BrowsingContext() = 0;
static WindowGlobalInit BaseInitializer( static WindowGlobalInit BaseInitializer(

View File

@ -359,7 +359,7 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvMakeFrameLocal(
// Trigger a process switch into the current process. // Trigger a process switch into the current process.
RemotenessOptions options; RemotenessOptions options;
options.mRemoteType = NOT_REMOTE_TYPE; options.mRemoteType.Assign(VoidString());
options.mPendingSwitchID.Construct(aPendingSwitchId); options.mPendingSwitchID.Construct(aPendingSwitchId);
options.mSwitchingInProgressLoad = true; options.mSwitchingInProgressLoad = true;
flo->ChangeRemoteness(options, IgnoreErrors()); flo->ChangeRemoteness(options, IgnoreErrors());
@ -573,12 +573,12 @@ void WindowGlobalChild::SetDocumentPrincipal(
SendUpdateDocumentPrincipal(aNewDocumentPrincipal); SendUpdateDocumentPrincipal(aNewDocumentPrincipal);
} }
const nsACString& WindowGlobalChild::GetRemoteType() { const nsAString& WindowGlobalChild::GetRemoteType() {
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
return ContentChild::GetSingleton()->GetRemoteType(); return ContentChild::GetSingleton()->GetRemoteType();
} }
return NOT_REMOTE_TYPE; return VoidString();
} }
already_AddRefed<JSWindowActorChild> WindowGlobalChild::GetActor( already_AddRefed<JSWindowActorChild> WindowGlobalChild::GetActor(

View File

@ -111,7 +111,7 @@ class WindowGlobalChild final : public WindowGlobalActor,
JS::Handle<JSObject*> aGivenProto) override; JS::Handle<JSObject*> aGivenProto) override;
protected: protected:
const nsACString& GetRemoteType() override; const nsAString& GetRemoteType() override;
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor, already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,
const nsACString& aName, const nsACString& aName,

View File

@ -425,12 +425,12 @@ IPCResult WindowGlobalParent::RecvRawMessage(const JSActorMessageMeta& aMeta,
return IPC_OK(); return IPC_OK();
} }
const nsACString& WindowGlobalParent::GetRemoteType() { const nsAString& WindowGlobalParent::GetRemoteType() {
if (RefPtr<BrowserParent> browserParent = GetBrowserParent()) { if (RefPtr<BrowserParent> browserParent = GetBrowserParent()) {
return browserParent->Manager()->GetRemoteType(); return browserParent->Manager()->GetRemoteType();
} }
return NOT_REMOTE_TYPE; return VoidString();
} }
void WindowGlobalParent::NotifyContentBlockingEvent( void WindowGlobalParent::NotifyContentBlockingEvent(

View File

@ -194,7 +194,7 @@ class WindowGlobalParent final : public WindowContext,
nsITransportSecurityInfo* GetSecurityInfo() { return mSecurityInfo; } nsITransportSecurityInfo* GetSecurityInfo() { return mSecurityInfo; }
const nsACString& GetRemoteType() override; const nsAString& GetRemoteType() override;
protected: protected:
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor, already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,

View File

@ -19,7 +19,7 @@ int FuzzingInitContentParentIPC(int* argc, char*** argv) { return 0; }
static int RunContentParentIPCFuzzing(const uint8_t* data, size_t size) { static int RunContentParentIPCFuzzing(const uint8_t* data, size_t size) {
static mozilla::dom::ContentParent* p = static mozilla::dom::ContentParent* p =
mozilla::ipc::ProtocolFuzzerHelper::CreateContentParent( mozilla::ipc::ProtocolFuzzerHelper::CreateContentParent(
DEFAULT_REMOTE_TYPE); NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
static nsTArray<nsCString> ignored = mozilla::ipc::LoadIPCMessageBlacklist( static nsTArray<nsCString> ignored = mozilla::ipc::LoadIPCMessageBlacklist(
getenv("MOZ_IPC_MESSAGE_FUZZ_BLACKLIST")); getenv("MOZ_IPC_MESSAGE_FUZZ_BLACKLIST"));

View File

@ -121,7 +121,7 @@ void JSProcessActorProtocol::RemoveObservers() {
} }
bool JSProcessActorProtocol::RemoteTypePrefixMatches( bool JSProcessActorProtocol::RemoteTypePrefixMatches(
const nsDependentCSubstring& aRemoteType) { const nsDependentSubstring& aRemoteType) {
for (auto& remoteType : mRemoteTypes) { for (auto& remoteType : mRemoteTypes) {
if (StringBeginsWith(aRemoteType, remoteType)) { if (StringBeginsWith(aRemoteType, remoteType)) {
return true; return true;
@ -130,7 +130,7 @@ bool JSProcessActorProtocol::RemoteTypePrefixMatches(
return false; return false;
} }
bool JSProcessActorProtocol::Matches(const nsACString& aRemoteType) { bool JSProcessActorProtocol::Matches(const nsAString& aRemoteType) {
if (!mRemoteTypes.IsEmpty() && if (!mRemoteTypes.IsEmpty() &&
!RemoteTypePrefixMatches(RemoteTypePrefix(aRemoteType))) { !RemoteTypePrefixMatches(RemoteTypePrefix(aRemoteType))) {
return false; return false;

View File

@ -54,15 +54,15 @@ class JSProcessActorProtocol final : public JSActorProtocol,
void AddObservers(); void AddObservers();
void RemoveObservers(); void RemoveObservers();
bool Matches(const nsACString& aRemoteType); bool Matches(const nsAString& aRemoteType);
private: private:
explicit JSProcessActorProtocol(const nsACString& aName) : mName(aName) {} explicit JSProcessActorProtocol(const nsACString& aName) : mName(aName) {}
bool RemoteTypePrefixMatches(const nsDependentCSubstring& aRemoteType); bool RemoteTypePrefixMatches(const nsDependentSubstring& aRemoteType);
~JSProcessActorProtocol() = default; ~JSProcessActorProtocol() = default;
nsCString mName; nsCString mName;
nsTArray<nsCString> mRemoteTypes; nsTArray<nsString> mRemoteTypes;
ParentSide mParent; ParentSide mParent;
ChildSide mChild; ChildSide mChild;

View File

@ -295,7 +295,7 @@ extensions::MatchPatternSet* JSWindowActorProtocol::GetURIMatcher() {
} }
bool JSWindowActorProtocol::RemoteTypePrefixMatches( bool JSWindowActorProtocol::RemoteTypePrefixMatches(
const nsDependentCSubstring& aRemoteType) { const nsDependentSubstring& aRemoteType) {
for (auto& remoteType : mRemoteTypes) { for (auto& remoteType : mRemoteTypes) {
if (StringBeginsWith(aRemoteType, remoteType)) { if (StringBeginsWith(aRemoteType, remoteType)) {
return true; return true;
@ -317,7 +317,7 @@ bool JSWindowActorProtocol::MessageManagerGroupMatches(
bool JSWindowActorProtocol::Matches(BrowsingContext* aBrowsingContext, bool JSWindowActorProtocol::Matches(BrowsingContext* aBrowsingContext,
nsIURI* aURI, nsIURI* aURI,
const nsACString& aRemoteType) { const nsAString& aRemoteType) {
MOZ_ASSERT(aBrowsingContext, "DocShell without a BrowsingContext!"); MOZ_ASSERT(aBrowsingContext, "DocShell without a BrowsingContext!");
MOZ_ASSERT(aURI, "Must have URI!"); MOZ_ASSERT(aURI, "Must have URI!");

View File

@ -70,12 +70,12 @@ class JSWindowActorProtocol final : public JSActorProtocol,
void AddObservers(); void AddObservers();
void RemoveObservers(); void RemoveObservers();
bool Matches(BrowsingContext* aBrowsingContext, nsIURI* aURI, bool Matches(BrowsingContext* aBrowsingContext, nsIURI* aURI,
const nsACString& aRemoteType); const nsAString& aRemoteType);
private: private:
explicit JSWindowActorProtocol(const nsACString& aName) : mName(aName) {} explicit JSWindowActorProtocol(const nsACString& aName) : mName(aName) {}
extensions::MatchPatternSet* GetURIMatcher(); extensions::MatchPatternSet* GetURIMatcher();
bool RemoteTypePrefixMatches(const nsDependentCSubstring& aRemoteType); bool RemoteTypePrefixMatches(const nsDependentSubstring& aRemoteType);
bool MessageManagerGroupMatches(BrowsingContext* aBrowsingContext); bool MessageManagerGroupMatches(BrowsingContext* aBrowsingContext);
~JSWindowActorProtocol() = default; ~JSWindowActorProtocol() = default;
@ -83,7 +83,7 @@ class JSWindowActorProtocol final : public JSActorProtocol,
bool mAllFrames = false; bool mAllFrames = false;
bool mIncludeChrome = false; bool mIncludeChrome = false;
nsTArray<nsString> mMatches; nsTArray<nsString> mMatches;
nsTArray<nsCString> mRemoteTypes; nsTArray<nsString> mRemoteTypes;
nsTArray<nsString> mMessageManagerGroups; nsTArray<nsString> mMessageManagerGroups;
ParentSide mParent; ParentSide mParent;

View File

@ -60,7 +60,6 @@ EXPORTS.mozilla.dom += [
'ReferrerInfoUtils.h', 'ReferrerInfoUtils.h',
'RefMessageBodyService.h', 'RefMessageBodyService.h',
'RemoteBrowser.h', 'RemoteBrowser.h',
'RemoteType.h',
'RemoteWebProgress.h', 'RemoteWebProgress.h',
'RemoteWebProgressRequest.h', 'RemoteWebProgressRequest.h',
'SharedMessageBody.h', 'SharedMessageBody.h',

View File

@ -103,7 +103,8 @@ nsresult PushNotifier::Dispatch(PushDispatcher& aDispatcher) {
// remote type is acceptable. This should not run when Fission is // remote type is acceptable. This should not run when Fission is
// enabled, and we specifically don't want this for // enabled, and we specifically don't want this for
// LARGE_ALLOCATION_REMOTE_TYPE, so don't use IsWebRemoteType(). // LARGE_ALLOCATION_REMOTE_TYPE, so don't use IsWebRemoteType().
if (contentActors[i]->GetRemoteType() != DEFAULT_REMOTE_TYPE) { if (!contentActors[i]->GetRemoteType().EqualsLiteral(
DEFAULT_REMOTE_TYPE)) {
continue; continue;
} }

View File

@ -5,7 +5,7 @@
*/ */
dictionary RemotenessOptions { dictionary RemotenessOptions {
required UTF8String? remoteType; required DOMString? remoteType;
// Used to resume a given channel load within the target process. If present, // Used to resume a given channel load within the target process. If present,
// it will be used rather than the `src` & `srcdoc` attributes on the // it will be used rather than the `src` & `srcdoc` attributes on the

View File

@ -60,8 +60,8 @@ void TransmitPermissionsAndBlobURLsForPrincipalInfo(
} // namespace } // namespace
// static // static
bool RemoteWorkerManager::MatchRemoteType(const nsACString& processRemoteType, bool RemoteWorkerManager::MatchRemoteType(const nsAString& processRemoteType,
const nsACString& workerRemoteType) { const nsAString& workerRemoteType) {
if (processRemoteType.Equals(workerRemoteType)) { if (processRemoteType.Equals(workerRemoteType)) {
return true; return true;
} }
@ -89,7 +89,7 @@ bool RemoteWorkerManager::MatchRemoteType(const nsACString& processRemoteType,
} }
// static // static
Result<nsCString, nsresult> RemoteWorkerManager::GetRemoteType( Result<nsString, nsresult> RemoteWorkerManager::GetRemoteType(
const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType) { const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType) {
AssertIsOnMainThread(); AssertIsOnMainThread();
@ -100,7 +100,7 @@ Result<nsCString, nsresult> RemoteWorkerManager::GetRemoteType(
return Err(NS_ERROR_UNEXPECTED); return Err(NS_ERROR_UNEXPECTED);
} }
nsCString remoteType = NOT_REMOTE_TYPE; nsString remoteType;
// If Gecko is running in single process mode, there is no child process // If Gecko is running in single process mode, there is no child process
// to select, return without assigning any remoteType. // to select, return without assigning any remoteType.
@ -131,21 +131,23 @@ Result<nsCString, nsresult> RemoteWorkerManager::GetRemoteType(
"browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", false); "browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", false);
if (isMozExtension) { if (isMozExtension) {
remoteType = EXTENSION_REMOTE_TYPE; remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE));
} else if (separatePrivilegedMozilla) { } else if (separatePrivilegedMozilla) {
bool isPrivilegedMozilla = false; bool isPrivilegedMozilla = false;
aPrincipal->IsURIInPrefList("browser.tabs.remote.separatedMozillaDomains", aPrincipal->IsURIInPrefList("browser.tabs.remote.separatedMozillaDomains",
&isPrivilegedMozilla); &isPrivilegedMozilla);
if (isPrivilegedMozilla) { if (isPrivilegedMozilla) {
remoteType = PRIVILEGEDMOZILLA_REMOTE_TYPE; remoteType.Assign(
} else if (aWorkerType == WorkerType::WorkerTypeShared && contentChild) { NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE));
remoteType = contentChild->GetRemoteType();
} else { } else {
remoteType = DEFAULT_REMOTE_TYPE; remoteType.Assign(
aWorkerType == WorkerType::WorkerTypeShared && contentChild
? contentChild->GetRemoteType()
: NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
} }
} else { } else {
remoteType = DEFAULT_REMOTE_TYPE; remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
} }
return remoteType; return remoteType;
@ -347,7 +349,7 @@ void RemoteWorkerManager::AsyncCreationFailed(
} }
/* static */ /* static */
nsCString RemoteWorkerManager::GetRemoteTypeForActor( nsString RemoteWorkerManager::GetRemoteTypeForActor(
const RemoteWorkerServiceParent* aActor) { const RemoteWorkerServiceParent* aActor) {
AssertIsInMainProcess(); AssertIsInMainProcess();
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
@ -360,10 +362,10 @@ nsCString RemoteWorkerManager::GetRemoteTypeForActor(
MakeScopeExit([&] { NS_ReleaseOnMainThread(contentParent.forget()); }); MakeScopeExit([&] { NS_ReleaseOnMainThread(contentParent.forget()); });
if (NS_WARN_IF(!contentParent)) { if (NS_WARN_IF(!contentParent)) {
return EmptyCString(); return EmptyString();
} }
nsCString aRemoteType(contentParent->GetRemoteType()); nsString aRemoteType(contentParent->GetRemoteType());
return aRemoteType; return aRemoteType;
} }
@ -549,7 +551,7 @@ void RemoteWorkerManager::LaunchNewContentProcess(
bgEventTarget = std::move(bgEventTarget), bgEventTarget = std::move(bgEventTarget),
self = RefPtr<RemoteWorkerManager>(this)]( self = RefPtr<RemoteWorkerManager>(this)](
const CallbackParamType& aValue, const CallbackParamType& aValue,
const nsCString& remoteType) mutable { const nsString& remoteType) mutable {
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
if (isServiceWorker) { if (isServiceWorker) {
TransmitPermissionsAndBlobURLsForPrincipalInfo(aValue.ResolveValue(), TransmitPermissionsAndBlobURLsForPrincipalInfo(aValue.ResolveValue(),
@ -586,7 +588,9 @@ void RemoteWorkerManager::LaunchNewContentProcess(
__func__, [callback = std::move(processLaunchCallback), __func__, [callback = std::move(processLaunchCallback),
workerRemoteType = aData.remoteType()]() mutable { workerRemoteType = aData.remoteType()]() mutable {
auto remoteType = auto remoteType =
workerRemoteType.IsEmpty() ? DEFAULT_REMOTE_TYPE : workerRemoteType; workerRemoteType.IsEmpty()
? NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)
: workerRemoteType;
ContentParent::GetNewOrUsedBrowserProcessAsync( ContentParent::GetNewOrUsedBrowserProcessAsync(
/* aFrameElement = */ nullptr, /* aFrameElement = */ nullptr,

View File

@ -35,14 +35,14 @@ class RemoteWorkerManager final {
void Launch(RemoteWorkerController* aController, void Launch(RemoteWorkerController* aController,
const RemoteWorkerData& aData, base::ProcessId aProcessId); const RemoteWorkerData& aData, base::ProcessId aProcessId);
static bool MatchRemoteType(const nsACString& processRemoteType, static bool MatchRemoteType(const nsAString& processRemoteType,
const nsACString& workerRemoteType); const nsAString& workerRemoteType);
/** /**
* Get the child process RemoteType where a RemoteWorker should be * Get the child process RemoteType where a RemoteWorker should be
* launched. * launched.
*/ */
static Result<nsCString, nsresult> GetRemoteType( static Result<nsString, nsresult> GetRemoteType(
const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType); const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType);
/** /**
@ -73,7 +73,7 @@ class RemoteWorkerManager final {
void AsyncCreationFailed(RemoteWorkerController* aController); void AsyncCreationFailed(RemoteWorkerController* aController);
static nsCString GetRemoteTypeForActor( static nsString GetRemoteTypeForActor(
const RemoteWorkerServiceParent* aActor); const RemoteWorkerServiceParent* aActor);
// Iterate through all RemoteWorkerServiceParent actors, starting from a // Iterate through all RemoteWorkerServiceParent actors, starting from a

View File

@ -72,7 +72,7 @@ struct RemoteWorkerData
nsID agentClusterId; nsID agentClusterId;
// Child process remote type where the worker should only run on. // Child process remote type where the worker should only run on.
nsCString remoteType; nsString remoteType;
}; };
// ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote // ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote

View File

@ -12,39 +12,54 @@ using namespace mozilla::dom;
TEST(RemoteWorkerManager, TestMatchRemoteType) TEST(RemoteWorkerManager, TestMatchRemoteType)
{ {
static const struct { static const struct {
const nsCString processRemoteType; const nsString processRemoteType;
const nsCString workerRemoteType; const nsString workerRemoteType;
const bool shouldMatch; const bool shouldMatch;
} tests[] = { } tests[] = {
// Test exact matches between process and worker remote types. // Test exact matches between process and worker remote types.
{DEFAULT_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true}, {NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE),
{EXTENSION_REMOTE_TYPE, EXTENSION_REMOTE_TYPE, true}, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
{PRIVILEGEDMOZILLA_REMOTE_TYPE, PRIVILEGEDMOZILLA_REMOTE_TYPE, true}, {NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE), true},
// Test workers with remoteType "web" not launched on non-web or coop+coep // Test workers with remoteType "web" not launched on non-web or coop+coep
// processes. // processes.
{PRIVILEGEDMOZILLA_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false}, {NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
{PRIVILEGEDABOUT_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false}, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{EXTENSION_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false}, {NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDABOUT_REMOTE_TYPE),
{FILE_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false}, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{WITH_COOP_COEP_REMOTE_TYPE_PREFIX, DEFAULT_REMOTE_TYPE, false}, {NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(FILE_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
// Test workers with remoteType "web" launched in web child processes. // Test workers with remoteType "web" launched in web child processes.
{LARGE_ALLOCATION_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true}, {NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE),
{FISSION_WEB_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true}, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(FISSION_WEB_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
// Test empty remoteType default to "web" remoteType. // Test empty remoteType default to "web" remoteType.
{DEFAULT_REMOTE_TYPE, NOT_REMOTE_TYPE, true}, {NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), EmptyString(),
{WITH_COOP_COEP_REMOTE_TYPE_PREFIX, NOT_REMOTE_TYPE, false}, true},
{PRIVILEGEDMOZILLA_REMOTE_TYPE, NOT_REMOTE_TYPE, false}, {NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX),
{EXTENSION_REMOTE_TYPE, NOT_REMOTE_TYPE, false}, EmptyString(), false},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
EmptyString(), false},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), EmptyString(),
false},
}; };
for (const auto& test : tests) { for (const auto& test : tests) {
auto message = nsPrintfCString( auto message =
R"(MatchRemoteType("%s", "%s") should return %s)", nsPrintfCString(R"(MatchRemoteType("%s", "%s") should return %s)",
test.processRemoteType.get(), test.workerRemoteType.get(), NS_ConvertUTF16toUTF8(test.processRemoteType).get(),
test.shouldMatch ? "true" : "false"); NS_ConvertUTF16toUTF8(test.workerRemoteType).get(),
test.shouldMatch ? "true" : "false");
ASSERT_EQ(RemoteWorkerManager::MatchRemoteType(test.processRemoteType, ASSERT_EQ(RemoteWorkerManager::MatchRemoteType(test.processRemoteType,
test.workerRemoteType), test.workerRemoteType),
test.shouldMatch) test.shouldMatch)

View File

@ -579,7 +579,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPFileCreatorConstructor(
if (!parent) { if (!parent) {
isFileRemoteType = true; isFileRemoteType = true;
} else { } else {
isFileRemoteType = parent->GetRemoteType() == FILE_REMOTE_TYPE; isFileRemoteType = parent->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
NS_ReleaseOnMainThread("ContentParent release", parent.forget()); NS_ReleaseOnMainThread("ContentParent release", parent.forget());
} }

View File

@ -185,11 +185,11 @@ void ScriptPreloader::InitContentChild(ContentParent& parent) {
} }
} }
ProcessType ScriptPreloader::GetChildProcessType(const nsACString& remoteType) { ProcessType ScriptPreloader::GetChildProcessType(const nsAString& remoteType) {
if (remoteType == EXTENSION_REMOTE_TYPE) { if (remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) {
return ProcessType::Extension; return ProcessType::Extension;
} }
if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) { if (remoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) {
return ProcessType::PrivilegedAbout; return ProcessType::PrivilegedAbout;
} }
return ProcessType::Web; return ProcessType::Web;

View File

@ -75,7 +75,7 @@ class ScriptPreloader : public nsIObserver,
static ScriptPreloader& GetSingleton(); static ScriptPreloader& GetSingleton();
static ScriptPreloader& GetChildSingleton(); static ScriptPreloader& GetChildSingleton();
static ProcessType GetChildProcessType(const nsACString& remoteType); static ProcessType GetChildProcessType(const nsAString& remoteType);
// Retrieves the script with the given cache key from the script cache. // Retrieves the script with the given cache key from the script cache.
// Returns null if the script is not cached. // Returns null if the script is not cached.

View File

@ -64,7 +64,7 @@ SimpleChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
SimpleChannelParent::GetRemoteType(nsACString& aRemoteType) { SimpleChannelParent::GetRemoteType(nsAString& aRemoteType) {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

View File

@ -77,5 +77,5 @@ interface nsIParentChannel : nsIStreamListener
/** /**
* The remote type of the target process for this load. * The remote type of the target process for this load.
*/ */
readonly attribute AUTF8String remoteType; readonly attribute AString remoteType;
}; };

View File

@ -1314,7 +1314,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
return false; return false;
} }
nsAutoCString currentRemoteType(NOT_REMOTE_TYPE); nsAutoString currentRemoteType(VoidString());
if (RefPtr<ContentParent> contentParent = if (RefPtr<ContentParent> contentParent =
browsingContext->GetContentParent()) { browsingContext->GetContentParent()) {
currentRemoteType = contentParent->GetRemoteType(); currentRemoteType = contentParent->GetRemoteType();
@ -1322,7 +1322,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
MOZ_ASSERT_IF(currentRemoteType.IsEmpty(), !OtherPid()); MOZ_ASSERT_IF(currentRemoteType.IsEmpty(), !OtherPid());
// Determine what type of content process this load should finish in. // Determine what type of content process this load should finish in.
nsAutoCString preferredRemoteType(currentRemoteType); nsAutoString preferredRemoteType(currentRemoteType);
bool replaceBrowsingContext = false; bool replaceBrowsingContext = false;
uint64_t specificGroupId = 0; uint64_t specificGroupId = 0;
@ -1370,12 +1370,13 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// high-resolution timers. // high-resolution timers.
nsAutoCString siteOrigin; nsAutoCString siteOrigin;
resultPrincipal->GetSiteOrigin(siteOrigin); resultPrincipal->GetSiteOrigin(siteOrigin);
preferredRemoteType = WITH_COOP_COEP_REMOTE_TYPE_PREFIX; preferredRemoteType =
preferredRemoteType.Append(siteOrigin); NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
AppendUTF8toUTF16(siteOrigin, preferredRemoteType);
} else if (isCOOPSwitch) { } else if (isCOOPSwitch) {
// If we're doing a COOP switch, we do not need any affinity to the // If we're doing a COOP switch, we do not need any affinity to the
// current remote type. Clear it back to the default value. // current remote type. Clear it back to the default value.
preferredRemoteType = DEFAULT_REMOTE_TYPE; preferredRemoteType = NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE);
} }
} }
@ -1386,10 +1387,12 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
if (browsingContext->IsTop() && if (browsingContext->IsTop() &&
browsingContext->Group()->Toplevels().Length() == 1) { browsingContext->Group()->Toplevels().Length() == 1) {
if (IsLargeAllocationLoad(browsingContext, mChannel)) { if (IsLargeAllocationLoad(browsingContext, mChannel)) {
preferredRemoteType = LARGE_ALLOCATION_REMOTE_TYPE; preferredRemoteType =
NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE);
replaceBrowsingContext = true; replaceBrowsingContext = true;
} else if (preferredRemoteType == LARGE_ALLOCATION_REMOTE_TYPE) { } else if (preferredRemoteType.EqualsLiteral(
preferredRemoteType = DEFAULT_REMOTE_TYPE; LARGE_ALLOCATION_REMOTE_TYPE)) {
preferredRemoteType = NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE);
replaceBrowsingContext = true; replaceBrowsingContext = true;
} }
} }
@ -1401,9 +1404,10 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// Toplevel extension BrowsingContexts must be loaded in the extension // Toplevel extension BrowsingContexts must be loaded in the extension
// browsing context group, within the extension content process. // browsing context group, within the extension content process.
if (ExtensionPolicyService::GetSingleton().UseRemoteExtensions()) { if (ExtensionPolicyService::GetSingleton().UseRemoteExtensions()) {
preferredRemoteType = EXTENSION_REMOTE_TYPE; preferredRemoteType =
NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE);
} else { } else {
preferredRemoteType = NOT_REMOTE_TYPE; preferredRemoteType = VoidString();
} }
if (browsingContext->Group()->Id() != if (browsingContext->Group()->Id() !=
@ -1422,7 +1426,8 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
LOG( LOG(
("DocumentLoadListener GetRemoteTypeForPrincipal " ("DocumentLoadListener GetRemoteTypeForPrincipal "
"[this=%p, contentParent=%s, preferredRemoteType=%s]", "[this=%p, contentParent=%s, preferredRemoteType=%s]",
this, currentRemoteType.get(), preferredRemoteType.get())); this, NS_ConvertUTF16toUTF8(currentRemoteType).get(),
NS_ConvertUTF16toUTF8(preferredRemoteType).get()));
nsCOMPtr<nsIE10SUtils> e10sUtils = nsCOMPtr<nsIE10SUtils> e10sUtils =
do_ImportModule("resource://gre/modules/E10SUtils.jsm", "E10SUtils"); do_ImportModule("resource://gre/modules/E10SUtils.jsm", "E10SUtils");
@ -1437,7 +1442,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
currentPrincipal = wgp->DocumentPrincipal(); currentPrincipal = wgp->DocumentPrincipal();
} }
nsAutoCString remoteType; nsAutoString remoteType;
rv = e10sUtils->GetRemoteTypeForPrincipal( rv = e10sUtils->GetRemoteTypeForPrincipal(
resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(), resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(),
browsingContext->UseRemoteSubframes(), preferredRemoteType, browsingContext->UseRemoteSubframes(), preferredRemoteType,
@ -1451,16 +1456,18 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// other remote type, ensure the browsing context is replaced so that we leave // other remote type, ensure the browsing context is replaced so that we leave
// the extension-specific BrowsingContextGroup. // the extension-specific BrowsingContextGroup.
if (browsingContext->IsTop() && currentRemoteType != remoteType && if (browsingContext->IsTop() && currentRemoteType != remoteType &&
currentRemoteType == EXTENSION_REMOTE_TYPE) { currentRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) {
replaceBrowsingContext = true; replaceBrowsingContext = true;
} }
LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s", LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s",
currentRemoteType.get(), remoteType.get())); NS_ConvertUTF16toUTF8(currentRemoteType).get(),
NS_ConvertUTF16toUTF8(remoteType).get()));
// Check if a process switch is needed. // Check if a process switch is needed.
if (currentRemoteType == remoteType && !replaceBrowsingContext) { if (currentRemoteType == remoteType && !replaceBrowsingContext) {
LOG(("Process Switch Abort: type (%s) is compatible", remoteType.get())); LOG(("Process Switch Abort: type (%s) is compatible",
NS_ConvertUTF16toUTF8(remoteType).get()));
return false; return false;
} }
@ -1472,7 +1479,8 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
*aWillSwitchToRemote = !remoteType.IsEmpty(); *aWillSwitchToRemote = !remoteType.IsEmpty();
LOG(("Process Switch: Changing Remoteness from '%s' to '%s'", LOG(("Process Switch: Changing Remoteness from '%s' to '%s'",
currentRemoteType.get(), remoteType.get())); NS_ConvertUTF16toUTF8(currentRemoteType).get(),
NS_ConvertUTF16toUTF8(remoteType).get()));
mDoingProcessSwitch = true; mDoingProcessSwitch = true;
@ -2030,7 +2038,7 @@ DocumentLoadListener::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
DocumentLoadListener::GetRemoteType(nsACString& aRemoteType) { DocumentLoadListener::GetRemoteType(nsAString& aRemoteType) {
RefPtr<CanonicalBrowsingContext> browsingContext = GetBrowsingContext(); RefPtr<CanonicalBrowsingContext> browsingContext = GetBrowsingContext();
if (!browsingContext) { if (!browsingContext) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
@ -2039,7 +2047,7 @@ DocumentLoadListener::GetRemoteType(nsACString& aRemoteType) {
ErrorResult error; ErrorResult error;
browsingContext->GetCurrentRemoteType(aRemoteType, error); browsingContext->GetCurrentRemoteType(aRemoteType, error);
if (error.Failed()) { if (error.Failed()) {
aRemoteType = NOT_REMOTE_TYPE; aRemoteType = VoidString();
} }
return NS_OK; return NS_OK;
} }

View File

@ -899,8 +899,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvGetPageThumbStream(
// ScriptSecurityManager, but if somehow the process has been tricked into // ScriptSecurityManager, but if somehow the process has been tricked into
// sending this message, we send IPC_FAIL in order to crash that // sending this message, we send IPC_FAIL in order to crash that
// likely-compromised content process. // likely-compromised content process.
if (static_cast<ContentParent*>(Manager())->GetRemoteType() != if (!static_cast<ContentParent*>(Manager())->GetRemoteType().EqualsLiteral(
PRIVILEGEDABOUT_REMOTE_TYPE) { PRIVILEGEDABOUT_REMOTE_TYPE)) {
return IPC_FAIL(this, "Wrong process type"); return IPC_FAIL(this, "Wrong process type");
} }

View File

@ -87,8 +87,8 @@ NS_IMETHODIMP
ParentChannelWrapper::Delete() { return NS_OK; } ParentChannelWrapper::Delete() { return NS_OK; }
NS_IMETHODIMP NS_IMETHODIMP
ParentChannelWrapper::GetRemoteType(nsACString& aRemoteType) { ParentChannelWrapper::GetRemoteType(nsAString& aRemoteType) {
aRemoteType = NOT_REMOTE_TYPE; aRemoteType = VoidString();
return NS_OK; return NS_OK;
} }

View File

@ -66,7 +66,7 @@ DataChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
DataChannelParent::GetRemoteType(nsACString& aRemoteType) { DataChannelParent::GetRemoteType(nsAString& aRemoteType) {
if (!CanSend()) { if (!CanSend()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -66,7 +66,7 @@ FileChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
FileChannelParent::GetRemoteType(nsACString& aRemoteType) { FileChannelParent::GetRemoteType(nsAString& aRemoteType) {
if (!CanSend()) { if (!CanSend()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -533,7 +533,7 @@ FTPChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
FTPChannelParent::GetRemoteType(nsACString& aRemoteType) { FTPChannelParent::GetRemoteType(nsAString& aRemoteType) {
if (!CanSend()) { if (!CanSend()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -1997,7 +1997,7 @@ HttpChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
HttpChannelParent::GetRemoteType(nsACString& aRemoteType) { HttpChannelParent::GetRemoteType(nsAString& aRemoteType) {
if (!CanSend()) { if (!CanSend()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }

View File

@ -30,7 +30,7 @@ ContentProcessSandboxParams::ForThisProcess(
// (Otherwise, mBrokerFd will remain -1 from the default ctor.) // (Otherwise, mBrokerFd will remain -1 from the default ctor.)
auto* cc = dom::ContentChild::GetSingleton(); auto* cc = dom::ContentChild::GetSingleton();
params.mFileProcess = cc->GetRemoteType() == FILE_REMOTE_TYPE; params.mFileProcess = cc->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
nsAutoCString extraSyscalls; nsAutoCString extraSyscalls;
nsresult rv = Preferences::GetCString( nsresult rv = Preferences::GetCString(

View File

@ -22,7 +22,6 @@
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "mozilla/ThreadLocal.h" #include "mozilla/ThreadLocal.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/dom/RemoteType.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
@ -506,7 +505,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime,
HangDetails hangDetails(aHangTime, HangDetails hangDetails(aHangTime,
nsDependentCString(XRE_GetProcessTypeString()), nsDependentCString(XRE_GetProcessTypeString()),
NOT_REMOTE_TYPE, mThreadName, mRunnableName, VoidString(), mThreadName, mRunnableName,
std::move(mHangStack), std::move(mAnnotations)); std::move(mHangStack), std::move(mAnnotations));
PersistedToDisk persistedToDisk = aPersistedToDisk; PersistedToDisk persistedToDisk = aPersistedToDisk;

View File

@ -55,7 +55,7 @@ nsHangDetails::GetProcess(nsACString& aName) {
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHangDetails::GetRemoteType(nsACString& aName) { nsHangDetails::GetRemoteType(nsAString& aName) {
aName.Assign(mDetails.remoteType()); aName.Assign(mDetails.remoteType());
return NS_OK; return NS_OK;
} }
@ -574,7 +574,7 @@ Result<HangDetails, nsresult> ReadHangDetailsFromFile(nsIFile* aFile) {
MOZ_TRY_VAR(result.threadName(), ReadTString<char>(fd)); MOZ_TRY_VAR(result.threadName(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.runnableName(), ReadTString<char>(fd)); MOZ_TRY_VAR(result.runnableName(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.process(), ReadTString<char>(fd)); MOZ_TRY_VAR(result.process(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.remoteType(), ReadTString<char>(fd)); MOZ_TRY_VAR(result.remoteType(), ReadTString<char16_t>(fd));
uint32_t numAnnotations; uint32_t numAnnotations;
MOZ_TRY_VAR(numAnnotations, ReadUint(fd)); MOZ_TRY_VAR(numAnnotations, ReadUint(fd));

View File

@ -85,7 +85,7 @@ struct HangDetails
{ {
TimeDuration duration; TimeDuration duration;
nsCString process; nsCString process;
nsCString remoteType; nsString remoteType;
nsCString threadName; nsCString threadName;
nsCString runnableName; nsCString runnableName;
HangStack stack; HangStack stack;

View File

@ -50,7 +50,7 @@ interface nsIHangDetails : nsISupports
/** /**
* The remote type of the content process which produced the hang. * The remote type of the content process which produced the hang.
*/ */
readonly attribute AUTF8String remoteType; readonly attribute AString remoteType;
/** /**
* Returns the stack which was captured by BHR. The offset is encoded as a hex * Returns the stack which was captured by BHR. The offset is encoded as a hex

View File

@ -119,7 +119,7 @@ bool ExtensionPolicyService::IsExtensionProcess() const {
if (isRemote && XRE_IsContentProcess()) { if (isRemote && XRE_IsContentProcess()) {
auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType(); auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType();
return remoteType == EXTENSION_REMOTE_TYPE; return remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE);
} }
return !isRemote && XRE_IsParentProcess(); return !isRemote && XRE_IsParentProcess();
} }

View File

@ -32,11 +32,11 @@ interface nsIE10SUtils : nsISupports {
* *
* @return The remote type to complete this load in. * @return The remote type to complete this load in.
*/ */
AUTF8String getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal, AString getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal,
in nsIURI aChannelOriginalURI, in nsIURI aChannelOriginalURI,
in boolean aMultiProcess, in boolean aMultiProcess,
in boolean aRemoteSubframes, in boolean aRemoteSubframes,
in AUTF8String aPreferredRemoteType, in AString aPreferredRemoteType,
in nsIPrincipal aCurrentPrincipal, in nsIPrincipal aCurrentPrincipal,
in boolean aIsSubframe); in boolean aIsSubframe);
}; };

View File

@ -700,11 +700,12 @@ nsXULAppInfo::GetUniqueProcessID(uint64_t* aResult) {
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULAppInfo::GetRemoteType(nsACString& aRemoteType) { nsXULAppInfo::GetRemoteType(nsAString& aRemoteType) {
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
aRemoteType = ContentChild::GetSingleton()->GetRemoteType(); ContentChild* cc = ContentChild::GetSingleton();
aRemoteType.Assign(cc->GetRemoteType());
} else { } else {
aRemoteType = NOT_REMOTE_TYPE; SetDOMStringToNull(aRemoteType);
} }
return NS_OK; return NS_OK;
@ -842,8 +843,8 @@ NS_IMETHODIMP
nsXULAppInfo::EnsureContentProcess() { nsXULAppInfo::EnsureContentProcess() {
if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE; if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE;
RefPtr<ContentParent> unused = RefPtr<ContentParent> unused = ContentParent::GetNewOrUsedBrowserProcess(
ContentParent::GetNewOrUsedBrowserProcess(nullptr, DEFAULT_REMOTE_TYPE); nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
return NS_OK; return NS_OK;
} }

View File

@ -947,8 +947,8 @@ TestShellParent* GetOrCreateTestShellParent() {
// this and you're sure you wouldn't be better off writing a "browser" // this and you're sure you wouldn't be better off writing a "browser"
// chrome mochitest where you can have multiple types of content // chrome mochitest where you can have multiple types of content
// processes. // processes.
RefPtr<ContentParent> parent = RefPtr<ContentParent> parent = ContentParent::GetNewOrUsedBrowserProcess(
ContentParent::GetNewOrUsedBrowserProcess(nullptr, DEFAULT_REMOTE_TYPE); nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
parent.forget(&gContentParent); parent.forget(&gContentParent);
} else if (!gContentParent->IsAlive()) { } else if (!gContentParent->IsAlive()) {
return nullptr; return nullptr;

View File

@ -21,7 +21,7 @@ nsTArray<nsCString> LoadIPCMessageBlacklist(const char* aPath) {
} }
mozilla::dom::ContentParent* ProtocolFuzzerHelper::CreateContentParent( mozilla::dom::ContentParent* ProtocolFuzzerHelper::CreateContentParent(
const nsACString& aRemoteType) { const nsAString& aRemoteType) {
auto* cp = new mozilla::dom::ContentParent(aRemoteType); auto* cp = new mozilla::dom::ContentParent(aRemoteType);
// TODO: this duplicates MessageChannel::Open // TODO: this duplicates MessageChannel::Open
cp->GetIPCChannel()->mWorkerThread = GetCurrentSerialEventTarget(); cp->GetIPCChannel()->mWorkerThread = GetCurrentSerialEventTarget();

View File

@ -19,7 +19,7 @@ namespace ipc {
class ProtocolFuzzerHelper { class ProtocolFuzzerHelper {
public: public:
static mozilla::dom::ContentParent* CreateContentParent( static mozilla::dom::ContentParent* CreateContentParent(
const nsACString& aRemoteType); const nsAString& aRemoteType);
static void CompositorBridgeParentSetup(); static void CompositorBridgeParentSetup();

View File

@ -426,7 +426,7 @@ NS_IMETHODIMP nsExtProtocolChannel::Delete() {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsExtProtocolChannel::GetRemoteType(nsACString& aRemoteType) { NS_IMETHODIMP nsExtProtocolChannel::GetRemoteType(nsAString& aRemoteType) {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

View File

@ -68,7 +68,7 @@ struct ProcInfo {
// Process type // Process type
ProcType type; ProcType type;
// Origin, if any // Origin, if any
nsCString origin; nsString origin;
// Process filename (without the path name). // Process filename (without the path name).
nsString filename; nsString filename;
// VMS in bytes. // VMS in bytes.
@ -94,12 +94,12 @@ typedef MozPromise<ProcInfo, nsresult, true> ProcInfoPromise;
#ifdef XP_MACOSX #ifdef XP_MACOSX
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& processType, const ProcType& processType,
const nsACString& origin, const nsAString& origin,
mach_port_t aChildTask = MACH_PORT_NULL); mach_port_t aChildTask = MACH_PORT_NULL);
#else #else
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& processType, const ProcType& processType,
const nsACString& origin); const nsAString& origin);
#endif #endif
} // namespace mozilla } // namespace mozilla

View File

@ -11,7 +11,7 @@ namespace mozilla {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& type, const ProcType& type,
const nsACString& origin) { const nsAString& origin) {
// Not implemented on Android. // Not implemented on Android.
return ProcInfoPromise::CreateAndReject(NS_ERROR_NOT_IMPLEMENTED, __func__); return ProcInfoPromise::CreateAndReject(NS_ERROR_NOT_IMPLEMENTED, __func__);
} }

View File

@ -20,7 +20,7 @@
namespace mozilla { namespace mozilla {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& type, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& type,
const nsACString& origin, mach_port_t aChildTask) { const nsAString& origin, mach_port_t aChildTask) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>(); auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__); RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__);
@ -33,7 +33,7 @@ RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, const
} }
// Ensure that the string is still alive when `ResolveGetProcInfo` is called. // Ensure that the string is still alive when `ResolveGetProcInfo` is called.
nsCString originCopy(origin); nsString originCopy(origin);
auto ResolveGetProcinfo = [holder = std::move(holder), pid, type, auto ResolveGetProcinfo = [holder = std::move(holder), pid, type,
originCopy = std::move(originCopy), childId, aChildTask]() { originCopy = std::move(originCopy), childId, aChildTask]() {
ProcInfo info; ProcInfo info;

View File

@ -211,7 +211,7 @@ class ThreadInfoReader final : public StatReader {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& type, const ProcType& type,
const nsACString& origin) { const nsAString& origin) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>(); auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__); RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__);
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -224,7 +224,7 @@ RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
} }
// Ensure that the string is still alive when the runnable is called. // Ensure that the string is still alive when the runnable is called.
nsCString originCopy(origin); nsString originCopy(origin);
RefPtr<nsIRunnable> r = NS_NewRunnableFunction( RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, [holder = std::move(holder), pid, type, __func__, [holder = std::move(holder), pid, type,
originCopy = std::move(originCopy), childId]() { originCopy = std::move(originCopy), childId]() {

View File

@ -77,7 +77,7 @@ void AppendThreads(ProcInfo* info) {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& type, const ProcType& type,
const nsACString& origin) { const nsAString& origin) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>(); auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__); RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__);
@ -91,7 +91,7 @@ RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
} }
// Ensure that the string is still alive when `ResolveGetProcInfo` is called. // Ensure that the string is still alive when `ResolveGetProcInfo` is called.
nsCString originCopy(origin); nsString originCopy(origin);
RefPtr<nsIRunnable> r = NS_NewRunnableFunction( RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, __func__,
[holder = std::move(holder), originCopy = std::move(originCopy), pid, [holder = std::move(holder), originCopy = std::move(originCopy), pid,

View File

@ -112,7 +112,7 @@ interface nsIXULRuntime : nsISupports
* a URI if Fission is enabled, so don't use it for any kind of * a URI if Fission is enabled, so don't use it for any kind of
* telemetry. * telemetry.
*/ */
readonly attribute AUTF8String remoteType; readonly attribute AString remoteType;
/** /**
* If true, browser tabs may be opened by default in a different process * If true, browser tabs may be opened by default in a different process