Bug 1650163 - Part 1: Switch native remoteType values to nsCString, r=farre,geckoview-reviewers,agi

Differential Revision: https://phabricator.services.mozilla.com/D82104
This commit is contained in:
Nika Layzell
2020-07-08 20:15:59 +00:00
parent 21b131694f
commit 5f45e08c22
79 changed files with 323 additions and 372 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.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) { if (remoteType == 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.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) { if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) {
return NS_OK; return NS_OK;
} }
} }

View File

@@ -1047,9 +1047,8 @@ 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( StringBeginsWith(ContentChild::GetSingleton()->GetRemoteType(),
ContentChild::GetSingleton()->GetRemoteType(), WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
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(nsAString& aRemoteType, void CanonicalBrowsingContext::GetCurrentRemoteType(nsACString& 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.Assign(VoidString()); aRemoteType.Assign(VoidCString());
return; return;
} }
@@ -822,7 +822,7 @@ CanonicalBrowsingContext::PendingRemotenessChange::~PendingRemotenessChange() {
} }
RefPtr<CanonicalBrowsingContext::RemotenessPromise> RefPtr<CanonicalBrowsingContext::RemotenessPromise>
CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType, CanonicalBrowsingContext::ChangeRemoteness(const nsACString& 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(nsAString& aRemoteType, ErrorResult& aRv) const; void GetCurrentRemoteType(nsACString& 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 VoidString() aRemoteType argument will perform a process switch into the // A VoidCString() aRemoteType argument will perform a process switch into 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 nsAString& aRemoteType, RefPtr<RemotenessPromise> ChangeRemoteness(const nsACString& 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, u""_ns) mozilla::GetProcInfo(parentPid, 0, mozilla::ProcType::Browser, ""_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;
} }
nsAutoString origin; nsAutoCString origin;
base::ProcessId childPid = base::ProcessId childPid =
base::GetProcId(aGeckoProcess->GetChildProcessHandle()); base::GetProcId(aGeckoProcess->GetChildProcessHandle());
int32_t childId = 0; int32_t childId = 0;
@@ -832,50 +832,42 @@ 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.
nsAutoString remoteType(contentParent->GetRemoteType()); nsAutoCString remoteType(contentParent->GetRemoteType());
if (StringBeginsWith(remoteType, if (StringBeginsWith(remoteType,
NS_LITERAL_STRING_FROM_CSTRING( FISSION_WEB_REMOTE_TYPE)) {
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( } else if (StringBeginsWith(remoteType,
remoteType, NS_LITERAL_STRING_FROM_CSTRING( DEFAULT_REMOTE_TYPE)) {
DEFAULT_REMOTE_TYPE))) {
type = mozilla::ProcType::Web; type = mozilla::ProcType::Web;
} else if (remoteType.EqualsLiteral(FILE_REMOTE_TYPE)) { } else if (remoteType == FILE_REMOTE_TYPE) {
type = mozilla::ProcType::File; type = mozilla::ProcType::File;
} else if (remoteType.EqualsLiteral( } else if (remoteType == EXTENSION_REMOTE_TYPE) {
EXTENSION_REMOTE_TYPE)) {
type = mozilla::ProcType::Extension; type = mozilla::ProcType::Extension;
} else if (remoteType.EqualsLiteral( } else if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) {
PRIVILEGEDABOUT_REMOTE_TYPE)) {
type = mozilla::ProcType::PrivilegedAbout; type = mozilla::ProcType::PrivilegedAbout;
} else if (remoteType.EqualsLiteral( } else if (remoteType == PRIVILEGEDMOZILLA_REMOTE_TYPE) {
PRIVILEGEDMOZILLA_REMOTE_TYPE)) {
type = mozilla::ProcType::PrivilegedMozilla; type = mozilla::ProcType::PrivilegedMozilla;
} else if (StringBeginsWith( } else if (StringBeginsWith(
remoteType, remoteType,
NS_LITERAL_STRING_FROM_CSTRING( WITH_COOP_COEP_REMOTE_TYPE_PREFIX)) {
WITH_COOP_COEP_REMOTE_TYPE_PREFIX))) {
type = mozilla::ProcType::WebCOOPCOEP; type = mozilla::ProcType::WebCOOPCOEP;
} else if (remoteType.EqualsLiteral( } else if (remoteType == LARGE_ALLOCATION_REMOTE_TYPE) {
LARGE_ALLOCATION_REMOTE_TYPE)) {
type = mozilla::ProcType::WebLargeAllocation; type = mozilla::ProcType::WebLargeAllocation;
} else if (remoteType.EqualsLiteral( } else if (remoteType == PREALLOC_REMOTE_TYPE) {
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.
nsAString::const_iterator cursor; nsACString::const_iterator cursor;
nsAString::const_iterator end; nsACString::const_iterator end;
remoteType.BeginReading(cursor); remoteType.BeginReading(cursor);
remoteType.EndReading(end); remoteType.EndReading(end);
if (FindCharInReadable(u'=', cursor, end)) { if (FindCharInReadable('=', 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(nsAString& aRemoteType, mozilla::ErrorResult& aError) { void GetRemoteType(nsACString& 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(VoidString()), mRemoteType(VoidCString()),
mDepthTooGreat(false), mDepthTooGreat(false),
mIsTopLevelContent(false), mIsTopLevelContent(false),
mDestroyCalled(false), mDestroyCalled(false),
@@ -351,17 +351,20 @@ static bool InitialLoadIsRemote(Element* aOwner) {
} }
static void GetInitialRemoteTypeAndProcess(Element* aOwner, static void GetInitialRemoteTypeAndProcess(Element* aOwner,
nsAString& aRemoteType, nsACString& 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, aRemoteType); aOwner->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType, remoteType);
if (!hasRemoteType || aRemoteType.IsEmpty()) { if (!hasRemoteType || remoteType.IsEmpty()) {
hasRemoteType = false; hasRemoteType = false;
aRemoteType.AssignLiteral(DEFAULT_REMOTE_TYPE); aRemoteType = 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.
@@ -528,7 +531,7 @@ void nsFrameLoader::LoadFrame(bool aOriginalSrc) {
} }
} }
void nsFrameLoader::ConfigRemoteProcess(const nsAString& aRemoteType, void nsFrameLoader::ConfigRemoteProcess(const nsACString& 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 nsAString& aRemoteType, void ConfigRemoteProcess(const nsACString& 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;
nsString mRemoteType; nsCString 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(nsAString& aRemoteType, void MessageManagerCallback::DoGetRemoteType(nsACString& 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(nsAString& aRemoteType, void nsFrameMessageManager::GetRemoteType(nsACString& 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(nsAString& aRemoteType, virtual void DoGetRemoteType(nsACString& 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(nsAString& aRemoteType, void GetRemoteType(nsACString& 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 DOMString? currentRemoteType; readonly attribute UTF8String? 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;
DOMString origin = ""; UTF8String 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<DOMString> remoteTypes; sequence<UTF8String> 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<DOMString> remoteTypes; sequence<UTF8String> 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 DOMString remoteType; readonly attribute UTF8String 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 AString aType, int32_t provideProcess(in AUTF8String 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,
NS_ConvertUTF16toUTF8(remoteTypePrefix)); remoteTypePrefix);
#endif /* MOZ_SANDBOX */ #endif /* MOZ_SANDBOX */
return IPC_OK(); return IPC_OK();
@@ -2568,38 +2568,36 @@ mozilla::ipc::IPCResult ContentChild::RecvAppInfo(
} }
mozilla::ipc::IPCResult ContentChild::RecvRemoteType( mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
const nsString& aRemoteType) { const nsCString& aRemoteType) {
if (!DOMStringIsNull(mRemoteType)) { if (!mRemoteType.IsVoid()) {
// 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(),
NS_ConvertUTF16toUTF8(mRemoteType).get(), mRemoteType.get(), aRemoteType.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.EqualsLiteral(FILE_REMOTE_TYPE) && MOZ_RELEASE_ASSERT(aRemoteType != FILE_REMOTE_TYPE &&
(mRemoteType.EqualsLiteral(PREALLOC_REMOTE_TYPE) || (mRemoteType == PREALLOC_REMOTE_TYPE ||
(mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) && (mRemoteType == DEFAULT_REMOTE_TYPE &&
aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)))); aRemoteType == 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(),
NS_ConvertUTF16toUTF8(aRemoteType).get())); 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.EqualsLiteral(FILE_REMOTE_TYPE)) { if (aRemoteType == FILE_REMOTE_TYPE) {
SetProcessName(u"file:// Content"_ns); SetProcessName(u"file:// Content"_ns);
} else if (aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) { } else if (aRemoteType == EXTENSION_REMOTE_TYPE) {
SetProcessName(u"WebExtensions"_ns); SetProcessName(u"WebExtensions"_ns);
} else if (aRemoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) { } else if (aRemoteType == PRIVILEGEDABOUT_REMOTE_TYPE) {
SetProcessName(u"Privileged Content"_ns); SetProcessName(u"Privileged Content"_ns);
} else if (aRemoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) { } else if (aRemoteType == LARGE_ALLOCATION_REMOTE_TYPE) {
SetProcessName(u"Large Allocation Web Content"_ns); SetProcessName(u"Large Allocation Web Content"_ns);
} else if (RemoteTypePrefix(aRemoteType) } else if (RemoteTypePrefix(aRemoteType) == FISSION_WEB_REMOTE_TYPE) {
.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
@@ -2611,7 +2609,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 nsAString& ContentChild::GetRemoteType() const { return mRemoteType; } const nsACString& ContentChild::GetRemoteType() const { return mRemoteType; }
mozilla::ipc::IPCResult ContentChild::RecvInitServiceWorkers( mozilla::ipc::IPCResult ContentChild::RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig) { const ServiceWorkerConfiguration& aConfig) {

View File

@@ -390,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 nsString& aRemoteType); mozilla::ipc::IPCResult RecvRemoteType(const nsCString& 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 nsAString& GetRemoteType() const override; const nsACString& GetRemoteType() const override;
mozilla::ipc::IPCResult RecvInitServiceWorkers( mozilla::ipc::IPCResult RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig); const ServiceWorkerConfiguration& aConfig);
@@ -863,7 +863,7 @@ class ContentChild final : public PContentChild,
AppInfo mAppInfo; AppInfo mAppInfo;
bool mIsForBrowser; bool mIsForBrowser;
nsString mRemoteType = VoidString(); nsCString mRemoteType = VoidCString();
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<nsStringHashKey, nsTArray<ContentParent*>>* nsClassHashtable<nsCStringHashKey, 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 nsAString& remoteType) { ProcessID GetTelemetryProcessID(const nsACString& 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.EqualsLiteral(EXTENSION_REMOTE_TYPE) ? ProcessID::Extension return remoteType == EXTENSION_REMOTE_TYPE ? ProcessID::Extension
: ProcessID::Content; : ProcessID::Content;
} }
} // anonymous namespace } // anonymous namespace
@@ -638,11 +638,10 @@ 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 = RefPtr<ContentParent> process = new ContentParent(PREALLOC_REMOTE_TYPE);
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_REMOTE_TYPE)); ("Preallocating process of type prealloc"));
return process->LaunchSubprocessAsync(PROCESS_PRIORITY_PREALLOC); return process->LaunchSubprocessAsync(PROCESS_PRIORITY_PREALLOC);
} }
@@ -688,7 +687,7 @@ void ContentParent::ShutDown() {
} }
/*static*/ /*static*/
uint32_t ContentParent::GetPoolSize(const nsAString& aContentProcessType) { uint32_t ContentParent::GetPoolSize(const nsACString& aContentProcessType) {
if (!sBrowserContentParents) { if (!sBrowserContentParents) {
return 0; return 0;
} }
@@ -700,17 +699,17 @@ uint32_t ContentParent::GetPoolSize(const nsAString& aContentProcessType) {
} }
/*static*/ nsTArray<ContentParent*>& ContentParent::GetOrCreatePool( /*static*/ nsTArray<ContentParent*>& ContentParent::GetOrCreatePool(
const nsAString& aContentProcessType) { const nsACString& aContentProcessType) {
if (!sBrowserContentParents) { if (!sBrowserContentParents) {
sBrowserContentParents = sBrowserContentParents =
new nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>; new nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>;
} }
return *sBrowserContentParents->LookupOrAdd(aContentProcessType); return *sBrowserContentParents->LookupOrAdd(aContentProcessType);
} }
const nsDependentSubstring RemoteTypePrefix( const nsDependentCSubstring RemoteTypePrefix(
const nsAString& aContentProcessType) { const nsACString& 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'=');
@@ -720,28 +719,26 @@ const nsDependentSubstring RemoteTypePrefix(
return StringHead(aContentProcessType, equalIdx); return StringHead(aContentProcessType, equalIdx);
} }
bool IsWebRemoteType(const nsAString& aContentProcessType) { bool IsWebRemoteType(const nsACString& 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, return StringBeginsWith(aContentProcessType, DEFAULT_REMOTE_TYPE);
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
} }
bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType) { bool IsWebCoopCoepRemoteType(const nsACString& aContentProcessType) {
return StringBeginsWith( return StringBeginsWith(aContentProcessType,
aContentProcessType, WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
} }
/*static*/ /*static*/
uint32_t ContentParent::GetMaxProcessCount( uint32_t ContentParent::GetMaxProcessCount(
const nsAString& aContentProcessType) { const nsACString& aContentProcessType) {
// Max process count is based only on the prefix. // Max process count is based only on the prefix.
const nsDependentSubstring processTypePrefix = const nsDependentCSubstring 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.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { if (processTypePrefix == DEFAULT_REMOTE_TYPE) {
return GetMaxWebProcessCount(); return GetMaxWebProcessCount();
} }
@@ -749,7 +746,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.");
AppendUTF16toUTF8(processTypePrefix, processCountPref); processCountPref.Append(processTypePrefix);
int32_t maxContentParents = Preferences::GetInt(processCountPref.get(), 1); int32_t maxContentParents = Preferences::GetInt(processCountPref.get(), 1);
if (maxContentParents < 1) { if (maxContentParents < 1) {
@@ -761,7 +758,7 @@ uint32_t ContentParent::GetMaxProcessCount(
/*static*/ /*static*/
bool ContentParent::IsMaxProcessCountReached( bool ContentParent::IsMaxProcessCountReached(
const nsAString& aContentProcessType) { const nsACString& aContentProcessType) {
return GetPoolSize(aContentProcessType) >= return GetPoolSize(aContentProcessType) >=
GetMaxProcessCount(aContentProcessType); GetMaxProcessCount(aContentProcessType);
} }
@@ -781,10 +778,9 @@ 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( MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
ContentParent::GetLog(), LogLevel::Debug, ("%s: %zu processes", cp->mRemoteType.get(),
("%s: %zu processes", NS_ConvertUTF16toUTF8(cp->mRemoteType).get(), contentParents->Length()));
contentParents->Length()));
break; break;
} }
} }
@@ -800,13 +796,12 @@ 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.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { cp->mRemoteType == 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, NS_ConvertUTF16toUTF8(cp->mRemoteType).get(), cp, cp->mRemoteType.get(), cp->ManagedPBrowserParent().Count(),
cp->ManagedPBrowserParent().Count(),
cp->HasActiveWorkerOrJSPlugin())); cp->HasActiveWorkerOrJSPlugin()));
} }
} }
@@ -814,8 +809,7 @@ 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, (" Shutdown %p (%s)", cp, cp->mRemoteType.get()));
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);
@@ -863,7 +857,7 @@ already_AddRefed<ContentParent> ContentParent::MinTabSelect(
/*static*/ /*static*/
already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess( already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
const nsAString& aRemoteType, nsTArray<ContentParent*>& aContentParents, const nsACString& 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);
@@ -902,7 +896,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(),
NS_ConvertUTF16toUTF8(aRemoteType).get())); PromiseFlatCString(aRemoteType).get()));
retval->AssertAlive(); retval->AssertAlive();
return retval.forget(); return retval.forget();
} }
@@ -915,7 +909,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(),
NS_ConvertUTF16toUTF8(aRemoteType).get())); PromiseFlatCString(aRemoteType).get()));
random->AssertAlive(); random->AssertAlive();
return random.forget(); return random.forget();
} }
@@ -927,8 +921,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.EqualsLiteral(FILE_REMOTE_TYPE) && if (aRemoteType != FILE_REMOTE_TYPE &&
!aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) && // Bug 1638119 aRemoteType != EXTENSION_REMOTE_TYPE && // Bug 1638119
(p = PreallocatedProcessManager::Take(aRemoteType)) && (p = PreallocatedProcessManager::Take(aRemoteType)) &&
!p->mShutdownPending) { !p->mShutdownPending) {
p->AssertAlive(); p->AssertAlive();
@@ -936,7 +930,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.EqualsLiteral(PREALLOC_REMOTE_TYPE); preallocated = p->mRemoteType == 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()) {
@@ -951,7 +945,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(),
NS_ConvertUTF16toUTF8(aRemoteType).get())); PromiseFlatCString(aRemoteType).get()));
p->mActivateTS = TimeStamp::Now(); p->mActivateTS = TimeStamp::Now();
p->AddToPool(aContentParents); p->AddToPool(aContentParents);
if (preallocated) { if (preallocated) {
@@ -971,8 +965,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.EqualsLiteral(DEFAULT_REMOTE_TYPE) && MOZ_RELEASE_ASSERT(p->mRemoteType == DEFAULT_REMOTE_TYPE &&
aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)); aRemoteType == DEFAULT_REMOTE_TYPE);
} }
return p.forget(); return p.forget();
} }
@@ -982,25 +976,22 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
/*static*/ /*static*/
already_AddRefed<ContentParent> already_AddRefed<ContentParent>
ContentParent::GetNewOrUsedLaunchingBrowserProcess(Element* aFrameElement, ContentParent::GetNewOrUsedLaunchingBrowserProcess(
const nsAString& aRemoteType, Element* aFrameElement, const nsACString& aRemoteType,
ProcessPriority aPriority, ProcessPriority aPriority, bool aPreferUsed) {
bool aPreferUsed) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetNewOrUsedProcess for type %s", ("GetNewOrUsedProcess for type %s",
NS_ConvertUTF16toUTF8(aRemoteType).get())); PromiseFlatCString(aRemoteType).get()));
nsTArray<ContentParent*>& contentParents = GetOrCreatePool(aRemoteType); nsTArray<ContentParent*>& contentParents = GetOrCreatePool(aRemoteType);
uint32_t maxContentParents = GetMaxProcessCount(aRemoteType); uint32_t maxContentParents = GetMaxProcessCount(aRemoteType);
if (aRemoteType.EqualsLiteral( // We never want to re-use Large-Allocation processes.
LARGE_ALLOCATION_REMOTE_TYPE) // We never want to re-use if (aRemoteType == LARGE_ALLOCATION_REMOTE_TYPE &&
// Large-Allocation processes. contentParents.Length() >= maxContentParents) {
&& 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( return GetNewOrUsedLaunchingBrowserProcess(aFrameElement,
aFrameElement, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), DEFAULT_REMOTE_TYPE, aPriority,
aPriority, /*aPreferUsed =*/false);
/*aPreferUsed =*/false);
} }
// Let's try and reuse an existing process. // Let's try and reuse an existing process.
@@ -1021,7 +1012,7 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(Element* aFrameElement,
// 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",
NS_ConvertUTF16toUTF8(aRemoteType).get())); PromiseFlatCString(aRemoteType).get()));
contentParent = new ContentParent(aRemoteType); contentParent = new ContentParent(aRemoteType);
if (!contentParent->BeginSubprocessLaunch(aPriority)) { if (!contentParent->BeginSubprocessLaunch(aPriority)) {
@@ -1048,7 +1039,7 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(Element* aFrameElement,
/*static*/ /*static*/
RefPtr<ContentParent::LaunchPromise> RefPtr<ContentParent::LaunchPromise>
ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement, ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement,
const nsAString& aRemoteType, const nsACString& aRemoteType,
ProcessPriority aPriority, ProcessPriority aPriority,
bool aPreferUsed) { bool aPreferUsed) {
// Obtain a `ContentParent` launched asynchronously. // Obtain a `ContentParent` launched asynchronously.
@@ -1063,7 +1054,7 @@ ContentParent::GetNewOrUsedBrowserProcessAsync(Element* aFrameElement,
/*static*/ /*static*/
already_AddRefed<ContentParent> ContentParent::GetNewOrUsedBrowserProcess( already_AddRefed<ContentParent> ContentParent::GetNewOrUsedBrowserProcess(
Element* aFrameElement, const nsAString& aRemoteType, Element* aFrameElement, const nsACString& 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);
@@ -1312,7 +1303,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 nsAString& aRemoteType, BrowsingContext* aBrowsingContext, const nsACString& aRemoteType, BrowsingContext* aBrowsingContext,
ContentParent* aOpenerContentParent) { ContentParent* aOpenerContentParent) {
AUTO_PROFILER_LABEL("ContentParent::CreateBrowser", OTHER); AUTO_PROFILER_LABEL("ContentParent::CreateBrowser", OTHER);
@@ -1320,9 +1311,9 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
return nullptr; return nullptr;
} }
nsAutoString remoteType(aRemoteType); nsAutoCString remoteType(aRemoteType);
if (remoteType.IsEmpty()) { if (remoteType.IsEmpty()) {
remoteType.AssignLiteral(DEFAULT_REMOTE_TYPE); remoteType = DEFAULT_REMOTE_TYPE;
} }
ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement); ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
@@ -1480,7 +1471,7 @@ void ContentParent::BroadcastFontListChanged() {
} }
} }
const nsAString& ContentParent::GetRemoteType() const { return mRemoteType; } const nsACString& ContentParent::GetRemoteType() const { return mRemoteType; }
void ContentParent::Init() { void ContentParent::Init() {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@@ -1940,7 +1931,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.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { if (mRemoteType != 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
@@ -2026,13 +2017,12 @@ bool ContentParent::ShouldKeepProcessAlive() {
nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive."); nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive.");
if (StringBeginsWith(mRemoteType, NS_LITERAL_STRING_FROM_CSTRING( if (StringBeginsWith(mRemoteType, FISSION_WEB_REMOTE_TYPE) &&
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(NS_ConvertUTF16toUTF8(mRemoteType)); keepAlivePref.Append(mRemoteType);
} }
if (NS_FAILED( if (NS_FAILED(
Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) { Preferences::GetInt(keepAlivePref.get(), &processesToKeepAlive))) {
@@ -2153,7 +2143,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().EqualsLiteral(FILE_REMOTE_TYPE)) { if (GetRemoteType() == FILE_REMOTE_TYPE) {
MacSandboxInfo::AppendFileAccessParam(aArgs, true); MacSandboxInfo::AppendFileAccessParam(aArgs, true);
} }
} }
@@ -2461,7 +2451,7 @@ RefPtr<ContentParent::LaunchPromise> ContentParent::LaunchSubprocessAsync(
}); });
} }
ContentParent::ContentParent(const nsAString& aRemoteType, int32_t aJSPluginID) ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
: mSelfRef(nullptr), : mSelfRef(nullptr),
mSubprocess(nullptr), mSubprocess(nullptr),
mLaunchTS(TimeStamp::Now()), mLaunchTS(TimeStamp::Now()),
@@ -2510,7 +2500,7 @@ ContentParent::ContentParent(const nsAString& aRemoteType, int32_t aJSPluginID)
#endif #endif
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
bool isFile = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE); bool isFile = mRemoteType == 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,
@@ -2817,7 +2807,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.EqualsLiteral(FILE_REMOTE_TYPE); bool isFileProcess = mRemoteType == FILE_REMOTE_TYPE;
UniquePtr<SandboxBroker::Policy> policy = UniquePtr<SandboxBroker::Policy> policy =
sSandboxBrokerPolicyFactory->GetContentPolicy(Pid(), isFileProcess); sSandboxBrokerPolicyFactory->GetContentPolicy(Pid(), isFileProcess);
if (policy) { if (policy) {
@@ -3201,8 +3191,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->SetPropertyAsAString(u"remoteTypePrefix"_ns, props->SetPropertyAsACString(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;
} }
@@ -5238,7 +5228,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().EqualsLiteral(FILE_REMOTE_TYPE) && GetRemoteType() != 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

@@ -53,17 +53,17 @@
// Process names as reported by about:memory are defined in // Process names as reported by about:memory are defined in
// ContentChild:RecvRemoteType. Add your value there too or it will be called // ContentChild:RecvRemoteType. Add your value there too or it will be called
// "Web Content". // "Web Content".
#define PREALLOC_REMOTE_TYPE "prealloc" #define PREALLOC_REMOTE_TYPE "prealloc"_ns
#define DEFAULT_REMOTE_TYPE "web" #define DEFAULT_REMOTE_TYPE "web"_ns
#define FILE_REMOTE_TYPE "file" #define FILE_REMOTE_TYPE "file"_ns
#define EXTENSION_REMOTE_TYPE "extension" #define EXTENSION_REMOTE_TYPE "extension"_ns
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout" #define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla" #define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
// These must start with the DEFAULT_REMOTE_TYPE above. // These must start with the DEFAULT_REMOTE_TYPE above.
#define FISSION_WEB_REMOTE_TYPE "webIsolated" #define FISSION_WEB_REMOTE_TYPE "webIsolated"_ns
#define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP=" #define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP="_ns
#define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation" #define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation"_ns
class nsConsoleService; class nsConsoleService;
class nsIContentProcessInfo; class nsIContentProcessInfo;
@@ -179,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 nsAString& aContentProcessType); static uint32_t GetPoolSize(const nsACString& aContentProcessType);
static uint32_t GetMaxProcessCount(const nsAString& aContentProcessType); static uint32_t GetMaxProcessCount(const nsACString& aContentProcessType);
static bool IsMaxProcessCountReached(const nsAString& aContentProcessType); static bool IsMaxProcessCountReached(const nsACString& aContentProcessType);
static void ReleaseCachedProcesses(); static void ReleaseCachedProcesses();
@@ -203,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 nsAString& aRemoteType, Element* aFrameElement, const nsACString& 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 nsAString& aRemoteType, Element* aFrameElement, const nsACString& aRemoteType,
hal::ProcessPriority aPriority = hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND, hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
bool aPreferUsed = false); bool aPreferUsed = false);
@@ -224,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 nsAString& aRemoteType, Element* aFrameElement, const nsACString& aRemoteType,
hal::ProcessPriority aPriority = hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND, hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
bool aPreferUsed = false); bool aPreferUsed = false);
@@ -250,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 nsAString& aRemoteType, BrowsingContext* aBrowsingContext, const nsACString& aRemoteType, BrowsingContext* aBrowsingContext,
ContentParent* aOpenerContentParent); ContentParent* aOpenerContentParent);
static void GetAll(nsTArray<ContentParent*>& aArray); static void GetAll(nsTArray<ContentParent*>& aArray);
@@ -261,9 +261,9 @@ class ContentParent final
static void BroadcastFontListChanged(); static void BroadcastFontListChanged();
const nsAString& GetRemoteType() const override; const nsACString& GetRemoteType() const override;
virtual void DoGetRemoteType(nsAString& aRemoteType, virtual void DoGetRemoteType(nsACString& aRemoteType,
ErrorResult& aError) const override { ErrorResult& aError) const override {
aRemoteType = GetRemoteType(); aRemoteType = GetRemoteType();
} }
@@ -723,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<nsStringHashKey, nsTArray<ContentParent*>>* static nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>*
sBrowserContentParents; sBrowserContentParents;
static UniquePtr<nsTArray<ContentParent*>> sPrivateContent; static UniquePtr<nsTArray<ContentParent*>> sPrivateContent;
static UniquePtr<nsDataHashtable<nsUint32HashKey, ContentParent*>> static UniquePtr<nsDataHashtable<nsUint32HashKey, ContentParent*>>
@@ -754,11 +754,11 @@ class ContentParent final
const OriginAttributes& aOriginAttributes); const OriginAttributes& aOriginAttributes);
explicit ContentParent(int32_t aPluginID) explicit ContentParent(int32_t aPluginID)
: ContentParent(EmptyString(), aPluginID) {} : ContentParent(EmptyCString(), aPluginID) {}
explicit ContentParent(const nsAString& aRemoteType) explicit ContentParent(const nsACString& aRemoteType)
: ContentParent(aRemoteType, nsFakePluginTag::NOT_JSPLUGIN) {} : ContentParent(aRemoteType, nsFakePluginTag::NOT_JSPLUGIN) {}
ContentParent(const nsAString& aRemoteType, int32_t aPluginID); ContentParent(const nsACString& 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.
@@ -881,7 +881,7 @@ class ContentParent final
* |aContentProcessType|. * |aContentProcessType|.
*/ */
static nsTArray<ContentParent*>& GetOrCreatePool( static nsTArray<ContentParent*>& GetOrCreatePool(
const nsAString& aContentProcessType); const nsACString& aContentProcessType);
mozilla::ipc::IPCResult RecvInitBackground( mozilla::ipc::IPCResult RecvInitBackground(
Endpoint<mozilla::ipc::PBackgroundParent>&& aEndpoint); Endpoint<mozilla::ipc::PBackgroundParent>&& aEndpoint);
@@ -1370,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 nsAString& aRemoteType, nsTArray<ContentParent*>& aContentParents, const nsACString& aRemoteType, nsTArray<ContentParent*>& aContentParents,
uint32_t aMaxContentParents, bool aPreferUsed); uint32_t aMaxContentParents, bool aPreferUsed);
void AddToPool(nsTArray<ContentParent*>&); void AddToPool(nsTArray<ContentParent*>&);
@@ -1394,7 +1394,7 @@ class ContentParent final
bool mIsAPreallocBlocker; // We called AddBlocker for this ContentParent bool mIsAPreallocBlocker; // We called AddBlocker for this ContentParent
nsString mRemoteType; nsCString mRemoteType;
ContentParentId mChildID; ContentParentId mChildID;
int32_t mGeolocationWatchID; int32_t mGeolocationWatchID;
@@ -1543,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 nsDependentSubstring RemoteTypePrefix( const nsDependentCSubstring RemoteTypePrefix(
const nsAString& aContentProcessType); const nsACString& aContentProcessType);
// This is based on isWebRemoteType in E10SUtils.jsm. // This is based on isWebRemoteType in E10SUtils.jsm.
bool IsWebRemoteType(const nsAString& aContentProcessType); bool IsWebRemoteType(const nsACString& aContentProcessType);
bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType); bool IsWebCoopCoepRemoteType(const nsACString& 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

@@ -45,7 +45,7 @@ class InProcessChild final : public nsIDOMProcessChild,
// |nullptr|. // |nullptr|.
static IProtocol* ParentActorFor(IProtocol* aActor); static IProtocol* ParentActorFor(IProtocol* aActor);
const nsAString& GetRemoteType() const override { return VoidString(); } const nsACString& GetRemoteType() const override { return VoidCString(); }
protected: protected:
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor, already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,

View File

@@ -47,7 +47,7 @@ class InProcessParent final : public nsIDOMProcessParent,
// |nullptr|. // |nullptr|.
static IProtocol* ChildActorFor(IProtocol* aActor); static IProtocol* ChildActorFor(IProtocol* aActor);
const nsAString& GetRemoteType() const override { return VoidString(); }; const nsACString& GetRemoteType() const override { return VoidCString(); };
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;
nsString[] remoteTypes; nsCString[] 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;
nsString[] remoteTypes; nsCString[] 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(nsString aRemoteType); async RemoteType(nsCString 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 nsAString& aRemoteType); already_AddRefed<ContentParent> Take(const nsACString& 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 nsAString& aRemoteType) { const nsACString& aRemoteType) {
if (!mEnabled || sShutdown) { if (!mEnabled || sShutdown) {
return nullptr; return nullptr;
} }
RefPtr<ContentParent> process; RefPtr<ContentParent> process;
if (aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { if (aRemoteType == 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 " DEFAULT_REMOTE_TYPE " process %p", process.get())); ("Reuse web 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_REMOTE_TYPE " process %p", process.get())); ("Use prealloc process %p", process.get()));
} }
if (process) { if (process) {
ProcessPriorityManager::SetProcessPriority(process, ProcessPriorityManager::SetProcessPriority(process,
@@ -220,15 +220,14 @@ already_AddRefed<ContentParent> PreallocatedProcessManagerImpl::Take(
} }
bool PreallocatedProcessManagerImpl::Provide(ContentParent* aParent) { bool PreallocatedProcessManagerImpl::Provide(ContentParent* aParent) {
MOZ_DIAGNOSTIC_ASSERT( MOZ_DIAGNOSTIC_ASSERT(aParent->GetRemoteType() == DEFAULT_REMOTE_TYPE);
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 " DEFAULT_REMOTE_TYPE " process %p", aParent)); ("Store for reuse web process %p", aParent));
ProcessPriorityManager::SetProcessPriority(aParent, ProcessPriorityManager::SetProcessPriority(aParent,
PROCESS_PRIORITY_BACKGROUND); PROCESS_PRIORITY_BACKGROUND);
mPreallocatedE10SProcess = aParent; mPreallocatedE10SProcess = aParent;
@@ -300,8 +299,7 @@ bool PreallocatedProcessManagerImpl::CanAllocate() {
return mEnabled && sNumBlockers == 0 && return mEnabled && sNumBlockers == 0 &&
mPreallocatedProcesses.size() < mNumberPreallocs && !sShutdown && mPreallocatedProcesses.size() < mNumberPreallocs && !sShutdown &&
(FissionAutostart() || (FissionAutostart() ||
!ContentParent::IsMaxProcessCountReached( !ContentParent::IsMaxProcessCountReached(DEFAULT_REMOTE_TYPE));
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)));
} }
void PreallocatedProcessManagerImpl::AllocateAfterDelay() { void PreallocatedProcessManagerImpl::AllocateAfterDelay() {
@@ -402,11 +400,11 @@ PreallocatedProcessManager::GetPPMImpl() {
} }
/* static */ /* static */
void PreallocatedProcessManager::AddBlocker(const nsAString& aRemoteType, void PreallocatedProcessManager::AddBlocker(const nsACString& 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)",
NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent, PromiseFlatCString(aRemoteType).get(), aParent,
PreallocatedProcessManagerImpl::sNumBlockers)); PreallocatedProcessManagerImpl::sNumBlockers));
if (auto impl = GetPPMImpl()) { if (auto impl = GetPPMImpl()) {
impl->AddBlocker(aParent); impl->AddBlocker(aParent);
@@ -414,11 +412,11 @@ void PreallocatedProcessManager::AddBlocker(const nsAString& aRemoteType,
} }
/* static */ /* static */
void PreallocatedProcessManager::RemoveBlocker(const nsAString& aRemoteType, void PreallocatedProcessManager::RemoveBlocker(const nsACString& 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)",
NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent, PromiseFlatCString(aRemoteType).get(), aParent,
PreallocatedProcessManagerImpl::sNumBlockers)); PreallocatedProcessManagerImpl::sNumBlockers));
if (auto impl = GetPPMImpl()) { if (auto impl = GetPPMImpl()) {
impl->RemoveBlocker(aParent); impl->RemoveBlocker(aParent);
@@ -427,7 +425,7 @@ void PreallocatedProcessManager::RemoveBlocker(const nsAString& aRemoteType,
/* static */ /* static */
already_AddRefed<ContentParent> PreallocatedProcessManager::Take( already_AddRefed<ContentParent> PreallocatedProcessManager::Take(
const nsAString& aRemoteType) { const nsACString& 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 nsAString& aRemoteType, ContentParent* aParent); static void AddBlocker(const nsACString& aRemoteType, ContentParent* aParent);
static void RemoveBlocker(const nsAString& aRemoteType, static void RemoveBlocker(const nsACString& 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 nsAString& aRemoteType); static already_AddRefed<ContentParent> Take(const nsACString& 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 nsAString& GetRemoteType() const = 0; virtual const nsACString& 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().EqualsLiteral(EXTENSION_REMOTE_TYPE) || mContentParent->GetRemoteType() == EXTENSION_REMOTE_TYPE ||
mHoldsPlayingAudioWakeLock) { mHoldsPlayingAudioWakeLock) {
return PROCESS_PRIORITY_FOREGROUND; return PROCESS_PRIORITY_FOREGROUND;
} }

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 nsAString& GetRemoteType() = 0; virtual const nsACString& 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.Assign(VoidString()); options.mRemoteType.Assign(VoidCString());
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 nsAString& WindowGlobalChild::GetRemoteType() { const nsACString& WindowGlobalChild::GetRemoteType() {
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
return ContentChild::GetSingleton()->GetRemoteType(); return ContentChild::GetSingleton()->GetRemoteType();
} }
return VoidString(); return VoidCString();
} }
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 nsAString& GetRemoteType() override; const nsACString& 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 nsAString& WindowGlobalParent::GetRemoteType() { const nsACString& WindowGlobalParent::GetRemoteType() {
if (RefPtr<BrowserParent> browserParent = GetBrowserParent()) { if (RefPtr<BrowserParent> browserParent = GetBrowserParent()) {
return browserParent->Manager()->GetRemoteType(); return browserParent->Manager()->GetRemoteType();
} }
return VoidString(); return VoidCString();
} }
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 nsAString& GetRemoteType() override; const nsACString& 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(
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); 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 nsDependentSubstring& aRemoteType) { const nsDependentCSubstring& 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 nsAString& aRemoteType) { bool JSProcessActorProtocol::Matches(const nsACString& 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 nsAString& aRemoteType); bool Matches(const nsACString& aRemoteType);
private: private:
explicit JSProcessActorProtocol(const nsACString& aName) : mName(aName) {} explicit JSProcessActorProtocol(const nsACString& aName) : mName(aName) {}
bool RemoteTypePrefixMatches(const nsDependentSubstring& aRemoteType); bool RemoteTypePrefixMatches(const nsDependentCSubstring& aRemoteType);
~JSProcessActorProtocol() = default; ~JSProcessActorProtocol() = default;
nsCString mName; nsCString mName;
nsTArray<nsString> mRemoteTypes; nsTArray<nsCString> 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 nsDependentSubstring& aRemoteType) { const nsDependentCSubstring& 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 nsAString& aRemoteType) { const nsACString& 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 nsAString& aRemoteType); const nsACString& 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 nsDependentSubstring& aRemoteType); bool RemoteTypePrefixMatches(const nsDependentCSubstring& 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<nsString> mRemoteTypes; nsTArray<nsCString> mRemoteTypes;
nsTArray<nsString> mMessageManagerGroups; nsTArray<nsString> mMessageManagerGroups;
ParentSide mParent; ParentSide mParent;

View File

@@ -103,8 +103,7 @@ 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().EqualsLiteral( if (contentActors[i]->GetRemoteType() != DEFAULT_REMOTE_TYPE) {
DEFAULT_REMOTE_TYPE)) {
continue; continue;
} }

View File

@@ -763,7 +763,7 @@ static void DebugDoContentSecurityCheck(nsIChannel* aChannel,
/* static */ /* static */
void nsContentSecurityManager::MeasureUnexpectedPrivilegedLoads( void nsContentSecurityManager::MeasureUnexpectedPrivilegedLoads(
nsIURI* aFinalURI, nsContentPolicyType aContentPolicyType, nsIURI* aFinalURI, nsContentPolicyType aContentPolicyType,
const nsAString& aRemoteType) { const nsACString& aRemoteType) {
if (!StaticPrefs::dom_security_unexpected_system_load_telemetry_enabled()) { if (!StaticPrefs::dom_security_unexpected_system_load_telemetry_enabled()) {
return; return;
} }
@@ -784,8 +784,7 @@ void nsContentSecurityManager::MeasureUnexpectedPrivilegedLoads(
} }
// sanitize remoteType because it may contain sensitive // sanitize remoteType because it may contain sensitive
// info, like URLs. e.g. `webIsolated=https://example.com` // info, like URLs. e.g. `webIsolated=https://example.com`
nsAutoCString loggedRemoteType = nsAutoCString loggedRemoteType(dom::RemoteTypePrefix(aRemoteType));
NS_ConvertUTF16toUTF8(dom::RemoteTypePrefix(aRemoteType));
nsAutoCString loggedContentType(NS_CP_ContentTypeName(aContentPolicyType)); nsAutoCString loggedContentType(NS_CP_ContentTypeName(aContentPolicyType));
MOZ_LOG(sCSMLog, LogLevel::Debug, ("UnexpectedPrivilegedLoadTelemetry:\n")); MOZ_LOG(sCSMLog, LogLevel::Debug, ("UnexpectedPrivilegedLoadTelemetry:\n"));
@@ -867,7 +866,7 @@ nsresult nsContentSecurityManager::CheckAllowLoadInSystemPrivilegedContext(
} }
} }
nsAutoString remoteType; nsAutoCString remoteType;
if (XRE_IsParentProcess()) { if (XRE_IsParentProcess()) {
nsCOMPtr<nsIParentChannel> parentChannel; nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(aChannel, parentChannel); NS_QueryNotificationCallbacks(aChannel, parentChannel);

View File

@@ -39,7 +39,7 @@ class nsContentSecurityManager : public nsIContentSecurityManager,
static bool AllowInsecureRedirectToDataURI(nsIChannel* aNewChannel); static bool AllowInsecureRedirectToDataURI(nsIChannel* aNewChannel);
static void MeasureUnexpectedPrivilegedLoads( static void MeasureUnexpectedPrivilegedLoads(
nsIURI* aFinalURI, nsContentPolicyType aContentPolicyType, nsIURI* aFinalURI, nsContentPolicyType aContentPolicyType,
const nsAString& aRemoteType); const nsACString& aRemoteType);
private: private:
static nsresult CheckChannel(nsIChannel* aChannel); static nsresult CheckChannel(nsIChannel* aChannel);

View File

@@ -33,7 +33,7 @@ TEST_F(TelemetryTestFixture, UnexpectedPrivilegedLoadsTelemetryTest) {
struct testCasesAndResults { struct testCasesAndResults {
nsCString urlstring; nsCString urlstring;
nsContentPolicyType contentType; nsContentPolicyType contentType;
nsString remoteType; nsCString remoteType;
testResults expected; testResults expected;
}; };
@@ -54,36 +54,36 @@ TEST_F(TelemetryTestFixture, UnexpectedPrivilegedLoadsTelemetryTest) {
testCasesAndResults myTestCases[] = { testCasesAndResults myTestCases[] = {
{"chrome://firegestures/content/browser.js"_ns, {"chrome://firegestures/content/browser.js"_ns,
nsIContentPolicy::TYPE_SCRIPT, nsIContentPolicy::TYPE_SCRIPT,
u"default"_ns, "default"_ns,
{"chromeuri"_ns, "TYPE_SCRIPT"_ns, "default"_ns, {"chromeuri"_ns, "TYPE_SCRIPT"_ns, "default"_ns,
"chrome://firegestures/content/browser.js"_ns}}, "chrome://firegestures/content/browser.js"_ns}},
{"resource://firegestures/content/browser.js"_ns, {"resource://firegestures/content/browser.js"_ns,
nsIContentPolicy::TYPE_SCRIPT, nsIContentPolicy::TYPE_SCRIPT,
u"default"_ns, "default"_ns,
{"resourceuri"_ns, "TYPE_SCRIPT"_ns, "default"_ns, {"resourceuri"_ns, "TYPE_SCRIPT"_ns, "default"_ns,
"resource://firegestures/content/browser.js"_ns}}, "resource://firegestures/content/browser.js"_ns}},
{// test that we don't report blob details {// test that we don't report blob details
// ..and test that we strip of URLs from remoteTypes // ..and test that we strip of URLs from remoteTypes
"blob://000-000"_ns, "blob://000-000"_ns,
nsIContentPolicy::TYPE_SCRIPT, nsIContentPolicy::TYPE_SCRIPT,
u"webIsolated=https://blob.example/"_ns, "webIsolated=https://blob.example/"_ns,
{"bloburi"_ns, "TYPE_SCRIPT"_ns, "webIsolated"_ns, "unknown"_ns}}, {"bloburi"_ns, "TYPE_SCRIPT"_ns, "webIsolated"_ns, "unknown"_ns}},
{// test for cases where finalURI is null, due to a broken nested URI {// test for cases where finalURI is null, due to a broken nested URI
// .. like malformed moz-icon URLs // .. like malformed moz-icon URLs
"moz-icon:blahblah"_ns, "moz-icon:blahblah"_ns,
nsIContentPolicy::TYPE_IMAGE, nsIContentPolicy::TYPE_IMAGE,
u"default"_ns, "default"_ns,
{"other"_ns, "TYPE_IMAGE"_ns, "default"_ns, "unknown"_ns}}, {"other"_ns, "TYPE_IMAGE"_ns, "default"_ns, "unknown"_ns}},
{// we dont report data urls {// we dont report data urls
// ..and test that we strip of URLs from remoteTypes // ..and test that we strip of URLs from remoteTypes
"data://blahblahblah"_ns, "data://blahblahblah"_ns,
nsIContentPolicy::TYPE_DOCUMENT, nsIContentPolicy::TYPE_DOCUMENT,
u"webCOOP+COEP=https://data.example"_ns, "webCOOP+COEP=https://data.example"_ns,
{"dataurl"_ns, "TYPE_DOCUMENT"_ns, "webCOOP+COEP"_ns, "unknown"_ns}}, {"dataurl"_ns, "TYPE_DOCUMENT"_ns, "webCOOP+COEP"_ns, "unknown"_ns}},
{// we only report file URLs on windows, where we can easily sanitize {// we only report file URLs on windows, where we can easily sanitize
"file://c/users/tom/file.txt"_ns, "file://c/users/tom/file.txt"_ns,
nsIContentPolicy::TYPE_SCRIPT, nsIContentPolicy::TYPE_SCRIPT,
u"default"_ns, "default"_ns,
{ {
#if defined(XP_WIN) #if defined(XP_WIN)
"sanitizedWindowsURL"_ns, "TYPE_SCRIPT"_ns, "default"_ns, "sanitizedWindowsURL"_ns, "TYPE_SCRIPT"_ns, "default"_ns,

View File

@@ -5,7 +5,7 @@
*/ */
dictionary RemotenessOptions { dictionary RemotenessOptions {
required DOMString? remoteType; required UTF8String? 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 nsAString& processRemoteType, bool RemoteWorkerManager::MatchRemoteType(const nsACString& processRemoteType,
const nsAString& workerRemoteType) { const nsACString& workerRemoteType) {
if (processRemoteType.Equals(workerRemoteType)) { if (processRemoteType.Equals(workerRemoteType)) {
return true; return true;
} }
@@ -89,7 +89,7 @@ bool RemoteWorkerManager::MatchRemoteType(const nsAString& processRemoteType,
} }
// static // static
Result<nsString, nsresult> RemoteWorkerManager::GetRemoteType( Result<nsCString, nsresult> RemoteWorkerManager::GetRemoteType(
const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType) { const nsCOMPtr<nsIPrincipal>& aPrincipal, WorkerType aWorkerType) {
AssertIsOnMainThread(); AssertIsOnMainThread();
@@ -100,7 +100,7 @@ Result<nsString, nsresult> RemoteWorkerManager::GetRemoteType(
return Err(NS_ERROR_UNEXPECTED); return Err(NS_ERROR_UNEXPECTED);
} }
nsString remoteType; nsCString remoteType = VoidCString();
// 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,23 +131,21 @@ Result<nsString, nsresult> RemoteWorkerManager::GetRemoteType(
"browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", false); "browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", false);
if (isMozExtension) { if (isMozExtension) {
remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE)); remoteType = 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.Assign( remoteType = PRIVILEGEDMOZILLA_REMOTE_TYPE;
NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE)); } else if (aWorkerType == WorkerType::WorkerTypeShared && contentChild) {
remoteType = contentChild->GetRemoteType();
} else { } else {
remoteType.Assign( remoteType = DEFAULT_REMOTE_TYPE;
aWorkerType == WorkerType::WorkerTypeShared && contentChild
? contentChild->GetRemoteType()
: NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
} }
} else { } else {
remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); remoteType = DEFAULT_REMOTE_TYPE;
} }
return remoteType; return remoteType;
@@ -349,7 +347,7 @@ void RemoteWorkerManager::AsyncCreationFailed(
} }
/* static */ /* static */
nsString RemoteWorkerManager::GetRemoteTypeForActor( nsCString RemoteWorkerManager::GetRemoteTypeForActor(
const RemoteWorkerServiceParent* aActor) { const RemoteWorkerServiceParent* aActor) {
AssertIsInMainProcess(); AssertIsInMainProcess();
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
@@ -362,10 +360,10 @@ nsString RemoteWorkerManager::GetRemoteTypeForActor(
MakeScopeExit([&] { NS_ReleaseOnMainThread(contentParent.forget()); }); MakeScopeExit([&] { NS_ReleaseOnMainThread(contentParent.forget()); });
if (NS_WARN_IF(!contentParent)) { if (NS_WARN_IF(!contentParent)) {
return EmptyString(); return EmptyCString();
} }
nsString aRemoteType(contentParent->GetRemoteType()); nsCString aRemoteType(contentParent->GetRemoteType());
return aRemoteType; return aRemoteType;
} }
@@ -551,7 +549,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 nsString& remoteType) mutable { const nsCString& remoteType) mutable {
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
if (isServiceWorker) { if (isServiceWorker) {
TransmitPermissionsAndBlobURLsForPrincipalInfo(aValue.ResolveValue(), TransmitPermissionsAndBlobURLsForPrincipalInfo(aValue.ResolveValue(),
@@ -588,9 +586,7 @@ 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() workerRemoteType.IsEmpty() ? DEFAULT_REMOTE_TYPE : workerRemoteType;
? 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 nsAString& processRemoteType, static bool MatchRemoteType(const nsACString& processRemoteType,
const nsAString& workerRemoteType); const nsACString& 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<nsString, nsresult> GetRemoteType( static Result<nsCString, 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 nsString GetRemoteTypeForActor( static nsCString 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.
nsString remoteType; nsCString remoteType;
}; };
// ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote // ErrorData/ErrorDataNote correspond to WorkerErrorReport/WorkerErrorNote

View File

@@ -12,54 +12,39 @@ using namespace mozilla::dom;
TEST(RemoteWorkerManager, TestMatchRemoteType) TEST(RemoteWorkerManager, TestMatchRemoteType)
{ {
static const struct { static const struct {
const nsString processRemoteType; const nsCString processRemoteType;
const nsString workerRemoteType; const nsCString 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.
{NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), {DEFAULT_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true},
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true}, {EXTENSION_REMOTE_TYPE, EXTENSION_REMOTE_TYPE, true},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), {PRIVILEGEDMOZILLA_REMOTE_TYPE, PRIVILEGEDMOZILLA_REMOTE_TYPE, true},
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.
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE), {PRIVILEGEDMOZILLA_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false},
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false}, {PRIVILEGEDABOUT_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDABOUT_REMOTE_TYPE), {EXTENSION_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false},
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false}, {FILE_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, false},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), {WITH_COOP_COEP_REMOTE_TYPE_PREFIX, DEFAULT_REMOTE_TYPE, false},
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.
{NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE), {LARGE_ALLOCATION_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true},
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true}, {FISSION_WEB_REMOTE_TYPE, 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.
{NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), EmptyString(), {DEFAULT_REMOTE_TYPE, VoidCString(), true},
true}, {WITH_COOP_COEP_REMOTE_TYPE_PREFIX, VoidCString(), false},
{NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX), {PRIVILEGEDMOZILLA_REMOTE_TYPE, VoidCString(), false},
EmptyString(), false}, {EXTENSION_REMOTE_TYPE, VoidCString(), 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 = auto message = nsPrintfCString(
nsPrintfCString(R"(MatchRemoteType("%s", "%s") should return %s)", R"(MatchRemoteType("%s", "%s") should return %s)",
NS_ConvertUTF16toUTF8(test.processRemoteType).get(), test.processRemoteType.get(), test.workerRemoteType.get(),
NS_ConvertUTF16toUTF8(test.workerRemoteType).get(), test.shouldMatch ? "true" : "false");
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().EqualsLiteral(FILE_REMOTE_TYPE); isFileRemoteType = parent->GetRemoteType() == 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 nsAString& remoteType) { ProcessType ScriptPreloader::GetChildProcessType(const nsACString& remoteType) {
if (remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) { if (remoteType == EXTENSION_REMOTE_TYPE) {
return ProcessType::Extension; return ProcessType::Extension;
} }
if (remoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) { if (remoteType == 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 nsAString& remoteType); static ProcessType GetChildProcessType(const nsACString& 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(nsAString& aRemoteType) { SimpleChannelParent::GetRemoteType(nsACString& 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 AString remoteType; readonly attribute AUTF8String remoteType;
}; };

View File

@@ -1314,7 +1314,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
return false; return false;
} }
nsAutoString currentRemoteType(VoidString()); nsAutoCString currentRemoteType(VoidCString());
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.
nsAutoString preferredRemoteType(currentRemoteType); nsAutoCString preferredRemoteType(currentRemoteType);
bool replaceBrowsingContext = false; bool replaceBrowsingContext = false;
uint64_t specificGroupId = 0; uint64_t specificGroupId = 0;
@@ -1370,13 +1370,12 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// high-resolution timers. // high-resolution timers.
nsAutoCString siteOrigin; nsAutoCString siteOrigin;
resultPrincipal->GetSiteOrigin(siteOrigin); resultPrincipal->GetSiteOrigin(siteOrigin);
preferredRemoteType = preferredRemoteType = WITH_COOP_COEP_REMOTE_TYPE_PREFIX;
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX); preferredRemoteType.Append(siteOrigin);
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 = NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE); preferredRemoteType = DEFAULT_REMOTE_TYPE;
} }
} }
@@ -1387,12 +1386,10 @@ 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 = preferredRemoteType = LARGE_ALLOCATION_REMOTE_TYPE;
NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE);
replaceBrowsingContext = true; replaceBrowsingContext = true;
} else if (preferredRemoteType.EqualsLiteral( } else if (preferredRemoteType == LARGE_ALLOCATION_REMOTE_TYPE) {
LARGE_ALLOCATION_REMOTE_TYPE)) { preferredRemoteType = DEFAULT_REMOTE_TYPE;
preferredRemoteType = NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE);
replaceBrowsingContext = true; replaceBrowsingContext = true;
} }
} }
@@ -1404,10 +1401,9 @@ 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 = preferredRemoteType = EXTENSION_REMOTE_TYPE;
NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE);
} else { } else {
preferredRemoteType = VoidString(); preferredRemoteType = VoidCString();
} }
if (browsingContext->Group()->Id() != if (browsingContext->Group()->Id() !=
@@ -1426,8 +1422,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
LOG( LOG(
("DocumentLoadListener GetRemoteTypeForPrincipal " ("DocumentLoadListener GetRemoteTypeForPrincipal "
"[this=%p, contentParent=%s, preferredRemoteType=%s]", "[this=%p, contentParent=%s, preferredRemoteType=%s]",
this, NS_ConvertUTF16toUTF8(currentRemoteType).get(), this, currentRemoteType.get(), preferredRemoteType.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");
@@ -1442,7 +1437,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
currentPrincipal = wgp->DocumentPrincipal(); currentPrincipal = wgp->DocumentPrincipal();
} }
nsAutoString remoteType; nsAutoCString remoteType;
rv = e10sUtils->GetRemoteTypeForPrincipal( rv = e10sUtils->GetRemoteTypeForPrincipal(
resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(), resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(),
browsingContext->UseRemoteSubframes(), preferredRemoteType, browsingContext->UseRemoteSubframes(), preferredRemoteType,
@@ -1456,18 +1451,16 @@ 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.EqualsLiteral(EXTENSION_REMOTE_TYPE)) { currentRemoteType == EXTENSION_REMOTE_TYPE) {
replaceBrowsingContext = true; replaceBrowsingContext = true;
} }
LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s", LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s",
NS_ConvertUTF16toUTF8(currentRemoteType).get(), currentRemoteType.get(), remoteType.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", LOG(("Process Switch Abort: type (%s) is compatible", remoteType.get()));
NS_ConvertUTF16toUTF8(remoteType).get()));
return false; return false;
} }
@@ -1479,8 +1472,7 @@ 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'",
NS_ConvertUTF16toUTF8(currentRemoteType).get(), currentRemoteType.get(), remoteType.get()));
NS_ConvertUTF16toUTF8(remoteType).get()));
mDoingProcessSwitch = true; mDoingProcessSwitch = true;
@@ -2038,7 +2030,7 @@ DocumentLoadListener::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
DocumentLoadListener::GetRemoteType(nsAString& aRemoteType) { DocumentLoadListener::GetRemoteType(nsACString& aRemoteType) {
RefPtr<CanonicalBrowsingContext> browsingContext = GetBrowsingContext(); RefPtr<CanonicalBrowsingContext> browsingContext = GetBrowsingContext();
if (!browsingContext) { if (!browsingContext) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
@@ -2047,7 +2039,7 @@ DocumentLoadListener::GetRemoteType(nsAString& aRemoteType) {
ErrorResult error; ErrorResult error;
browsingContext->GetCurrentRemoteType(aRemoteType, error); browsingContext->GetCurrentRemoteType(aRemoteType, error);
if (error.Failed()) { if (error.Failed()) {
aRemoteType = VoidString(); aRemoteType = VoidCString();
} }
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().EqualsLiteral( if (static_cast<ContentParent*>(Manager())->GetRemoteType() !=
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(nsAString& aRemoteType) { ParentChannelWrapper::GetRemoteType(nsACString& aRemoteType) {
aRemoteType = VoidString(); aRemoteType = VoidCString();
return NS_OK; return NS_OK;
} }

View File

@@ -66,7 +66,7 @@ DataChannelParent::Delete() {
} }
NS_IMETHODIMP NS_IMETHODIMP
DataChannelParent::GetRemoteType(nsAString& aRemoteType) { DataChannelParent::GetRemoteType(nsACString& 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(nsAString& aRemoteType) { FileChannelParent::GetRemoteType(nsACString& 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(nsAString& aRemoteType) { FTPChannelParent::GetRemoteType(nsACString& 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(nsAString& aRemoteType) { HttpChannelParent::GetRemoteType(nsACString& 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().EqualsLiteral(FILE_REMOTE_TYPE); params.mFileProcess = cc->GetRemoteType() == FILE_REMOTE_TYPE;
nsAutoCString extraSyscalls; nsAutoCString extraSyscalls;
nsresult rv = Preferences::GetCString( nsresult rv = Preferences::GetCString(

View File

@@ -440,11 +440,11 @@ nsresult StartupCache::ParseStartupCacheCmdLineArgs(char* aScacheHandleStr,
return NS_OK; return NS_OK;
} }
ProcessType StartupCache::GetChildProcessType(const nsAString& remoteType) { ProcessType StartupCache::GetChildProcessType(const nsACString& remoteType) {
if (remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) { if (remoteType == EXTENSION_REMOTE_TYPE) {
return ProcessType::Extension; return ProcessType::Extension;
} }
if (remoteType.EqualsLiteral(PRIVILEGEDABOUT_REMOTE_TYPE)) { if (remoteType == PRIVILEGEDABOUT_REMOTE_TYPE) {
return ProcessType::PrivilegedAbout; return ProcessType::PrivilegedAbout;
} }
return ProcessType::Web; return ProcessType::Web;

View File

@@ -293,7 +293,7 @@ class StartupCache : public nsIMemoryReporter {
nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream, nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream,
nsIObjectOutputStream** outStream); nsIObjectOutputStream** outStream);
static ProcessType GetChildProcessType(const nsAString& remoteType); static ProcessType GetChildProcessType(const nsACString& remoteType);
static StartupCache* GetSingleton(); static StartupCache* GetSingleton();
// This will get the StartupCache up and running to get cached entries, but // This will get the StartupCache up and running to get cached entries, but

View File

@@ -505,7 +505,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime,
HangDetails hangDetails(aHangTime, HangDetails hangDetails(aHangTime,
nsDependentCString(XRE_GetProcessTypeString()), nsDependentCString(XRE_GetProcessTypeString()),
VoidString(), mThreadName, mRunnableName, VoidCString(), 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(nsAString& aName) { nsHangDetails::GetRemoteType(nsACString& 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<char16_t>(fd)); MOZ_TRY_VAR(result.remoteType(), ReadTString<char>(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;
nsString remoteType; nsCString 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 AString remoteType; readonly attribute AUTF8String 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.EqualsLiteral(EXTENSION_REMOTE_TYPE); return remoteType == 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.
*/ */
AString getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal, AUTF8String getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal,
in nsIURI aChannelOriginalURI, in nsIURI aChannelOriginalURI,
in boolean aMultiProcess, in boolean aMultiProcess,
in boolean aRemoteSubframes, in boolean aRemoteSubframes,
in AString aPreferredRemoteType, in AUTF8String aPreferredRemoteType,
in nsIPrincipal aCurrentPrincipal, in nsIPrincipal aCurrentPrincipal,
in boolean aIsSubframe); in boolean aIsSubframe);
}; };

View File

@@ -700,12 +700,12 @@ nsXULAppInfo::GetUniqueProcessID(uint64_t* aResult) {
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULAppInfo::GetRemoteType(nsAString& aRemoteType) { nsXULAppInfo::GetRemoteType(nsACString& aRemoteType) {
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
ContentChild* cc = ContentChild::GetSingleton(); ContentChild* cc = ContentChild::GetSingleton();
aRemoteType.Assign(cc->GetRemoteType()); aRemoteType.Assign(cc->GetRemoteType());
} else { } else {
SetDOMStringToNull(aRemoteType); aRemoteType = VoidCString();
} }
return NS_OK; return NS_OK;
@@ -844,7 +844,7 @@ nsXULAppInfo::EnsureContentProcess() {
if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE; if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE;
RefPtr<ContentParent> unused = ContentParent::GetNewOrUsedBrowserProcess( RefPtr<ContentParent> unused = ContentParent::GetNewOrUsedBrowserProcess(
nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); nullptr, 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 = ContentParent::GetNewOrUsedBrowserProcess( RefPtr<ContentParent> parent =
nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); ContentParent::GetNewOrUsedBrowserProcess(nullptr, 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 nsAString& aRemoteType) { const nsACString& 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 nsAString& aRemoteType); const nsACString& 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(nsAString& aRemoteType) { NS_IMETHODIMP nsExtProtocolChannel::GetRemoteType(nsACString& 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
nsString origin; nsCString 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 nsAString& origin, const nsACString& 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 nsAString& origin); const nsACString& 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 nsAString& origin) { const nsACString& 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 nsAString& origin, mach_port_t aChildTask) { const nsACString& 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.
nsString originCopy(origin); nsCString 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 nsAString& origin) { const nsACString& 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.
nsString originCopy(origin); nsCString 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 nsAString& origin) { const nsACString& 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.
nsString originCopy(origin); nsCString 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 AString remoteType; readonly attribute AUTF8String 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