diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index 9927a11420e7..1471e10bf0db 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -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 aboutNewTabService = do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 68ddbf5cb1d8..99742118c8ee 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -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; } } diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 84026f2bcadb..e37733bea7c1 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -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() { diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index afc6d2f845e1..6fb0336a9456 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -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::ChangeRemoteness(const nsACString& aRemoteType, +CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType, uint64_t aPendingSwitchId, bool aReplaceBrowsingContext, uint64_t aSpecificGroupId) { diff --git a/docshell/base/CanonicalBrowsingContext.h b/docshell/base/CanonicalBrowsingContext.h index 5fa55545d7d4..d62e583d53f3 100644 --- a/docshell/base/CanonicalBrowsingContext.h +++ b/docshell/base/CanonicalBrowsingContext.h @@ -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, nsresult, false>; - RefPtr ChangeRemoteness(const nsACString& aRemoteType, + RefPtr ChangeRemoteness(const nsAString& aRemoteType, uint64_t aPendingSwitchId, bool aReplaceBrowsingContext, uint64_t aSpecificGroupId); diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index baca12862dbd..9614b5d48430 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -795,7 +795,7 @@ already_AddRefed 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 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 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(); diff --git a/dom/base/MessageManagerGlobal.h b/dom/base/MessageManagerGlobal.h index 7e445e5bee38..16e6e00cd165 100644 --- a/dom/base/MessageManagerGlobal.h +++ b/dom/base/MessageManagerGlobal.h @@ -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; diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 4ff0cbac2ee7..3f840fafee98 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -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"); diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index 1bd4d736604d..74337525c5f3 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -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 mSessionStoreListener; - nsCString mRemoteType; + nsString mRemoteType; bool mDepthTooGreat : 1; bool mIsTopLevelContent : 1; diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 024566814b42..7673869803ba 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -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) { diff --git a/dom/base/nsFrameMessageManager.h b/dom/base/nsFrameMessageManager.h index 48fe72d70e36..75cb09040278 100644 --- a/dom/base/nsFrameMessageManager.h +++ b/dom/base/nsFrameMessageManager.h @@ -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 GetProcessMessageManager(mozilla::ErrorResult& aError); - void GetRemoteType(nsACString& aRemoteType, + void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) const; // SyncMessageSender diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index 0b35cc8fe8ac..f3252a11cd5d 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -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; diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index 974123cc2683..2f7ab48e9c2e 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -555,7 +555,7 @@ dictionary ChildProcInfoDictionary { sequence threads = []; // Firefox info unsigned long long ChildID = 0; - UTF8String origin = ""; + DOMString origin = ""; WebIDLProcType type = "web"; }; diff --git a/dom/chrome-webidl/JSProcessActor.webidl b/dom/chrome-webidl/JSProcessActor.webidl index ba944f95fc2b..eea710b4d6fc 100644 --- a/dom/chrome-webidl/JSProcessActor.webidl +++ b/dom/chrome-webidl/JSProcessActor.webidl @@ -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 remoteTypes; + sequence remoteTypes; /** This fields are used for configuring individual sides of the actor. */ ProcessActorSidedOptions parent; diff --git a/dom/chrome-webidl/JSWindowActor.webidl b/dom/chrome-webidl/JSWindowActor.webidl index fa66a6893b32..f23f0aa0af05 100644 --- a/dom/chrome-webidl/JSWindowActor.webidl +++ b/dom/chrome-webidl/JSWindowActor.webidl @@ -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 remoteTypes; + sequence remoteTypes; /** * An array of MessageManagerGroup values which restrict which type diff --git a/dom/chrome-webidl/MessageManager.webidl b/dom/chrome-webidl/MessageManager.webidl index 99d026f5d887..6c2fb5fda653 100644 --- a/dom/chrome-webidl/MessageManager.webidl +++ b/dom/chrome-webidl/MessageManager.webidl @@ -322,7 +322,7 @@ interface mixin MessageSenderMixin { * Otherwise, it is empty. */ [Throws] - readonly attribute UTF8String remoteType; + readonly attribute DOMString remoteType; }; [ChromeOnly, Exposed=Window] diff --git a/dom/interfaces/base/nsIContentProcess.idl b/dom/interfaces/base/nsIContentProcess.idl index 198bb093a6ec..6bc52faf923b 100644 --- a/dom/interfaces/base/nsIContentProcess.idl +++ b/dom/interfaces/base/nsIContentProcess.idl @@ -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 aAliveProcesses, in uint32_t aMaxCount); }; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 8d9913e51529..a5ec5802ef26 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -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) { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 03edaaf33df0..c1d821be5867 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -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; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 395d7983788a..b65a8e1ce54e 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -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>* +nsClassHashtable>* ContentParent::sBrowserContentParents; namespace { @@ -570,13 +570,13 @@ 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 - : ProcessID::Content; + return remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) ? ProcessID::Extension + : ProcessID::Content; } } // anonymous namespace @@ -638,10 +638,11 @@ static const char* sObserverTopics[] = { // ContentParent then takes this process back within GetNewOrUsedBrowserProcess. /*static*/ RefPtr ContentParent::PreallocateProcess() { - RefPtr process = new ContentParent(PREALLOC_REMOTE_TYPE); + RefPtr 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::GetOrCreatePool( - const nsACString& aContentProcessType) { + const nsAString& aContentProcessType) { if (!sBrowserContentParents) { sBrowserContentParents = - new nsClassHashtable>; + new nsClassHashtable>; } 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,9 +781,10 @@ void ContentParent::ReleaseCachedProcesses() { nsTArray* contentParents = iter.Data().get(); num += contentParents->Length(); for (auto* cp : *contentParents) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("%s: %zu processes", cp->mRemoteType.get(), - contentParents->Length())); + 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::MinTabSelect( /*static*/ already_AddRefed ContentParent::GetUsedBrowserProcess( - const nsACString& aRemoteType, nsTArray& aContentParents, + const nsAString& aRemoteType, nsTArray& aContentParents, uint32_t aMaxContentParents, bool aPreferUsed) { #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED AutoRestore ar(sInProcessSelector); @@ -896,7 +902,7 @@ already_AddRefed 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::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::GetUsedBrowserProcess( // try to reuse a process that is being shut down. RefPtr 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::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::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::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,22 +982,25 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( /*static*/ already_AddRefed -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& 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, - /*aPreferUsed =*/false); + return GetNewOrUsedLaunchingBrowserProcess( + aFrameElement, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), + aPriority, + /*aPreferUsed =*/false); } // Let's try and reuse an existing process. @@ -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::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::GetNewOrUsedBrowserProcess( - Element* aFrameElement, const nsACString& aRemoteType, + Element* aFrameElement, const nsAString& aRemoteType, ProcessPriority aPriority, bool aPreferUsed) { RefPtr contentParent = GetNewOrUsedLaunchingBrowserProcess( aFrameElement, aRemoteType, aPriority, aPreferUsed); @@ -1303,7 +1312,7 @@ mozilla::ipc::IPCResult ContentParent::RecvLaunchRDDProcess( /*static*/ already_AddRefed 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 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 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& 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::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 policy = sSandboxBrokerPolicyFactory->GetContentPolicy(Pid(), isFileProcess); if (policy) { @@ -3191,8 +3201,8 @@ ContentParent::GetName(nsAString& aName) { NS_IMETHODIMP ContentParent::GetState(nsIPropertyBag** aResult) { auto props = MakeRefPtr(); - props->SetPropertyAsACString(u"remoteTypePrefix"_ns, - RemoteTypePrefix(mRemoteType)); + props->SetPropertyAsAString(u"remoteTypePrefix"_ns, + RemoteTypePrefix(mRemoteType)); *aResult = props.forget().downcast().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 diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 3639c661afa4..4efc42b57db7 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -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 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 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 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 CreateBrowser( const TabContext& aContext, Element* aFrameElement, - const nsACString& aRemoteType, BrowsingContext* aBrowsingContext, + const nsAString& aRemoteType, BrowsingContext* aBrowsingContext, ContentParent* aOpenerContentParent); static void GetAll(nsTArray& 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>* + static nsClassHashtable>* sBrowserContentParents; static UniquePtr> sPrivateContent; static UniquePtr> @@ -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& GetOrCreatePool( - const nsACString& aContentProcessType); + const nsAString& aContentProcessType); mozilla::ipc::IPCResult RecvInitBackground( Endpoint&& aEndpoint); @@ -1355,7 +1370,7 @@ class ContentParent final private: // Return an existing ContentParent if possible. Otherwise, `nullptr`. static already_AddRefed GetUsedBrowserProcess( - const nsACString& aRemoteType, nsTArray& aContentParents, + const nsAString& aRemoteType, nsTArray& aContentParents, uint32_t aMaxContentParents, bool aPreferUsed); void AddToPool(nsTArray&); @@ -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(aContentParent); diff --git a/dom/ipc/InProcessChild.h b/dom/ipc/InProcessChild.h index c90e9f7157d6..d6d0d6a29f30 100644 --- a/dom/ipc/InProcessChild.h +++ b/dom/ipc/InProcessChild.h @@ -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 InitJSActor(JS::HandleObject aMaybeActor, diff --git a/dom/ipc/InProcessParent.h b/dom/ipc/InProcessParent.h index 6a4acc7e77ec..46ec01185248 100644 --- a/dom/ipc/InProcessParent.h +++ b/dom/ipc/InProcessParent.h @@ -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 InitJSActor(JS::HandleObject aMaybeActor, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index c0d933962b8d..a272b8275a48 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -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. diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index e0ee153c6f90..79695c9622ab 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -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 Take(const nsACString& aRemoteType); + already_AddRefed Take(const nsAString& aRemoteType); bool Provide(ContentParent* aParent); void Erase(ContentParent* aParent); @@ -190,17 +190,17 @@ void PreallocatedProcessManagerImpl::RereadPrefs() { } already_AddRefed PreallocatedProcessManagerImpl::Take( - const nsACString& aRemoteType) { + const nsAString& aRemoteType) { if (!mEnabled || sShutdown) { return nullptr; } RefPtr 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 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 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 PreallocatedProcessManager::Take( - const nsACString& aRemoteType) { + const nsAString& aRemoteType) { if (auto impl = GetPPMImpl()) { return impl->Take(aRemoteType); } diff --git a/dom/ipc/PreallocatedProcessManager.h b/dom/ipc/PreallocatedProcessManager.h index ed70b516a168..a06c91eb8bd7 100644 --- a/dom/ipc/PreallocatedProcessManager.h +++ b/dom/ipc/PreallocatedProcessManager.h @@ -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 Take(const nsACString& aRemoteType); + static already_AddRefed Take(const nsAString& aRemoteType); /** * Cache a process (currently only DEFAULT_REMOTE_TYPE) for reuse later diff --git a/dom/ipc/ProcessActor.h b/dom/ipc/ProcessActor.h index f0b72382dbfb..cd2b9abe8a11 100644 --- a/dom/ipc/ProcessActor.h +++ b/dom/ipc/ProcessActor.h @@ -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 diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index a2ee913323e3..a4aaae307450 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -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; } diff --git a/dom/ipc/RemoteType.h b/dom/ipc/RemoteType.h deleted file mode 100644 index b79c97f8c9be..000000000000 --- a/dom/ipc/RemoteType.h +++ /dev/null @@ -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 diff --git a/dom/ipc/WindowGlobalActor.h b/dom/ipc/WindowGlobalActor.h index 0957e67ffea0..5aa8eb74d5f8 100644 --- a/dom/ipc/WindowGlobalActor.h +++ b/dom/ipc/WindowGlobalActor.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( diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index b1f446db4395..1e051dcbffed 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -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 WindowGlobalChild::GetActor( diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index 3711cbeec27b..126583585f7b 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -111,7 +111,7 @@ class WindowGlobalChild final : public WindowGlobalActor, JS::Handle aGivenProto) override; protected: - const nsACString& GetRemoteType() override; + const nsAString& GetRemoteType() override; already_AddRefed InitJSActor(JS::HandleObject aMaybeActor, const nsACString& aName, diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 84eee3060d5f..1f82a796673f 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -425,12 +425,12 @@ IPCResult WindowGlobalParent::RecvRawMessage(const JSActorMessageMeta& aMeta, return IPC_OK(); } -const nsACString& WindowGlobalParent::GetRemoteType() { +const nsAString& WindowGlobalParent::GetRemoteType() { if (RefPtr browserParent = GetBrowserParent()) { return browserParent->Manager()->GetRemoteType(); } - return NOT_REMOTE_TYPE; + return VoidString(); } void WindowGlobalParent::NotifyContentBlockingEvent( diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 61a3a5487c3b..3eabd962e175 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -194,7 +194,7 @@ class WindowGlobalParent final : public WindowContext, nsITransportSecurityInfo* GetSecurityInfo() { return mSecurityInfo; } - const nsACString& GetRemoteType() override; + const nsAString& GetRemoteType() override; protected: already_AddRefed InitJSActor(JS::HandleObject aMaybeActor, diff --git a/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp b/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp index a5067057023b..ef26fea6c6fc 100644 --- a/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp +++ b/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp @@ -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 ignored = mozilla::ipc::LoadIPCMessageBlacklist( getenv("MOZ_IPC_MESSAGE_FUZZ_BLACKLIST")); diff --git a/dom/ipc/jsactor/JSProcessActorProtocol.cpp b/dom/ipc/jsactor/JSProcessActorProtocol.cpp index 7568d76957e3..eb796740657f 100644 --- a/dom/ipc/jsactor/JSProcessActorProtocol.cpp +++ b/dom/ipc/jsactor/JSProcessActorProtocol.cpp @@ -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; diff --git a/dom/ipc/jsactor/JSProcessActorProtocol.h b/dom/ipc/jsactor/JSProcessActorProtocol.h index b6440a493d2a..f54d6e8fd5cb 100644 --- a/dom/ipc/jsactor/JSProcessActorProtocol.h +++ b/dom/ipc/jsactor/JSProcessActorProtocol.h @@ -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 mRemoteTypes; + nsTArray mRemoteTypes; ParentSide mParent; ChildSide mChild; diff --git a/dom/ipc/jsactor/JSWindowActorProtocol.cpp b/dom/ipc/jsactor/JSWindowActorProtocol.cpp index 1d15439117dd..8e78aa8e49a9 100644 --- a/dom/ipc/jsactor/JSWindowActorProtocol.cpp +++ b/dom/ipc/jsactor/JSWindowActorProtocol.cpp @@ -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!"); diff --git a/dom/ipc/jsactor/JSWindowActorProtocol.h b/dom/ipc/jsactor/JSWindowActorProtocol.h index 452d4d588bc9..014766f4562c 100644 --- a/dom/ipc/jsactor/JSWindowActorProtocol.h +++ b/dom/ipc/jsactor/JSWindowActorProtocol.h @@ -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 mMatches; - nsTArray mRemoteTypes; + nsTArray mRemoteTypes; nsTArray mMessageManagerGroups; ParentSide mParent; diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index 461c3cb9c97d..27ff1695cd06 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -60,7 +60,6 @@ EXPORTS.mozilla.dom += [ 'ReferrerInfoUtils.h', 'RefMessageBodyService.h', 'RemoteBrowser.h', - 'RemoteType.h', 'RemoteWebProgress.h', 'RemoteWebProgressRequest.h', 'SharedMessageBody.h', diff --git a/dom/push/PushNotifier.cpp b/dom/push/PushNotifier.cpp index d8806d081c55..59940ff53c74 100644 --- a/dom/push/PushNotifier.cpp +++ b/dom/push/PushNotifier.cpp @@ -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; } diff --git a/dom/webidl/MozFrameLoaderOwner.webidl b/dom/webidl/MozFrameLoaderOwner.webidl index 865f436fd066..320cf6010f5c 100644 --- a/dom/webidl/MozFrameLoaderOwner.webidl +++ b/dom/webidl/MozFrameLoaderOwner.webidl @@ -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 diff --git a/dom/workers/remoteworkers/RemoteWorkerManager.cpp b/dom/workers/remoteworkers/RemoteWorkerManager.cpp index 0f64f09879a8..72de3791ceb1 100644 --- a/dom/workers/remoteworkers/RemoteWorkerManager.cpp +++ b/dom/workers/remoteworkers/RemoteWorkerManager.cpp @@ -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 RemoteWorkerManager::GetRemoteType( +Result RemoteWorkerManager::GetRemoteType( const nsCOMPtr& aPrincipal, WorkerType aWorkerType) { AssertIsOnMainThread(); @@ -100,7 +100,7 @@ Result 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 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(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, diff --git a/dom/workers/remoteworkers/RemoteWorkerManager.h b/dom/workers/remoteworkers/RemoteWorkerManager.h index 86f97534ab2a..ecf5218498cc 100644 --- a/dom/workers/remoteworkers/RemoteWorkerManager.h +++ b/dom/workers/remoteworkers/RemoteWorkerManager.h @@ -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 GetRemoteType( + static Result GetRemoteType( const nsCOMPtr& 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 diff --git a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh index a282d6ee7f03..c9018fbc04bc 100644 --- a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh +++ b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh @@ -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 diff --git a/dom/workers/remoteworkers/gtest/TestMatchRemoteType.cpp b/dom/workers/remoteworkers/gtest/TestMatchRemoteType.cpp index 10016a52c2d7..916a77d44eab 100644 --- a/dom/workers/remoteworkers/gtest/TestMatchRemoteType.cpp +++ b/dom/workers/remoteworkers/gtest/TestMatchRemoteType.cpp @@ -12,39 +12,54 @@ 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(), - test.shouldMatch ? "true" : "false"); + 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), test.shouldMatch) diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 62679ad3500a..6412a4db7937 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -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()); } diff --git a/js/xpconnect/loader/ScriptPreloader.cpp b/js/xpconnect/loader/ScriptPreloader.cpp index 7e8e6844cf18..10b30331ebc8 100644 --- a/js/xpconnect/loader/ScriptPreloader.cpp +++ b/js/xpconnect/loader/ScriptPreloader.cpp @@ -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; diff --git a/js/xpconnect/loader/ScriptPreloader.h b/js/xpconnect/loader/ScriptPreloader.h index d0df0571658c..a26388dcffe4 100644 --- a/js/xpconnect/loader/ScriptPreloader.h +++ b/js/xpconnect/loader/ScriptPreloader.h @@ -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. diff --git a/netwerk/base/SimpleChannelParent.cpp b/netwerk/base/SimpleChannelParent.cpp index 01029d74ebde..c8617c2a7357 100644 --- a/netwerk/base/SimpleChannelParent.cpp +++ b/netwerk/base/SimpleChannelParent.cpp @@ -64,7 +64,7 @@ SimpleChannelParent::Delete() { } NS_IMETHODIMP -SimpleChannelParent::GetRemoteType(nsACString& aRemoteType) { +SimpleChannelParent::GetRemoteType(nsAString& aRemoteType) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/netwerk/base/nsIParentChannel.idl b/netwerk/base/nsIParentChannel.idl index 137d1907bdfb..6d6f487865d4 100644 --- a/netwerk/base/nsIParentChannel.idl +++ b/netwerk/base/nsIParentChannel.idl @@ -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; }; diff --git a/netwerk/ipc/DocumentLoadListener.cpp b/netwerk/ipc/DocumentLoadListener.cpp index b09c4ddde64d..fbb5dc9f3198 100644 --- a/netwerk/ipc/DocumentLoadListener.cpp +++ b/netwerk/ipc/DocumentLoadListener.cpp @@ -1314,7 +1314,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch( return false; } - nsAutoCString currentRemoteType(NOT_REMOTE_TYPE); + nsAutoString currentRemoteType(VoidString()); if (RefPtr 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 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 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; } diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 6dcd332d21c1..eaebfa069097 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -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(Manager())->GetRemoteType() != - PRIVILEGEDABOUT_REMOTE_TYPE) { + if (!static_cast(Manager())->GetRemoteType().EqualsLiteral( + PRIVILEGEDABOUT_REMOTE_TYPE)) { return IPC_FAIL(this, "Wrong process type"); } diff --git a/netwerk/ipc/ParentChannelWrapper.cpp b/netwerk/ipc/ParentChannelWrapper.cpp index c2c5eb858094..953cf4b1fcfd 100644 --- a/netwerk/ipc/ParentChannelWrapper.cpp +++ b/netwerk/ipc/ParentChannelWrapper.cpp @@ -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; } diff --git a/netwerk/protocol/data/DataChannelParent.cpp b/netwerk/protocol/data/DataChannelParent.cpp index 025cc2060e76..2c501faa3cee 100644 --- a/netwerk/protocol/data/DataChannelParent.cpp +++ b/netwerk/protocol/data/DataChannelParent.cpp @@ -66,7 +66,7 @@ DataChannelParent::Delete() { } NS_IMETHODIMP -DataChannelParent::GetRemoteType(nsACString& aRemoteType) { +DataChannelParent::GetRemoteType(nsAString& aRemoteType) { if (!CanSend()) { return NS_ERROR_UNEXPECTED; } diff --git a/netwerk/protocol/file/FileChannelParent.cpp b/netwerk/protocol/file/FileChannelParent.cpp index 904b9fa88f4b..3c8f01062dfb 100644 --- a/netwerk/protocol/file/FileChannelParent.cpp +++ b/netwerk/protocol/file/FileChannelParent.cpp @@ -66,7 +66,7 @@ FileChannelParent::Delete() { } NS_IMETHODIMP -FileChannelParent::GetRemoteType(nsACString& aRemoteType) { +FileChannelParent::GetRemoteType(nsAString& aRemoteType) { if (!CanSend()) { return NS_ERROR_UNEXPECTED; } diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index 330616020a55..0515344a3d36 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -533,7 +533,7 @@ FTPChannelParent::Delete() { } NS_IMETHODIMP -FTPChannelParent::GetRemoteType(nsACString& aRemoteType) { +FTPChannelParent::GetRemoteType(nsAString& aRemoteType) { if (!CanSend()) { return NS_ERROR_UNEXPECTED; } diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 8a1c022406e9..e5c4b792026f 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -1997,7 +1997,7 @@ HttpChannelParent::Delete() { } NS_IMETHODIMP -HttpChannelParent::GetRemoteType(nsACString& aRemoteType) { +HttpChannelParent::GetRemoteType(nsAString& aRemoteType) { if (!CanSend()) { return NS_ERROR_UNEXPECTED; } diff --git a/security/sandbox/linux/glue/SandboxPrefBridge.cpp b/security/sandbox/linux/glue/SandboxPrefBridge.cpp index 9782e58817df..53a9870a3a4e 100644 --- a/security/sandbox/linux/glue/SandboxPrefBridge.cpp +++ b/security/sandbox/linux/glue/SandboxPrefBridge.cpp @@ -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( diff --git a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp index 1bc5ad357da4..16c28de69830 100644 --- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp +++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp @@ -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; diff --git a/toolkit/components/backgroundhangmonitor/HangDetails.cpp b/toolkit/components/backgroundhangmonitor/HangDetails.cpp index b940bb4b846f..250bcfc216ab 100644 --- a/toolkit/components/backgroundhangmonitor/HangDetails.cpp +++ b/toolkit/components/backgroundhangmonitor/HangDetails.cpp @@ -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 ReadHangDetailsFromFile(nsIFile* aFile) { MOZ_TRY_VAR(result.threadName(), ReadTString(fd)); MOZ_TRY_VAR(result.runnableName(), ReadTString(fd)); MOZ_TRY_VAR(result.process(), ReadTString(fd)); - MOZ_TRY_VAR(result.remoteType(), ReadTString(fd)); + MOZ_TRY_VAR(result.remoteType(), ReadTString(fd)); uint32_t numAnnotations; MOZ_TRY_VAR(numAnnotations, ReadUint(fd)); diff --git a/toolkit/components/backgroundhangmonitor/HangTypes.ipdlh b/toolkit/components/backgroundhangmonitor/HangTypes.ipdlh index 3d8dd5aff2e1..44fd4d322fd7 100644 --- a/toolkit/components/backgroundhangmonitor/HangTypes.ipdlh +++ b/toolkit/components/backgroundhangmonitor/HangTypes.ipdlh @@ -85,7 +85,7 @@ struct HangDetails { TimeDuration duration; nsCString process; - nsCString remoteType; + nsString remoteType; nsCString threadName; nsCString runnableName; HangStack stack; diff --git a/toolkit/components/backgroundhangmonitor/nsIHangDetails.idl b/toolkit/components/backgroundhangmonitor/nsIHangDetails.idl index f9c6ba2de06b..7e15ebd5f020 100644 --- a/toolkit/components/backgroundhangmonitor/nsIHangDetails.idl +++ b/toolkit/components/backgroundhangmonitor/nsIHangDetails.idl @@ -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 diff --git a/toolkit/components/extensions/ExtensionPolicyService.cpp b/toolkit/components/extensions/ExtensionPolicyService.cpp index 8138694674da..3c63e3f8f920 100644 --- a/toolkit/components/extensions/ExtensionPolicyService.cpp +++ b/toolkit/components/extensions/ExtensionPolicyService.cpp @@ -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(); } diff --git a/toolkit/modules/nsIE10SUtils.idl b/toolkit/modules/nsIE10SUtils.idl index 7419827b3837..d56939fbee7d 100644 --- a/toolkit/modules/nsIE10SUtils.idl +++ b/toolkit/modules/nsIE10SUtils.idl @@ -32,11 +32,11 @@ interface nsIE10SUtils : nsISupports { * * @return The remote type to complete this load in. */ - AUTF8String getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal, - in nsIURI aChannelOriginalURI, - in boolean aMultiProcess, - in boolean aRemoteSubframes, - in AUTF8String aPreferredRemoteType, - in nsIPrincipal aCurrentPrincipal, - in boolean aIsSubframe); + AString getRemoteTypeForPrincipal(in nsIPrincipal aPrincipal, + in nsIURI aChannelOriginalURI, + in boolean aMultiProcess, + in boolean aRemoteSubframes, + in AString aPreferredRemoteType, + in nsIPrincipal aCurrentPrincipal, + in boolean aIsSubframe); }; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index a3290c0fb111..5b0675db9337 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -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 unused = - ContentParent::GetNewOrUsedBrowserProcess(nullptr, DEFAULT_REMOTE_TYPE); + RefPtr unused = ContentParent::GetNewOrUsedBrowserProcess( + nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); return NS_OK; } diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 68ac80315709..f3a2e79329fa 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -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 parent = - ContentParent::GetNewOrUsedBrowserProcess(nullptr, DEFAULT_REMOTE_TYPE); + RefPtr parent = ContentParent::GetNewOrUsedBrowserProcess( + nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)); parent.forget(&gContentParent); } else if (!gContentParent->IsAlive()) { return nullptr; diff --git a/tools/fuzzing/ipc/ProtocolFuzzer.cpp b/tools/fuzzing/ipc/ProtocolFuzzer.cpp index e2d7aae96d3d..8d2bd9b8404c 100644 --- a/tools/fuzzing/ipc/ProtocolFuzzer.cpp +++ b/tools/fuzzing/ipc/ProtocolFuzzer.cpp @@ -21,7 +21,7 @@ nsTArray 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(); diff --git a/tools/fuzzing/ipc/ProtocolFuzzer.h b/tools/fuzzing/ipc/ProtocolFuzzer.h index f57852038ae8..88eea8ffdb90 100644 --- a/tools/fuzzing/ipc/ProtocolFuzzer.h +++ b/tools/fuzzing/ipc/ProtocolFuzzer.h @@ -19,7 +19,7 @@ namespace ipc { class ProtocolFuzzerHelper { public: static mozilla::dom::ContentParent* CreateContentParent( - const nsACString& aRemoteType); + const nsAString& aRemoteType); static void CompositorBridgeParentSetup(); diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index 64a585df8d7e..e9eab96acf64 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -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; } diff --git a/widget/ProcInfo.h b/widget/ProcInfo.h index 0076603adfe4..4628b9e81650 100644 --- a/widget/ProcInfo.h +++ b/widget/ProcInfo.h @@ -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 ProcInfoPromise; #ifdef XP_MACOSX RefPtr 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 GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& processType, - const nsACString& origin); + const nsAString& origin); #endif } // namespace mozilla diff --git a/widget/android/ProcInfo.cpp b/widget/android/ProcInfo.cpp index 0bcdcb625cce..7e054aaa4446 100644 --- a/widget/android/ProcInfo.cpp +++ b/widget/android/ProcInfo.cpp @@ -11,7 +11,7 @@ namespace mozilla { RefPtr 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__); } diff --git a/widget/cocoa/ProcInfo.mm b/widget/cocoa/ProcInfo.mm index 6dc233dd0ba5..8cb4df477161 100644 --- a/widget/cocoa/ProcInfo.mm +++ b/widget/cocoa/ProcInfo.mm @@ -20,7 +20,7 @@ namespace mozilla { RefPtr 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>(); RefPtr promise = holder->Ensure(__func__); @@ -33,7 +33,7 @@ RefPtr 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; diff --git a/widget/gtk/ProcInfo.cpp b/widget/gtk/ProcInfo.cpp index 857f45245fc7..1538b561b4c2 100644 --- a/widget/gtk/ProcInfo.cpp +++ b/widget/gtk/ProcInfo.cpp @@ -211,7 +211,7 @@ class ThreadInfoReader final : public StatReader { RefPtr GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& type, - const nsACString& origin) { + const nsAString& origin) { auto holder = MakeUnique>(); RefPtr promise = holder->Ensure(__func__); nsresult rv = NS_OK; @@ -224,7 +224,7 @@ RefPtr 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 r = NS_NewRunnableFunction( __func__, [holder = std::move(holder), pid, type, originCopy = std::move(originCopy), childId]() { diff --git a/widget/windows/ProcInfo.cpp b/widget/windows/ProcInfo.cpp index 1050bdd7064b..ee13aa65ba07 100644 --- a/widget/windows/ProcInfo.cpp +++ b/widget/windows/ProcInfo.cpp @@ -77,7 +77,7 @@ void AppendThreads(ProcInfo* info) { RefPtr GetProcInfo(base::ProcessId pid, int32_t childId, const ProcType& type, - const nsACString& origin) { + const nsAString& origin) { auto holder = MakeUnique>(); RefPtr promise = holder->Ensure(__func__); @@ -91,7 +91,7 @@ RefPtr 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 r = NS_NewRunnableFunction( __func__, [holder = std::move(holder), originCopy = std::move(originCopy), pid, diff --git a/xpcom/system/nsIXULRuntime.idl b/xpcom/system/nsIXULRuntime.idl index 28eab662effe..47b6cb8e3133 100644 --- a/xpcom/system/nsIXULRuntime.idl +++ b/xpcom/system/nsIXULRuntime.idl @@ -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