зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1908725 - Part 3: Use GeckoChildID as the value for ContentParentId, r=smaug,ipc-reviewers,mccr8
The type for ContentParentId is uint64_t, however only at most 22 bits are allowed to be used (as it is used in the high bits of nsContentUtils process-specific IDs, which need to fit within a JS double). Switching to use the same existing ChildID reduces the risk of confusion, but this patch doesn't attempt to update the types used for ContentParentId/ChildID to match GeckoChildID. In the future, we probably will want to align these types more closely, and perhaps de-duplicate some code which currently passes around both. Differential Revision: https://phabricator.services.mozilla.com/D217119
This commit is contained in:
Родитель
bdb401316d
Коммит
d2c96b2361
|
@ -603,10 +603,7 @@ ContentChild* ContentChild::sSingleton;
|
|||
StaticAutoPtr<ContentChild::ShutdownCanary> ContentChild::sShutdownCanary;
|
||||
|
||||
ContentChild::ContentChild()
|
||||
: mID(uint64_t(-1)),
|
||||
mIsForBrowser(false),
|
||||
mIsAlive(true),
|
||||
mShuttingDown(false) {
|
||||
: mIsForBrowser(false), mIsAlive(true), mShuttingDown(false) {
|
||||
// This process is a content process, so it's clearly running in
|
||||
// multiprocess mode!
|
||||
nsDebugImpl::SetMultiprocessMode("Child");
|
||||
|
@ -705,8 +702,7 @@ class nsGtkNativeInitRunnable : public Runnable {
|
|||
};
|
||||
|
||||
void ContentChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
|
||||
const char* aParentBuildID, uint64_t aChildID,
|
||||
bool aIsForBrowser) {
|
||||
const char* aParentBuildID, bool aIsForBrowser) {
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// When running X11 only build we need to pass a display down
|
||||
// to gtk_init because it's not going to use the one from the environment
|
||||
|
@ -795,7 +791,6 @@ void ContentChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
|
|||
|
||||
CrashReporterClient::InitSingleton(this);
|
||||
|
||||
mID = aChildID;
|
||||
mIsForBrowser = aIsForBrowser;
|
||||
|
||||
SetProcessName("Web Content"_ns);
|
||||
|
@ -4572,7 +4567,7 @@ mozilla::ipc::IPCResult ContentChild::RecvInitSandboxTesting(
|
|||
#endif
|
||||
|
||||
NS_IMETHODIMP ContentChild::GetChildID(uint64_t* aOut) {
|
||||
*aOut = mID;
|
||||
*aOut = XRE_GetChildID();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class ContentChild final : public PContentChild,
|
|||
BrowsingContext** aReturn);
|
||||
|
||||
void Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
|
||||
const char* aParentBuildID, uint64_t aChildID, bool aIsForBrowser);
|
||||
const char* aParentBuildID, bool aIsForBrowser);
|
||||
|
||||
void InitXPCOM(XPCOMInitData&& aXPCOMInit,
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData,
|
||||
|
@ -446,7 +446,9 @@ class ContentChild final : public PContentChild,
|
|||
// cache the value
|
||||
nsString& GetIndexedDBPath();
|
||||
|
||||
ContentParentId GetID() const { return mID; }
|
||||
ContentParentId GetID() const {
|
||||
return ContentParentId{static_cast<uint64_t>(XRE_GetChildID())};
|
||||
}
|
||||
|
||||
bool IsForBrowser() const { return mIsForBrowser; }
|
||||
|
||||
|
@ -827,15 +829,6 @@ class ContentChild final : public PContentChild,
|
|||
// Temporary storage for list of shared-fontlist memory blocks.
|
||||
nsTArray<base::SharedMemoryHandle> mSharedFontListBlocks;
|
||||
|
||||
/**
|
||||
* An ID unique to the process containing our corresponding
|
||||
* content parent.
|
||||
*
|
||||
* We expect our content parent to set this ID immediately after opening a
|
||||
* channel to us.
|
||||
*/
|
||||
ContentParentId mID;
|
||||
|
||||
AppInfo mAppInfo;
|
||||
|
||||
bool mIsForBrowser;
|
||||
|
|
|
@ -553,9 +553,6 @@ static bool sCreatedFirstContentProcess = false;
|
|||
static bool sInProcessSelector = false;
|
||||
#endif
|
||||
|
||||
// The first content child has ID 1, so the chrome process can have ID 0.
|
||||
static uint64_t gContentChildID = 1;
|
||||
|
||||
static const char* sObserverTopics[] = {
|
||||
NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
|
||||
NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC,
|
||||
|
@ -2368,7 +2365,6 @@ bool ContentParent::BeginSubprocessLaunch(ProcessPriority aPriority) {
|
|||
}
|
||||
|
||||
std::vector<std::string> extraArgs;
|
||||
geckoargs::sChildID.Put(mChildID, extraArgs);
|
||||
geckoargs::sIsForBrowser.Put(IsForBrowser(), extraArgs);
|
||||
geckoargs::sNotForBrowser.Put(!IsForBrowser(), extraArgs);
|
||||
|
||||
|
@ -2541,14 +2537,19 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool IsFileContent(const nsACString& aRemoteType) {
|
||||
return aRemoteType == FILE_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
ContentParent::ContentParent(const nsACString& aRemoteType)
|
||||
: mSubprocess(nullptr),
|
||||
: mSubprocess(new GeckoChildProcessHost(GeckoProcessType_Content,
|
||||
IsFileContent(aRemoteType))),
|
||||
mLaunchTS(TimeStamp::Now()),
|
||||
mLaunchYieldTS(mLaunchTS),
|
||||
mActivateTS(mLaunchTS),
|
||||
mIsAPreallocBlocker(false),
|
||||
mRemoteType(aRemoteType),
|
||||
mChildID(gContentChildID++),
|
||||
mChildID(mSubprocess->GetChildID()),
|
||||
mGeolocationWatchID(-1),
|
||||
mThreadsafeHandle(
|
||||
new ThreadsafeContentParentHandle(this, mChildID, mRemoteType)),
|
||||
|
@ -2569,6 +2570,8 @@ ContentParent::ContentParent(const nsACString& aRemoteType)
|
|||
mBlockShutdownCalled(false),
|
||||
#endif
|
||||
mHangMonitorActor(nullptr) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
mRemoteTypeIsolationPrincipal =
|
||||
CreateRemoteTypeIsolationPrincipal(aRemoteType);
|
||||
|
||||
|
@ -2588,13 +2591,9 @@ ContentParent::ContentParent(const nsACString& aRemoteType)
|
|||
MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
|
||||
#endif
|
||||
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
bool isFile = mRemoteType == FILE_REMOTE_TYPE;
|
||||
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, isFile);
|
||||
MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose,
|
||||
("CreateSubprocess: ContentParent %p mSubprocess %p handle %" PRIuPTR,
|
||||
this, mSubprocess,
|
||||
mSubprocess ? (uintptr_t)mSubprocess->GetChildProcessHandle() : -1));
|
||||
("CreateSubprocess: ContentParent %p mSubprocess %p childID %d", this,
|
||||
mSubprocess, mSubprocess->GetChildID()));
|
||||
}
|
||||
|
||||
ContentParent::~ContentParent() {
|
||||
|
@ -3248,7 +3247,6 @@ mozilla::ipc::IPCResult ContentParent::RecvClipboardHasType(
|
|||
}
|
||||
|
||||
namespace {
|
||||
|
||||
static Result<ClipboardReadRequest, nsresult> CreateClipboardReadRequest(
|
||||
ContentParent& aContentParent,
|
||||
nsIClipboardDataSnapshot& aClipboardDataSnapshot) {
|
||||
|
|
|
@ -464,6 +464,13 @@ class ContentParent final : public PContentParent,
|
|||
*/
|
||||
void KillHard(const char* aReason);
|
||||
|
||||
/**
|
||||
* Get a unique identifier for this child process. This ID is unique across
|
||||
* all types of child processes.
|
||||
*
|
||||
* NOTE: The `ContentParentId` wrapper type is a historical artifact from when
|
||||
* the ID was only specific to content processes.
|
||||
*/
|
||||
ContentParentId ChildID() const { return mChildID; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,6 @@ ContentProcess::ContentProcess(ProcessId aParentPid,
|
|||
ContentProcess::~ContentProcess() { NS_LogTerm(); }
|
||||
|
||||
bool ContentProcess::Init(int aArgc, char* aArgv[]) {
|
||||
Maybe<uint64_t> childID = geckoargs::sChildID.Get(aArgc, aArgv);
|
||||
Maybe<bool> isForBrowser = Nothing();
|
||||
Maybe<const char*> parentBuildID =
|
||||
geckoargs::sParentBuildID.Get(aArgc, aArgv);
|
||||
|
@ -122,8 +121,7 @@ bool ContentProcess::Init(int aArgc, char* aArgv[]) {
|
|||
#endif /* XP_MACOSX && MOZ_SANDBOX */
|
||||
|
||||
// Did we find all the mandatory flags?
|
||||
if (childID.isNothing() || isForBrowser.isNothing() ||
|
||||
parentBuildID.isNothing()) {
|
||||
if (isForBrowser.isNothing() || parentBuildID.isNothing()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -136,7 +134,7 @@ bool ContentProcess::Init(int aArgc, char* aArgv[]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
mContent.Init(TakeInitialEndpoint(), *parentBuildID, *childID, *isForBrowser);
|
||||
mContent.Init(TakeInitialEndpoint(), *parentBuildID, *isForBrowser);
|
||||
|
||||
nsCOMPtr<nsIFile> greDir;
|
||||
nsresult rv = GetGREDir(getter_AddRefs(greDir));
|
||||
|
|
|
@ -121,8 +121,6 @@ static CommandLineArg<uint64_t> sPrefMapHandle{"-prefMapHandle",
|
|||
"prefmaphandle"};
|
||||
static CommandLineArg<uint64_t> sPrefMapSize{"-prefMapSize", "prefmapsize"};
|
||||
|
||||
static CommandLineArg<uint64_t> sChildID{"-childID", "childid"};
|
||||
|
||||
static CommandLineArg<uint64_t> sSandboxingKind{"-sandboxingKind",
|
||||
"sandboxingkind"};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче