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

CLOSED TREE

Backed out changeset 51d7c644a1e6 (bug 1650163)
Backed out changeset 3d2b6908447a (bug 1650163)
Backed out changeset 79141707d47b (bug 1650163)
This commit is contained in:
Mihai Alexandru Michis 2020-07-08 21:18:44 +03:00
Родитель 48c6c034ee
Коммит 1ba2a3f6f6
76 изменённых файлов: 368 добавлений и 341 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_RemoteType_h
#define mozilla_dom_RemoteType_h
#include "nsString.h"
#include "nsReadableUtils.h"
// These must match the similar ones in E10SUtils.jsm and ProcInfo.h.
// Process names as reported by about:memory are defined in
// ContentChild:RecvRemoteType. Add your value there too or it will be called
// "Web Content".
#define PREALLOC_REMOTE_TYPE "prealloc"_ns
#define DEFAULT_REMOTE_TYPE "web"_ns
#define FILE_REMOTE_TYPE "file"_ns
#define EXTENSION_REMOTE_TYPE "extension"_ns
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
// These must start with the DEFAULT_REMOTE_TYPE above.
#define FISSION_WEB_REMOTE_TYPE "webIsolated"_ns
#define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP="_ns
#define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation"_ns
// Remote type value used to represent being non-remote.
#define NOT_REMOTE_TYPE VoidCString()
#endif // mozilla_dom_RemoteType_h

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -5,7 +5,7 @@
*/
dictionary RemotenessOptions {
required UTF8String? remoteType;
required DOMString? remoteType;
// 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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -55,7 +55,7 @@ nsHangDetails::GetProcess(nsACString& aName) {
}
NS_IMETHODIMP
nsHangDetails::GetRemoteType(nsACString& aName) {
nsHangDetails::GetRemoteType(nsAString& aName) {
aName.Assign(mDetails.remoteType());
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.runnableName(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.process(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.remoteType(), ReadTString<char>(fd));
MOZ_TRY_VAR(result.remoteType(), ReadTString<char16_t>(fd));
uint32_t numAnnotations;
MOZ_TRY_VAR(numAnnotations, ReadUint(fd));

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -20,7 +20,7 @@
namespace mozilla {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& type,
const nsACString& origin, mach_port_t aChildTask) {
const nsAString& origin, mach_port_t aChildTask) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
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.
nsCString originCopy(origin);
nsString originCopy(origin);
auto ResolveGetProcinfo = [holder = std::move(holder), pid, type,
originCopy = std::move(originCopy), childId, aChildTask]() {
ProcInfo info;

Просмотреть файл

@ -211,7 +211,7 @@ class ThreadInfoReader final : public StatReader {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& type,
const nsACString& origin) {
const nsAString& origin) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__);
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.
nsCString originCopy(origin);
nsString originCopy(origin);
RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, [holder = std::move(holder), pid, type,
originCopy = std::move(originCopy), childId]() {

Просмотреть файл

@ -77,7 +77,7 @@ void AppendThreads(ProcInfo* info) {
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
const ProcType& type,
const nsACString& origin) {
const nsAString& origin) {
auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
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.
nsCString originCopy(origin);
nsString originCopy(origin);
RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__,
[holder = std::move(holder), originCopy = std::move(originCopy), pid,

Просмотреть файл

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