Bug 1650163 - Part 2: Add a NOT_REMOTE_TYPE define to clarify calling code, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D82106
This commit is contained in:
Nika Layzell 2020-07-08 01:13:45 +00:00
Родитель c850a94434
Коммит 64031d88e9
15 изменённых файлов: 28 добавлений и 26 удалений

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

@ -98,7 +98,7 @@ void CanonicalBrowsingContext::GetCurrentRemoteType(nsACString& aRemoteType,
ErrorResult& aRv) const {
// If we're in the parent process, dump out the void string.
if (mProcessId == 0) {
aRemoteType.Assign(VoidCString());
aRemoteType = NOT_REMOTE_TYPE;
return;
}
@ -108,7 +108,7 @@ void CanonicalBrowsingContext::GetCurrentRemoteType(nsACString& aRemoteType,
return;
}
aRemoteType.Assign(cp->GetRemoteType());
aRemoteType = cp->GetRemoteType();
}
void CanonicalBrowsingContext::SetOwnerProcessId(uint64_t aProcessId) {

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

@ -150,8 +150,8 @@ 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 VoidCString() aRemoteType argument will perform a process switch into the
// parent process, and the method will resolve with a null BrowserParent.
// A NOT_REMOTE_TYPE aRemoteType argument will perform a process switch into
// the parent process, and the method will resolve with a null BrowserParent.
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
RefPtr<RemotenessPromise> ChangeRemoteness(const nsACString& aRemoteType,
uint64_t aPendingSwitchId,

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

@ -169,7 +169,7 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, BrowsingContext* aBrowsingContext,
mDetachedSubdocFrame(nullptr),
mPendingSwitchID(0),
mChildID(0),
mRemoteType(VoidCString()),
mRemoteType(NOT_REMOTE_TYPE),
mDepthTooGreat(false),
mIsTopLevelContent(false),
mDestroyCalled(false),

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

@ -863,7 +863,7 @@ class ContentChild final : public PContentChild,
AppInfo mAppInfo;
bool mIsForBrowser;
nsCString mRemoteType = VoidCString();
nsCString mRemoteType = NOT_REMOTE_TYPE;
bool mIsAlive;
nsString mProcessName;

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

@ -60,6 +60,9 @@
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
// Remote type value used to represent being non-remote.
#define NOT_REMOTE_TYPE VoidCString()
// 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

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

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

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

@ -47,7 +47,7 @@ class InProcessParent final : public nsIDOMProcessParent,
// |nullptr|.
static IProtocol* ChildActorFor(IProtocol* aActor);
const nsACString& GetRemoteType() const override { return VoidCString(); };
const nsACString& GetRemoteType() const override { return NOT_REMOTE_TYPE; };
protected:
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,

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

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

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

@ -430,7 +430,7 @@ const nsACString& WindowGlobalParent::GetRemoteType() {
return browserParent->Manager()->GetRemoteType();
}
return VoidCString();
return NOT_REMOTE_TYPE;
}
void WindowGlobalParent::NotifyContentBlockingEvent(

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

@ -100,7 +100,7 @@ Result<nsCString, nsresult> RemoteWorkerManager::GetRemoteType(
return Err(NS_ERROR_UNEXPECTED);
}
nsCString remoteType = VoidCString();
nsCString remoteType = NOT_REMOTE_TYPE;
// If Gecko is running in single process mode, there is no child process
// to select, return without assigning any remoteType.

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

@ -34,10 +34,10 @@ TEST(RemoteWorkerManager, TestMatchRemoteType)
{FISSION_WEB_REMOTE_TYPE, DEFAULT_REMOTE_TYPE, true},
// Test empty remoteType default to "web" remoteType.
{DEFAULT_REMOTE_TYPE, VoidCString(), true},
{WITH_COOP_COEP_REMOTE_TYPE_PREFIX, VoidCString(), false},
{PRIVILEGEDMOZILLA_REMOTE_TYPE, VoidCString(), false},
{EXTENSION_REMOTE_TYPE, VoidCString(), false},
{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},
};
for (const auto& test : tests) {

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

@ -1314,7 +1314,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
return false;
}
nsAutoCString currentRemoteType(VoidCString());
nsAutoCString currentRemoteType(NOT_REMOTE_TYPE);
if (RefPtr<ContentParent> contentParent =
browsingContext->GetContentParent()) {
currentRemoteType = contentParent->GetRemoteType();
@ -1403,7 +1403,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
if (ExtensionPolicyService::GetSingleton().UseRemoteExtensions()) {
preferredRemoteType = EXTENSION_REMOTE_TYPE;
} else {
preferredRemoteType = VoidCString();
preferredRemoteType = NOT_REMOTE_TYPE;
}
if (browsingContext->Group()->Id() !=
@ -2039,7 +2039,7 @@ DocumentLoadListener::GetRemoteType(nsACString& aRemoteType) {
ErrorResult error;
browsingContext->GetCurrentRemoteType(aRemoteType, error);
if (error.Failed()) {
aRemoteType = VoidCString();
aRemoteType = NOT_REMOTE_TYPE;
}
return NS_OK;
}

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

@ -88,7 +88,7 @@ ParentChannelWrapper::Delete() { return NS_OK; }
NS_IMETHODIMP
ParentChannelWrapper::GetRemoteType(nsACString& aRemoteType) {
aRemoteType = VoidCString();
aRemoteType = NOT_REMOTE_TYPE;
return NS_OK;
}

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

@ -505,7 +505,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime,
HangDetails hangDetails(aHangTime,
nsDependentCString(XRE_GetProcessTypeString()),
VoidCString(), mThreadName, mRunnableName,
NOT_REMOTE_TYPE, mThreadName, mRunnableName,
std::move(mHangStack), std::move(mAnnotations));
PersistedToDisk persistedToDisk = aPersistedToDisk;

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

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