Bug 1908725 - Part 2: Make the ChildID available in the same places as OtherPid, r=ipc-reviewers,media-playback-reviewers,win-reviewers,alwu,rkraesig,gfx-reviewers,mccr8,nical

This requires quite a bit of piping to get the ChildID passed everywhere where
we currently pass the pid in IPC. This is done by adding a new struct type
(EndpointProcInfo), which is passed around instead of OtherPid in these places,
and contains the full pid.

In most cases, it was a fairly painless change to move over, however in some
cases, more complex changes were required, as the pid was being stored
previously in something like an Atomic<...>, and needed to be switched to using
a mutex-protected value.

In the future, it may be possible to remove OtherPid from IPDL actors once
everything is migrated to ChildID, but we're still a long way off from that, so
for now we unfortunately need to pass both around.

Differential Revision: https://phabricator.services.mozilla.com/D217118
This commit is contained in:
Nika Layzell 2024-08-07 20:39:39 +00:00
Родитель 008c780b6b
Коммит bdb401316d
51 изменённых файлов: 356 добавлений и 244 удалений

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

@ -1156,8 +1156,8 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateGMPService() {
}
nsresult rv;
rv = PGMPService::CreateEndpoints(base::GetCurrentProcId(), OtherPid(),
&parent, &child);
rv = PGMPService::CreateEndpoints(EndpointProcInfo::Current(),
OtherEndpointProcInfo(), &parent, &child);
if (NS_FAILED(rv)) {
return IPC_FAIL(this, "CreateEndpoints failed");
}
@ -2886,9 +2886,9 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
Endpoint<PRemoteDecoderManagerChild> videoManager;
AutoTArray<uint32_t, 3> namespaces;
if (!gpm->CreateContentBridges(OtherPid(), &compositor, &imageBridge,
&vrBridge, &videoManager, mChildID,
&namespaces)) {
if (!gpm->CreateContentBridges(OtherEndpointProcInfo(), &compositor,
&imageBridge, &vrBridge, &videoManager,
mChildID, &namespaces)) {
// This can fail if we've already started shutting down the compositor
// thread. See Bug 1562763 comment 8.
MOZ_ASSERT(AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdown));
@ -3055,9 +3055,9 @@ void ContentParent::OnCompositorUnexpectedShutdown() {
Endpoint<PRemoteDecoderManagerChild> videoManager;
AutoTArray<uint32_t, 3> namespaces;
if (!gpm->CreateContentBridges(OtherPid(), &compositor, &imageBridge,
&vrBridge, &videoManager, mChildID,
&namespaces)) {
if (!gpm->CreateContentBridges(OtherEndpointProcInfo(), &compositor,
&imageBridge, &vrBridge, &videoManager,
mChildID, &namespaces)) {
MOZ_ASSERT(AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdown));
return;
}

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

@ -75,7 +75,7 @@ void InProcessParent::Startup() {
MOZ_CRASH("Failed to open InProcessChild!");
}
parent->SetOtherProcessId(base::GetCurrentProcId());
parent->SetOtherEndpointProcInfo(EndpointProcInfo::Current());
// Stash global references to fetch the other side of the reference.
InProcessParent::sSingleton = std::move(parent);

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

@ -60,9 +60,9 @@ nsresult JSOracleParent::BindToUtilityProcess(
Endpoint<PJSOracleParent> parentEnd;
Endpoint<PJSOracleChild> childEnd;
MOZ_ASSERT(aUtilityParent);
if (NS_FAILED(PJSOracle::CreateEndpoints(base::GetCurrentProcId(),
aUtilityParent->OtherPid(),
&parentEnd, &childEnd))) {
if (NS_FAILED(PJSOracle::CreateEndpoints(
mozilla::ipc::EndpointProcInfo::Current(),
aUtilityParent->OtherEndpointProcInfo(), &parentEnd, &childEnd))) {
return NS_ERROR_FAILURE;
}

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

@ -1276,7 +1276,8 @@ bool GMPParent::OpenPGMPContent() {
Endpoint<PGMPContentParent> parent;
Endpoint<PGMPContentChild> child;
if (NS_WARN_IF(NS_FAILED(PGMPContent::CreateEndpoints(
base::GetCurrentProcId(), OtherPid(), &parent, &child)))) {
mozilla::ipc::EndpointProcInfo::Current(), OtherEndpointProcInfo(),
&parent, &child)))) {
return false;
}

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

@ -2004,7 +2004,8 @@ mozilla::ipc::IPCResult GMPServiceParent::RecvLaunchGMP(
Endpoint<PGMPContentParent> parent;
Endpoint<PGMPContentChild> child;
rv = PGMPContent::CreateEndpoints(OtherPid(), result.pid(), &parent, &child);
rv = PGMPContent::CreateEndpoints(
OtherEndpointProcInfo(), gmp->OtherEndpointProcInfo(), &parent, &child);
if (NS_WARN_IF(NS_FAILED(rv))) {
result.result() = rv;
result.errorDescription() = "PGMPContent::CreateEndpoints failed."_ns;

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

@ -6,6 +6,7 @@
include protocol PGMPContent;
include GMPTypes;
// FIXME: Should use GeckoChildID over ProcessId to identify processes.
using base::ProcessId from "base/process.h";
using GMPPluginType from "GMPNativeTypes.h";

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

@ -192,7 +192,7 @@ RefPtr<GenericNonExclusivePromise> RDDProcessManager::LaunchRDDProcess() {
}
auto RDDProcessManager::EnsureRDDProcessAndCreateBridge(
base::ProcessId aOtherProcess,
ipc::EndpointProcInfo aOtherProcess,
dom::ContentParentId aParentId) -> RefPtr<EnsureRDDPromise> {
return InvokeAsync(
GetMainThreadSerialEventTarget(), __func__,
@ -276,7 +276,7 @@ void RDDProcessManager::DestroyProcess() {
}
bool RDDProcessManager::CreateContentBridge(
base::ProcessId aOtherProcess, dom::ContentParentId aParentId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aParentId,
ipc::Endpoint<PRemoteDecoderManagerChild>* aOutRemoteDecoderManager) {
MOZ_ASSERT(NS_IsMainThread());
@ -290,7 +290,8 @@ bool RDDProcessManager::CreateContentBridge(
ipc::Endpoint<PRemoteDecoderManagerChild> childPipe;
nsresult rv = PRemoteDecoderManager::CreateEndpoints(
mRDDChild->OtherPid(), aOtherProcess, &parentPipe, &childPipe);
mRDDChild->OtherEndpointProcInfo(), aOtherProcess, &parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
MOZ_LOG(sPDMLog, LogLevel::Debug,
("Could not create content remote decoder: %d", int(rv)));
@ -310,8 +311,9 @@ bool RDDProcessManager::CreateVideoBridge() {
ipc::Endpoint<PVideoBridgeChild> childPipe;
GPUProcessManager* gpuManager = GPUProcessManager::Get();
base::ProcessId gpuProcessPid =
gpuManager ? gpuManager->GPUProcessPid() : base::kInvalidProcessId;
ipc::EndpointProcInfo gpuProcessInfo = gpuManager
? gpuManager->GPUEndpointProcInfo()
: ipc::EndpointProcInfo::Invalid();
// Build content device data first; this ensure that the GPU process is fully
// ready.
@ -320,13 +322,14 @@ bool RDDProcessManager::CreateVideoBridge() {
// The child end is the producer of video frames; the parent end is the
// consumer.
base::ProcessId childPid = RDDProcessPid();
base::ProcessId parentPid = gpuProcessPid != base::kInvalidProcessId
? gpuProcessPid
: base::GetCurrentProcId();
ipc::EndpointProcInfo childInfo = RDDEndpointProcInfo();
ipc::EndpointProcInfo parentInfo =
gpuProcessInfo != ipc::EndpointProcInfo::Invalid()
? gpuProcessInfo
: ipc::EndpointProcInfo::Current();
nsresult rv = PVideoBridge::CreateEndpoints(parentPid, childPid, &parentPipe,
&childPipe);
nsresult rv = PVideoBridge::CreateEndpoints(parentInfo, childInfo,
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
MOZ_LOG(sPDMLog, LogLevel::Debug,
("Could not create video bridge: %d", int(rv)));
@ -335,7 +338,7 @@ bool RDDProcessManager::CreateVideoBridge() {
mRDDChild->SendInitVideoBridge(std::move(childPipe),
mNumUnexpectedCrashes == 0, contentDeviceData);
if (gpuProcessPid != base::kInvalidProcessId) {
if (gpuProcessInfo != ipc::EndpointProcInfo::Invalid()) {
gpuManager->InitVideoBridge(std::move(parentPipe),
VideoBridgeSource::RddProcess);
} else {
@ -353,6 +356,12 @@ base::ProcessId RDDProcessManager::RDDProcessPid() {
return rddPid;
}
ipc::EndpointProcInfo RDDProcessManager::RDDEndpointProcInfo() {
MOZ_ASSERT(NS_IsMainThread());
return mRDDChild ? mRDDChild->OtherEndpointProcInfo()
: ipc::EndpointProcInfo::Invalid();
}
class RDDMemoryReporter : public MemoryReportingProcess {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RDDMemoryReporter, override)

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

@ -39,7 +39,7 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
// If not using a RDD process, launch a new RDD process asynchronously and
// create a RemoteDecoderManager bridge
RefPtr<EnsureRDDPromise> EnsureRDDProcessAndCreateBridge(
base::ProcessId aOtherProcess, dom::ContentParentId aParentId);
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aParentId);
void OnProcessUnexpectedShutdown(RDDProcessHost* aHost) override;
@ -50,6 +50,9 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
// Returns -1 if there is no RDD process, or the platform pid for it.
base::ProcessId RDDProcessPid();
// Returns Invalid if there is no RDD process, or the proc info for it.
ipc::EndpointProcInfo RDDEndpointProcInfo();
// If a RDD process is present, create a MemoryReportingProcess object.
// Otherwise, return null.
RefPtr<MemoryReportingProcess> GetProcessMemoryReporter();
@ -102,7 +105,7 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
friend class Observer;
bool CreateContentBridge(
base::ProcessId aOtherProcess, dom::ContentParentId aParentId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aParentId,
ipc::Endpoint<PRemoteDecoderManagerChild>* aOutRemoteDecoderManager);
const RefPtr<Observer> mObserver;

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

@ -22,9 +22,9 @@ class WindowsUtilsParent final : public PWindowsUtilsParent {
RefPtr<mozilla::ipc::UtilityProcessParent> aUtilityParent) {
Endpoint<PWindowsUtilsParent> parentEnd;
Endpoint<PWindowsUtilsChild> childEnd;
nsresult rv = PWindowsUtils::CreateEndpoints(base::GetCurrentProcId(),
aUtilityParent->OtherPid(),
&parentEnd, &childEnd);
nsresult rv = PWindowsUtils::CreateEndpoints(
mozilla::ipc::EndpointProcInfo::Current(),
aUtilityParent->OtherEndpointProcInfo(), &parentEnd, &childEnd);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Protocol endpoints failure");

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

@ -33,9 +33,10 @@ RefPtr<RemoteWorkerServiceParent> RemoteWorkerServiceParent::CreateForProcess(
Endpoint<PRemoteWorkerServiceParent> parentEp;
nsresult rv = PRemoteWorkerService::CreateEndpoints(
base::GetCurrentProcId(),
aProcess ? aProcess->OtherPid() : base::GetCurrentProcId(), &parentEp,
aChildEp);
EndpointProcInfo::Current(),
aProcess ? aProcess->OtherEndpointProcInfo()
: EndpointProcInfo::Current(),
&parentEp, aChildEp);
NS_ENSURE_SUCCESS(rv, nullptr);
RefPtr<RemoteWorkerServiceParent> actor = new RemoteWorkerServiceParent(

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

@ -112,13 +112,15 @@ void CanvasManagerChild::Destroy() {
ipc::Endpoint<PCanvasManagerParent> parentEndpoint;
ipc::Endpoint<PCanvasManagerChild> childEndpoint;
auto compositorPid = CompositorManagerChild::GetOtherPid();
if (NS_WARN_IF(!compositorPid)) {
ipc::EndpointProcInfo compositorInfo =
CompositorManagerChild::GetCompositorProcInfo();
if (NS_WARN_IF(compositorInfo == ipc::EndpointProcInfo::Invalid())) {
return nullptr;
}
nsresult rv = PCanvasManager::CreateEndpoints(
compositorPid, base::GetCurrentProcId(), &parentEndpoint, &childEndpoint);
compositorInfo, ipc::EndpointProcInfo::Current(), &parentEndpoint,
&childEndpoint);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}

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

@ -453,8 +453,9 @@ bool GPUProcessManager::EnsureCompositorManagerChild() {
ipc::Endpoint<PCompositorManagerParent> parentPipe;
ipc::Endpoint<PCompositorManagerChild> childPipe;
rv = PCompositorManager::CreateEndpoints(
mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
rv = PCompositorManager::CreateEndpoints(mGPUChild->OtherEndpointProcInfo(),
ipc::EndpointProcInfo::Current(),
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
DisableGPUProcess("Failed to create PCompositorManager endpoints");
return true;
@ -484,8 +485,9 @@ bool GPUProcessManager::EnsureImageBridgeChild() {
ipc::Endpoint<PImageBridgeParent> parentPipe;
ipc::Endpoint<PImageBridgeChild> childPipe;
rv = PImageBridge::CreateEndpoints(
mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
rv = PImageBridge::CreateEndpoints(mGPUChild->OtherEndpointProcInfo(),
ipc::EndpointProcInfo::Current(),
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
DisableGPUProcess("Failed to create PImageBridge endpoints");
return true;
@ -514,8 +516,9 @@ bool GPUProcessManager::EnsureVRManager() {
ipc::Endpoint<PVRManagerParent> parentPipe;
ipc::Endpoint<PVRManagerChild> childPipe;
rv = PVRManager::CreateEndpoints(
mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
rv = PVRManager::CreateEndpoints(mGPUChild->OtherEndpointProcInfo(),
ipc::EndpointProcInfo::Current(),
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
DisableGPUProcess("Failed to create PVRManager endpoints");
return true;
@ -542,8 +545,8 @@ GPUProcessManager::CreateUiCompositorController(nsBaseWidget* aWidget,
} else {
ipc::Endpoint<PUiCompositorControllerParent> parentPipe;
ipc::Endpoint<PUiCompositorControllerChild> childPipe;
rv = PUiCompositorController::CreateEndpoints(mGPUChild->OtherPid(),
base::GetCurrentProcId(),
rv = PUiCompositorController::CreateEndpoints(
mGPUChild->OtherEndpointProcInfo(), ipc::EndpointProcInfo::Current(),
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
DisableGPUProcess("Failed to create PUiCompositorController endpoints");
@ -581,8 +584,8 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) {
ipc::Endpoint<PVsyncBridgeParent> vsyncParent;
ipc::Endpoint<PVsyncBridgeChild> vsyncChild;
nsresult rv = PVsyncBridge::CreateEndpoints(mGPUChild->OtherPid(),
base::GetCurrentProcId(),
nsresult rv = PVsyncBridge::CreateEndpoints(
mGPUChild->OtherEndpointProcInfo(), ipc::EndpointProcInfo::Current(),
&vsyncParent, &vsyncChild);
if (NS_FAILED(rv)) {
DisableGPUProcess("Failed to create PVsyncBridge endpoints");
@ -1282,8 +1285,8 @@ RefPtr<CompositorSession> GPUProcessManager::CreateRemoteSession(
ipc::Endpoint<PAPZInputBridgeParent> parentPipe;
ipc::Endpoint<PAPZInputBridgeChild> childPipe;
nsresult rv = PAPZInputBridge::CreateEndpoints(mGPUChild->OtherPid(),
base::GetCurrentProcId(),
nsresult rv = PAPZInputBridge::CreateEndpoints(
mGPUChild->OtherEndpointProcInfo(), ipc::EndpointProcInfo::Current(),
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
return nullptr;
@ -1308,7 +1311,7 @@ RefPtr<CompositorSession> GPUProcessManager::CreateRemoteSession(
}
bool GPUProcessManager::CreateContentBridges(
base::ProcessId aOtherProcess,
ipc::EndpointProcInfo aOtherProcess,
ipc::Endpoint<PCompositorManagerChild>* aOutCompositor,
ipc::Endpoint<PImageBridgeChild>* aOutImageBridge,
ipc::Endpoint<PVRManagerChild>* aOutVRBridge,
@ -1333,7 +1336,7 @@ bool GPUProcessManager::CreateContentBridges(
}
bool GPUProcessManager::CreateContentCompositorManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
uint32_t aNamespace, ipc::Endpoint<PCompositorManagerChild>* aOutEndpoint) {
ipc::Endpoint<PCompositorManagerParent> parentPipe;
ipc::Endpoint<PCompositorManagerChild> childPipe;
@ -1343,10 +1346,11 @@ bool GPUProcessManager::CreateContentCompositorManager(
return false;
}
base::ProcessId parentPid =
NS_SUCCEEDED(rv) ? mGPUChild->OtherPid() : base::GetCurrentProcId();
ipc::EndpointProcInfo parentInfo = NS_SUCCEEDED(rv)
? mGPUChild->OtherEndpointProcInfo()
: ipc::EndpointProcInfo::Current();
rv = PCompositorManager::CreateEndpoints(parentPid, aOtherProcess,
rv = PCompositorManager::CreateEndpoints(parentInfo, aOtherProcess,
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
gfxCriticalNote << "Could not create content compositor manager: "
@ -1368,7 +1372,7 @@ bool GPUProcessManager::CreateContentCompositorManager(
}
bool GPUProcessManager::CreateContentImageBridge(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
ipc::Endpoint<PImageBridgeChild>* aOutEndpoint) {
if (!EnsureImageBridgeChild()) {
return false;
@ -1379,12 +1383,13 @@ bool GPUProcessManager::CreateContentImageBridge(
return false;
}
base::ProcessId parentPid =
NS_SUCCEEDED(rv) ? mGPUChild->OtherPid() : base::GetCurrentProcId();
ipc::EndpointProcInfo parentInfo = NS_SUCCEEDED(rv)
? mGPUChild->OtherEndpointProcInfo()
: ipc::EndpointProcInfo::Current();
ipc::Endpoint<PImageBridgeParent> parentPipe;
ipc::Endpoint<PImageBridgeChild> childPipe;
rv = PImageBridge::CreateEndpoints(parentPid, aOtherProcess, &parentPipe,
rv = PImageBridge::CreateEndpoints(parentInfo, aOtherProcess, &parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
gfxCriticalNote << "Could not create content compositor bridge: "
@ -1410,8 +1415,13 @@ base::ProcessId GPUProcessManager::GPUProcessPid() {
return gpuPid;
}
ipc::EndpointProcInfo GPUProcessManager::GPUEndpointProcInfo() {
return mGPUChild ? mGPUChild->OtherEndpointProcInfo()
: ipc::EndpointProcInfo::Invalid();
}
bool GPUProcessManager::CreateContentVRManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
ipc::Endpoint<PVRManagerChild>* aOutEndpoint) {
if (NS_WARN_IF(!EnsureVRManager())) {
return false;
@ -1422,12 +1432,13 @@ bool GPUProcessManager::CreateContentVRManager(
return false;
}
base::ProcessId parentPid =
NS_SUCCEEDED(rv) ? mGPUChild->OtherPid() : base::GetCurrentProcId();
ipc::EndpointProcInfo parentInfo = NS_SUCCEEDED(rv)
? mGPUChild->OtherEndpointProcInfo()
: ipc::EndpointProcInfo::Current();
ipc::Endpoint<PVRManagerParent> parentPipe;
ipc::Endpoint<PVRManagerChild> childPipe;
rv = PVRManager::CreateEndpoints(parentPid, aOtherProcess, &parentPipe,
rv = PVRManager::CreateEndpoints(parentInfo, aOtherProcess, &parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
gfxCriticalNote << "Could not create content compositor bridge: "
@ -1448,7 +1459,7 @@ bool GPUProcessManager::CreateContentVRManager(
}
void GPUProcessManager::CreateContentRemoteDecoderManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
ipc::EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
ipc::Endpoint<PRemoteDecoderManagerChild>* aOutEndpoint) {
nsresult rv = EnsureGPUReady();
if (NS_WARN_IF(rv == NS_ERROR_ILLEGAL_DURING_SHUTDOWN)) {
@ -1464,7 +1475,8 @@ void GPUProcessManager::CreateContentRemoteDecoderManager(
ipc::Endpoint<PRemoteDecoderManagerChild> childPipe;
rv = PRemoteDecoderManager::CreateEndpoints(
mGPUChild->OtherPid(), aOtherProcess, &parentPipe, &childPipe);
mGPUChild->OtherEndpointProcInfo(), aOtherProcess, &parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
gfxCriticalNote << "Could not create content video decoder: "
<< hexa(int(rv));

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

@ -106,7 +106,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
uint64_t aInnerWindowId, bool* aRetry);
bool CreateContentBridges(
base::ProcessId aOtherProcess,
mozilla::ipc::EndpointProcInfo aOtherProcess,
mozilla::ipc::Endpoint<PCompositorManagerChild>* aOutCompositor,
mozilla::ipc::Endpoint<PImageBridgeChild>* aOutImageBridge,
mozilla::ipc::Endpoint<PVRManagerChild>* aOutVRBridge,
@ -194,6 +194,9 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
// Returns -1 if there is no GPU process, or the platform pid for it.
base::ProcessId GPUProcessPid();
// Returns Invalid() if there is no GPU process, or the proc info for it.
mozilla::ipc::EndpointProcInfo GPUEndpointProcInfo();
// If a GPU process is present, create a MemoryReportingProcess object.
// Otherwise, return null.
RefPtr<MemoryReportingProcess> GetProcessMemoryReporter();
@ -225,17 +228,20 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
void ScreenInformationChanged();
bool CreateContentCompositorManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
uint32_t aNamespace,
mozilla::ipc::EndpointProcInfo aOtherProcess,
dom::ContentParentId aChildId, uint32_t aNamespace,
mozilla::ipc::Endpoint<PCompositorManagerChild>* aOutEndpoint);
bool CreateContentImageBridge(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
mozilla::ipc::EndpointProcInfo aOtherProcess,
dom::ContentParentId aChildId,
mozilla::ipc::Endpoint<PImageBridgeChild>* aOutEndpoint);
bool CreateContentVRManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
mozilla::ipc::EndpointProcInfo aOtherProcess,
dom::ContentParentId aChildId,
mozilla::ipc::Endpoint<PVRManagerChild>* aOutEndpoint);
void CreateContentRemoteDecoderManager(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
mozilla::ipc::EndpointProcInfo aOtherProcess,
dom::ContentParentId aChildId,
mozilla::ipc::Endpoint<PRemoteDecoderManagerChild>* aOutEndPoint);
// Called from RemoteCompositorSession. We track remote sessions so we can

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

@ -24,7 +24,21 @@ namespace layers {
using gfx::GPUProcessManager;
StaticRefPtr<CompositorManagerChild> CompositorManagerChild::sInstance;
Atomic<base::ProcessId> CompositorManagerChild::sOtherPid(0);
static StaticMutex sCompositorProcInfoMutex;
static ipc::EndpointProcInfo sCompositorProcInfo
MOZ_GUARDED_BY(sCompositorProcInfoMutex);
static void SetCompositorProcInfo(ipc::EndpointProcInfo aInfo) {
StaticMutexAutoLock lock(sCompositorProcInfoMutex);
sCompositorProcInfo = aInfo;
}
/* static */
ipc::EndpointProcInfo CompositorManagerChild::GetCompositorProcInfo() {
StaticMutexAutoLock lock(sCompositorProcInfoMutex);
return sCompositorProcInfo;
}
/* static */
bool CompositorManagerChild::IsInitialized(uint64_t aProcessToken) {
@ -44,16 +58,19 @@ void CompositorManagerChild::InitSameProcess(uint32_t aNamespace,
RefPtr<CompositorManagerParent> parent =
CompositorManagerParent::CreateSameProcess(aNamespace);
RefPtr<CompositorManagerChild> child =
new CompositorManagerChild(parent, aProcessToken, aNamespace);
if (NS_WARN_IF(!child->CanSend())) {
RefPtr<CompositorManagerChild> child = new CompositorManagerChild(
aProcessToken, aNamespace, /* aSameProcess */ true);
child->SetOtherEndpointProcInfo(ipc::EndpointProcInfo::Current());
if (NS_WARN_IF(!child->Open(parent, CompositorThread(), ipc::ChildSide))) {
MOZ_DIAGNOSTIC_ASSERT(false, "Failed to open same process protocol");
return;
}
child->mCanSend = true;
child->SetReplyTimeout();
parent->BindComplete(/* aIsRoot */ true);
sInstance = std::move(child);
sOtherPid = sInstance->OtherPid();
SetCompositorProcInfo(sInstance->OtherEndpointProcInfo());
}
/* static */
@ -65,12 +82,17 @@ bool CompositorManagerChild::Init(Endpoint<PCompositorManagerChild>&& aEndpoint,
MOZ_ASSERT(sInstance->mNamespace != aNamespace);
}
sInstance = new CompositorManagerChild(std::move(aEndpoint), aProcessToken,
aNamespace);
sOtherPid = sInstance->OtherPid();
if (!sInstance->CanSend()) {
RefPtr<CompositorManagerChild> child =
new CompositorManagerChild(aProcessToken, aNamespace,
/* aSameProcess */ false);
if (NS_WARN_IF(!aEndpoint.Bind(child))) {
return false;
}
child->mCanSend = true;
child->SetReplyTimeout();
sInstance = std::move(child);
SetCompositorProcInfo(sInstance->OtherEndpointProcInfo());
// If there are any canvases waiting on the recreation of the GPUProcess or
// CompositorManagerChild, then we need to notify them so that they can
@ -90,7 +112,7 @@ void CompositorManagerChild::Shutdown() {
sInstance->Close();
sInstance = nullptr;
sOtherPid = 0;
SetCompositorProcInfo(ipc::EndpointProcInfo::Invalid());
}
/* static */
@ -102,7 +124,7 @@ void CompositorManagerChild::OnGPUProcessLost(uint64_t aProcessToken) {
// yet to be. As such, we want to pre-emptively set mCanSend to false.
if (sInstance && sInstance->mProcessToken == aProcessToken) {
sInstance->mCanSend = false;
sOtherPid = 0;
SetCompositorProcInfo(ipc::EndpointProcInfo::Invalid());
}
}
@ -178,42 +200,15 @@ CompositorManagerChild::CreateSameProcessWidgetCompositorBridge(
return bridge.forget();
}
CompositorManagerChild::CompositorManagerChild(CompositorManagerParent* aParent,
uint64_t aProcessToken,
uint32_t aNamespace)
CompositorManagerChild::CompositorManagerChild(uint64_t aProcessToken,
uint32_t aNamespace,
bool aSameProcess)
: mProcessToken(aProcessToken),
mNamespace(aNamespace),
mResourceId(0),
mCanSend(false),
mSameProcess(true),
mFwdTransactionCounter(this) {
MOZ_ASSERT(aParent);
SetOtherProcessId(base::GetCurrentProcId());
if (NS_WARN_IF(!Open(aParent, CompositorThread(), ipc::ChildSide))) {
return;
}
mCanSend = true;
SetReplyTimeout();
}
CompositorManagerChild::CompositorManagerChild(
Endpoint<PCompositorManagerChild>&& aEndpoint, uint64_t aProcessToken,
uint32_t aNamespace)
: mProcessToken(aProcessToken),
mNamespace(aNamespace),
mResourceId(0),
mCanSend(false),
mSameProcess(false),
mFwdTransactionCounter(this) {
if (NS_WARN_IF(!aEndpoint.Bind(this))) {
return;
}
mCanSend = true;
SetReplyTimeout();
}
mSameProcess(aSameProcess),
mFwdTransactionCounter(this) {}
void CompositorManagerChild::ActorDestroy(ActorDestroyReason aReason) {
mCanSend = false;

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

@ -51,8 +51,9 @@ class CompositorManagerChild : public PCompositorManagerChild {
return sInstance;
}
// Threadsafe way to get the compositor process ID.
static base::ProcessId GetOtherPid() { return sOtherPid; }
// Threadsafe way to snapshot the current compositor process info from another
// thread.
static mozilla::ipc::EndpointProcInfo GetCompositorProcInfo();
bool CanSend() const {
MOZ_ASSERT(NS_IsMainThread());
@ -99,13 +100,9 @@ class CompositorManagerChild : public PCompositorManagerChild {
private:
static StaticRefPtr<CompositorManagerChild> sInstance;
static Atomic<base::ProcessId> sOtherPid;
CompositorManagerChild(CompositorManagerParent* aParent,
uint64_t aProcessToken, uint32_t aNamespace);
CompositorManagerChild(Endpoint<PCompositorManagerChild>&& aEndpoint,
uint64_t aProcessToken, uint32_t aNamespace);
CompositorManagerChild(uint64_t aProcessToken, uint32_t aNamespace,
bool aSameProcess);
virtual ~CompositorManagerChild() = default;

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

@ -46,7 +46,7 @@ CompositorManagerParent::CreateSameProcess(uint32_t aNamespace) {
// on the main thread and complete before we return the manager handles.
RefPtr<CompositorManagerParent> parent =
new CompositorManagerParent(dom::ContentParentId(), aNamespace);
parent->SetOtherProcessId(base::GetCurrentProcId());
parent->SetOtherEndpointProcInfo(ipc::EndpointProcInfo::Current());
return parent.forget();
}

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

@ -63,14 +63,14 @@ void ImageBridgeParent::Setup() {
}
ImageBridgeParent::ImageBridgeParent(nsISerialEventTarget* aThread,
ProcessId aChildProcessId,
EndpointProcInfo aChildProcessInfo,
dom::ContentParentId aContentId)
: mThread(aThread),
mContentId(aContentId),
mClosed(false),
mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()) {
MOZ_ASSERT(NS_IsMainThread());
SetOtherProcessId(aChildProcessId);
SetOtherEndpointProcInfo(aChildProcessInfo);
mRemoteTextureTxnScheduler = RemoteTextureTxnScheduler::Create(this);
}
@ -78,14 +78,14 @@ ImageBridgeParent::~ImageBridgeParent() = default;
/* static */
ImageBridgeParent* ImageBridgeParent::CreateSameProcess() {
base::ProcessId pid = base::GetCurrentProcId();
RefPtr<ImageBridgeParent> parent =
new ImageBridgeParent(CompositorThread(), pid, dom::ContentParentId());
EndpointProcInfo procInfo = EndpointProcInfo::Current();
RefPtr<ImageBridgeParent> parent = new ImageBridgeParent(
CompositorThread(), procInfo, dom::ContentParentId());
{
MonitorAutoLock lock(*sImageBridgesLock);
MOZ_RELEASE_ASSERT(sImageBridges.count(pid) == 0);
sImageBridges[pid] = parent;
MOZ_RELEASE_ASSERT(sImageBridges.count(procInfo.mPid) == 0);
sImageBridges[procInfo.mPid] = parent;
}
sImageBridgeParentSingleton = parent;
@ -102,8 +102,9 @@ bool ImageBridgeParent::CreateForGPUProcess(
return false;
}
RefPtr<ImageBridgeParent> parent = new ImageBridgeParent(
compositorThread, aEndpoint.OtherPid(), dom::ContentParentId());
RefPtr<ImageBridgeParent> parent =
new ImageBridgeParent(compositorThread, aEndpoint.OtherEndpointProcInfo(),
dom::ContentParentId());
compositorThread->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
"layers::ImageBridgeParent::Bind", parent, &ImageBridgeParent::Bind,
@ -235,8 +236,8 @@ bool ImageBridgeParent::CreateForContent(
return false;
}
RefPtr<ImageBridgeParent> bridge =
new ImageBridgeParent(compositorThread, aEndpoint.OtherPid(), aContentId);
RefPtr<ImageBridgeParent> bridge = new ImageBridgeParent(
compositorThread, aEndpoint.OtherEndpointProcInfo(), aContentId);
compositorThread->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
"layers::ImageBridgeParent::Bind", bridge, &ImageBridgeParent::Bind,
std::move(aEndpoint)));

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

@ -41,7 +41,8 @@ class ImageBridgeParent final : public PImageBridgeParent,
typedef nsTArray<OpDestroy> OpDestroyArray;
protected:
ImageBridgeParent(nsISerialEventTarget* aThread, ProcessId aChildProcessId,
ImageBridgeParent(nsISerialEventTarget* aThread,
ipc::EndpointProcInfo aChildProcessInfo,
dom::ContentParentId aContentId);
public:

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

@ -239,7 +239,7 @@ void UiCompositorControllerParent::InitializeForSameProcess() {
// This function is called by UiCompositorControllerChild in the main thread.
// So dispatch to the compositor thread to Initialize.
if (!CompositorThreadHolder::IsInCompositorThread()) {
SetOtherProcessId(base::GetCurrentProcId());
SetOtherEndpointProcInfo(ipc::EndpointProcInfo::Current());
SynchronousTask task(
"UiCompositorControllerParent::InitializeForSameProcess");

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

@ -25,8 +25,8 @@ void VideoBridgeChild::StartupForGPUProcess() {
ipc::Endpoint<PVideoBridgeParent> parentPipe;
ipc::Endpoint<PVideoBridgeChild> childPipe;
PVideoBridge::CreateEndpoints(base::GetCurrentProcId(),
base::GetCurrentProcId(), &parentPipe,
PVideoBridge::CreateEndpoints(ipc::EndpointProcInfo::Current(),
ipc::EndpointProcInfo::Current(), &parentPipe,
&childPipe);
VideoBridgeChild::Open(std::move(childPipe));

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

@ -16,10 +16,10 @@ namespace gfx {
using namespace ipc;
VRGPUParent::VRGPUParent(ProcessId aChildProcessId) : mClosed(false) {
VRGPUParent::VRGPUParent(EndpointProcInfo aChildProcess) : mClosed(false) {
MOZ_ASSERT(NS_IsMainThread());
SetOtherProcessId(aChildProcessId);
SetOtherEndpointProcInfo(aChildProcess);
}
VRGPUParent::~VRGPUParent() = default;
@ -42,7 +42,7 @@ RefPtr<VRGPUParent> VRGPUParent::CreateForGPU(
return nullptr;
}
RefPtr<VRGPUParent> vcp = new VRGPUParent(aEndpoint.OtherPid());
RefPtr<VRGPUParent> vcp = new VRGPUParent(aEndpoint.OtherEndpointProcInfo());
GetCurrentSerialEventTarget()->Dispatch(
NewRunnableMethod<Endpoint<PVRGPUParent>&&>("gfx::VRGPUParent::Bind", vcp,
&VRGPUParent::Bind,

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

@ -32,7 +32,7 @@ class VRGPUParent final : public PVRGPUParent {
mozilla::ipc::IPCResult RecvPuppetCheckForCompletion();
private:
explicit VRGPUParent(ProcessId aChildProcessId);
explicit VRGPUParent(ipc::EndpointProcInfo aChildProcess);
~VRGPUParent();
void DeferredDestroy();

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

@ -26,7 +26,7 @@ namespace gfx {
// See VRManagerChild.cpp
void ReleaseVRManagerParentSingleton();
VRManagerParent::VRManagerParent(ProcessId aChildProcessId,
VRManagerParent::VRManagerParent(ipc::EndpointProcInfo aChildProcess,
dom::ContentParentId aChildId,
bool aIsContentChild)
: mChildId(aChildId),
@ -37,7 +37,7 @@ VRManagerParent::VRManagerParent(ProcessId aChildProcessId,
MOZ_COUNT_CTOR(VRManagerParent);
MOZ_ASSERT(NS_IsMainThread());
SetOtherProcessId(aChildProcessId);
SetOtherEndpointProcInfo(aChildProcess);
}
VRManagerParent::~VRManagerParent() {
@ -88,7 +88,7 @@ bool VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint,
}
RefPtr<VRManagerParent> vmp =
new VRManagerParent(aEndpoint.OtherPid(), aChildId, true);
new VRManagerParent(aEndpoint.OtherEndpointProcInfo(), aChildId, true);
CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
std::move(aEndpoint)));
@ -114,7 +114,7 @@ void VRManagerParent::RegisterVRManagerInCompositorThread(
/*static*/
already_AddRefed<VRManagerParent> VRManagerParent::CreateSameProcess() {
RefPtr<VRManagerParent> vmp = new VRManagerParent(
base::GetCurrentProcId(), dom::ContentParentId(), false);
ipc::EndpointProcInfo::Current(), dom::ContentParentId(), false);
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
CompositorThread()->Dispatch(
NewRunnableFunction("RegisterVRManagerIncompositorThreadRunnable",
@ -124,8 +124,8 @@ already_AddRefed<VRManagerParent> VRManagerParent::CreateSameProcess() {
bool VRManagerParent::CreateForGPUProcess(
Endpoint<PVRManagerParent>&& aEndpoint) {
RefPtr<VRManagerParent> vmp =
new VRManagerParent(aEndpoint.OtherPid(), dom::ContentParentId(), false);
RefPtr<VRManagerParent> vmp = new VRManagerParent(
aEndpoint.OtherEndpointProcInfo(), dom::ContentParentId(), false);
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,

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

@ -28,7 +28,7 @@ class VRManagerParent final : public PVRManagerParent {
friend class PVRManagerParent;
public:
explicit VRManagerParent(ProcessId aChildProcessId,
explicit VRManagerParent(ipc::EndpointProcInfo aChildProcess,
dom::ContentParentId aChildId, bool aIsContentChild);
static already_AddRefed<VRManagerParent> CreateSameProcess();

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

@ -145,7 +145,7 @@ void VRProcessManager::OnProcessUnexpectedShutdown(VRProcessParent* aParent) {
}
bool VRProcessManager::CreateGPUBridges(
base::ProcessId aOtherProcess,
mozilla::ipc::EndpointProcInfo aOtherProcess,
mozilla::ipc::Endpoint<PVRGPUChild>* aOutVRBridge) {
if (!CreateGPUVRManager(aOtherProcess, aOutVRBridge)) {
return false;
@ -154,21 +154,21 @@ bool VRProcessManager::CreateGPUBridges(
}
bool VRProcessManager::CreateGPUVRManager(
base::ProcessId aOtherProcess,
mozilla::ipc::EndpointProcInfo aOtherProcess,
mozilla::ipc::Endpoint<PVRGPUChild>* aOutEndpoint) {
if (mProcess && !mProcess->IsConnected()) {
NS_WARNING("VR process haven't connected with the parent process yet");
return false;
}
base::ProcessId vrparentPid = mProcess
? mProcess->OtherPid() // VR process id.
: base::GetCurrentProcId();
ipc::EndpointProcInfo vrparentInfo =
mProcess ? ipc::EndpointProcInfo{.mPid = mProcess->GetChildProcessId(),
.mChildID = mProcess->GetChildID()}
: ipc::EndpointProcInfo::Current();
ipc::Endpoint<PVRGPUParent> vrparentPipe;
ipc::Endpoint<PVRGPUChild> vrchildPipe;
nsresult rv = PVRGPU::CreateEndpoints(vrparentPid, // vr process id
aOtherProcess, // gpu process id
nsresult rv = PVRGPU::CreateEndpoints(vrparentInfo, aOtherProcess,
&vrparentPipe, &vrchildPipe);
if (NS_FAILED(rv)) {

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

@ -41,7 +41,7 @@ class VRProcessManager final : public VRProcessParent::Listener {
// Otherwise it blocks until the VR process has finished launching.
bool EnsureVRReady();
bool CreateGPUBridges(base::ProcessId aOtherProcess,
bool CreateGPUBridges(mozilla::ipc::EndpointProcInfo aOtherProcess,
mozilla::ipc::Endpoint<PVRGPUChild>* aOutVRBridge);
VRChild* GetVRChild();
@ -57,7 +57,7 @@ class VRProcessManager final : public VRProcessParent::Listener {
DISALLOW_COPY_AND_ASSIGN(VRProcessManager);
bool CreateGPUVRManager(base::ProcessId aOtherProcess,
bool CreateGPUVRManager(mozilla::ipc::EndpointProcInfo aOtherProcess,
mozilla::ipc::Endpoint<PVRGPUChild>* aOutEndpoint);
void OnXPCOMShutdown();
void OnPreferenceChange(const char16_t* aData);

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

@ -174,7 +174,7 @@ bool VRProcessParent::InitAfterConnect(bool aSucceeded) {
Endpoint<PVRGPUChild> vrGPUBridge;
VRProcessManager* vpm = VRProcessManager::Get();
DebugOnly<bool> opened =
vpm->CreateGPUBridges(gpuChild->OtherPid(), &vrGPUBridge);
vpm->CreateGPUBridges(gpuChild->OtherEndpointProcInfo(), &vrGPUBridge);
MOZ_ASSERT(opened);
Unused << gpuChild->SendInitVR(std::move(vrGPUBridge));
@ -234,8 +234,6 @@ void VRProcessParent::OnChannelClosed() {
MOZ_ASSERT(!mVRChild);
}
base::ProcessId VRProcessParent::OtherPid() { return mVRChild->OtherPid(); }
bool VRProcessParent::IsConnected() const { return !!mVRChild; }
} // namespace gfx

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

@ -54,7 +54,6 @@ class VRProcessParent final : public mozilla::ipc::GeckoChildProcessHost {
void OnChannelClosed();
bool IsConnected() const;
base::ProcessId OtherPid();
VRChild* GetActor() const { return mVRChild.get(); }
// Return a unique id for this process, guaranteed not to be shared with any
// past or future instance of VRProcessParent.

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

@ -1410,8 +1410,7 @@ the way it sounds. For example:
bool MyPreexistingActorParent::MakeMyActor() {
Endpoint<PMyActorParent> parentEnd;
Endpoint<PMyActorChild> childEnd;
if (NS_WARN_IF(NS_FAILED(PMyActor::CreateEndpoints(
base::GetCurrentProcId(), OtherPid(), &parentEnd, &childEnd)))) {
if (NS_WARN_IF(NS_FAILED(PMyActor::CreateEndpoints(&parentEnd, &childEnd)))) {
// ... handle failure ...
return false;
}

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

@ -850,9 +850,8 @@ Above, we saw that this is started by ``Host::MakeBridgeAndResolve`` after the
auto resolveFail = MakeScopeExit([&] { mResolver(Nothing()); });
// Parent side is first PID (main/content), child is second (demo).
nsresult rv = PDempHelpline::CreateEndpoints(
mParentPid, base::GetProcId(GetChildProcessHandle()), &parent, &child);
// Parent side is first argument (main/content), child is second (demo).
nsresult rv = PDempHelpline::CreateEndpoints(&parent, &child);
// ...

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

@ -346,7 +346,8 @@ class ChildImpl final : public BackgroundChildImpl {
Endpoint<PBackgroundStarterParent> parent;
Endpoint<PBackgroundStarterChild> child;
MOZ_ALWAYS_SUCCEEDS(PBackgroundStarter::CreateEndpoints(
aActor->OtherPid(), base::GetCurrentProcId(), &parent, &child));
aActor->OtherEndpointProcInfo(), EndpointProcInfo::Current(), &parent,
&child));
MOZ_ALWAYS_TRUE(aActor->SendInitBackground(std::move(parent)));
InitStarter(std::move(child));
@ -355,14 +356,14 @@ class ChildImpl final : public BackgroundChildImpl {
void InitStarter(Endpoint<PBackgroundStarterChild>&& aEndpoint) {
AssertIsOnMainThread();
base::ProcessId otherPid = aEndpoint.OtherPid();
EndpointProcInfo otherProcInfo = aEndpoint.OtherEndpointProcInfo();
nsCOMPtr<nsISerialEventTarget> taskQueue;
MOZ_ALWAYS_SUCCEEDS(NS_CreateBackgroundTaskQueue(
"PBackgroundStarter Queue", getter_AddRefs(taskQueue)));
RefPtr<BackgroundStarterChild> starter =
new BackgroundStarterChild(otherPid, taskQueue);
new BackgroundStarterChild(otherProcInfo, taskQueue);
taskQueue->Dispatch(NS_NewRunnableFunction(
"PBackgroundStarterChild Init",
@ -459,8 +460,9 @@ class ChildImpl final : public BackgroundChildImpl {
Endpoint<PBackgroundParent> parent;
Endpoint<PBackgroundChild> child;
nsresult rv;
rv = PBackground::CreateEndpoints(
starter->mOtherPid, base::GetCurrentProcId(), &parent, &child);
rv = PBackground::CreateEndpoints(starter->mOtherProcInfo,
EndpointProcInfo::Current(), &parent,
&child);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to create top level actor!");
return nullptr;
@ -1165,7 +1167,8 @@ void ChildImpl::Startup() {
Endpoint<PBackgroundStarterParent> parent;
Endpoint<PBackgroundStarterChild> child;
MOZ_ALWAYS_SUCCEEDS(PBackgroundStarter::CreateEndpoints(
base::GetCurrentProcId(), base::GetCurrentProcId(), &parent, &child));
EndpointProcInfo::Current(), EndpointProcInfo::Current(), &parent,
&child));
MOZ_ALWAYS_TRUE(ParentImpl::AllocStarter(nullptr, std::move(parent),
/* aCrossProcess */ false));

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

@ -1251,7 +1251,8 @@ BackgroundParentImpl::RecvEnsureRDDProcessAndCreateBridge(
return IPC_OK();
}
rdd->EnsureRDDProcessAndCreateBridge(OtherPid(), parent->ChildID())
rdd->EnsureRDDProcessAndCreateBridge(OtherEndpointProcInfo(),
parent->ChildID())
->Then(GetCurrentSerialEventTarget(), __func__,
[resolver = std::move(aResolver)](
mozilla::RDDProcessManager::EnsureRDDPromise::
@ -1270,7 +1271,7 @@ mozilla::ipc::IPCResult
BackgroundParentImpl::RecvEnsureUtilityProcessAndCreateBridge(
const RemoteDecodeIn& aLocation,
EnsureUtilityProcessAndCreateBridgeResolver&& aResolver) {
base::ProcessId otherPid = OtherPid();
EndpointProcInfo otherProcInfo = OtherEndpointProcInfo();
RefPtr<ThreadsafeContentParentHandle> parent =
BackgroundParent::GetContentParentHandle(this);
if (NS_WARN_IF(!parent)) {
@ -1283,7 +1284,7 @@ BackgroundParentImpl::RecvEnsureUtilityProcessAndCreateBridge(
}
NS_DispatchToMainThread(NS_NewRunnableFunction(
"BackgroundParentImpl::RecvEnsureUtilityProcessAndCreateBridge()",
[aResolver, managerThread, otherPid, childId, aLocation]() {
[aResolver, managerThread, otherProcInfo, childId, aLocation]() {
RefPtr<UtilityProcessManager> upm =
UtilityProcessManager::GetSingleton();
using Type =
@ -1299,7 +1300,8 @@ BackgroundParentImpl::RecvEnsureUtilityProcessAndCreateBridge(
}));
} else {
SandboxingKind sbKind = GetSandboxingKindFromLocation(aLocation);
upm->StartProcessForRemoteMediaDecoding(otherPid, childId, sbKind)
upm->StartProcessForRemoteMediaDecoding(otherProcInfo, childId,
sbKind)
->Then(managerThread, __func__,
[resolver = aResolver](
mozilla::ipc::UtilityProcessManager::

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

@ -16,13 +16,13 @@ class BackgroundStarterChild final : public PBackgroundStarterChild {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BackgroundStarterChild, override)
BackgroundStarterChild(base::ProcessId aOtherPid,
BackgroundStarterChild(EndpointProcInfo aOtherProcInfo,
nsISerialEventTarget* aTaskQueue)
: mOtherPid(aOtherPid), mTaskQueue(aTaskQueue) {}
: mOtherProcInfo(aOtherProcInfo), mTaskQueue(aTaskQueue) {}
// Unlike the methods on `IToplevelProtocol`, may be accessed on any thread
// and will not be modified after construction.
const base::ProcessId mOtherPid;
const EndpointProcInfo mOtherProcInfo;
const nsCOMPtr<nsISerialEventTarget> mTaskQueue;
private:

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

@ -152,16 +152,16 @@ void ParamTraits<mozilla::ipc::UntypedEndpoint>::Write(MessageWriter* aWriter,
paramType&& aParam) {
IPC::WriteParam(aWriter, std::move(aParam.mPort));
IPC::WriteParam(aWriter, aParam.mMessageChannelId);
IPC::WriteParam(aWriter, aParam.mMyPid);
IPC::WriteParam(aWriter, aParam.mOtherPid);
IPC::WriteParam(aWriter, aParam.mMyProcInfo);
IPC::WriteParam(aWriter, aParam.mOtherProcInfo);
}
bool ParamTraits<mozilla::ipc::UntypedEndpoint>::Read(MessageReader* aReader,
paramType* aResult) {
return IPC::ReadParam(aReader, &aResult->mPort) &&
IPC::ReadParam(aReader, &aResult->mMessageChannelId) &&
IPC::ReadParam(aReader, &aResult->mMyPid) &&
IPC::ReadParam(aReader, &aResult->mOtherPid);
IPC::ReadParam(aReader, &aResult->mMyProcInfo) &&
IPC::ReadParam(aReader, &aResult->mOtherProcInfo);
}
} // namespace IPC

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

@ -47,18 +47,16 @@ struct PrivateIPDLInterface {};
class UntypedEndpoint {
public:
using ProcessId = base::ProcessId;
UntypedEndpoint() = default;
UntypedEndpoint(const PrivateIPDLInterface&, ScopedPort aPort,
const nsID& aMessageChannelId,
ProcessId aMyPid = base::kInvalidProcessId,
ProcessId aOtherPid = base::kInvalidProcessId)
EndpointProcInfo aMyProcInfo = EndpointProcInfo::Invalid(),
EndpointProcInfo aOtherProcInfo = EndpointProcInfo::Invalid())
: mPort(std::move(aPort)),
mMessageChannelId(aMessageChannelId),
mMyPid(aMyPid),
mOtherPid(aOtherPid) {}
mMyProcInfo(aMyProcInfo),
mOtherProcInfo(aOtherProcInfo) {}
UntypedEndpoint(const UntypedEndpoint&) = delete;
UntypedEndpoint(UntypedEndpoint&& aOther) = default;
@ -75,10 +73,10 @@ class UntypedEndpoint {
bool Bind(IToplevelProtocol* aActor,
nsISerialEventTarget* aEventTarget = nullptr) {
MOZ_RELEASE_ASSERT(IsValid());
MOZ_RELEASE_ASSERT(mMyPid == base::kInvalidProcessId ||
mMyPid == base::GetCurrentProcId());
MOZ_RELEASE_ASSERT(mMyProcInfo == EndpointProcInfo::Invalid() ||
mMyProcInfo == EndpointProcInfo::Current());
MOZ_RELEASE_ASSERT(!aEventTarget || aEventTarget->IsOnCurrentThread());
return aActor->Open(std::move(mPort), mMessageChannelId, mOtherPid,
return aActor->Open(std::move(mPort), mMessageChannelId, mOtherProcInfo,
aEventTarget);
}
@ -89,8 +87,8 @@ class UntypedEndpoint {
ScopedPort mPort;
nsID mMessageChannelId{};
ProcessId mMyPid = base::kInvalidProcessId;
ProcessId mOtherPid = base::kInvalidProcessId;
EndpointProcInfo mMyProcInfo;
EndpointProcInfo mOtherProcInfo;
};
/**
@ -123,15 +121,19 @@ class Endpoint final : public UntypedEndpoint {
using UntypedEndpoint::IsValid;
using UntypedEndpoint::UntypedEndpoint;
base::ProcessId OtherPid() const {
EndpointProcInfo OtherEndpointProcInfo() const {
static_assert(
endpoint_detail::ActorNeedsOtherPid<PFooSide>,
"OtherPid may only be called on Endpoints for actors which are "
"[NeedsOtherPid]");
MOZ_RELEASE_ASSERT(mOtherPid != base::kInvalidProcessId);
return mOtherPid;
MOZ_RELEASE_ASSERT(mOtherProcInfo != EndpointProcInfo::Invalid());
return mOtherProcInfo;
}
base::ProcessId OtherPid() const { return OtherEndpointProcInfo().mPid; }
GeckoChildID OtherChildID() const { return OtherEndpointProcInfo().mChildID; }
// This method binds aActor to this endpoint. After this call, the actor can
// be used to send and receive messages. The endpoint becomes invalid.
//
@ -173,21 +175,22 @@ nsresult CreateEndpoints(const PrivateIPDLInterface& aPrivate,
template <class PFooParent, class PFooChild>
nsresult CreateEndpoints(const PrivateIPDLInterface& aPrivate,
base::ProcessId aParentDestPid,
base::ProcessId aChildDestPid,
EndpointProcInfo aParentDestProcInfo,
EndpointProcInfo aChildDestProcInfo,
Endpoint<PFooParent>* aParentEndpoint,
Endpoint<PFooChild>* aChildEndpoint) {
MOZ_RELEASE_ASSERT(aParentDestPid != base::kInvalidProcessId);
MOZ_RELEASE_ASSERT(aChildDestPid != base::kInvalidProcessId);
MOZ_RELEASE_ASSERT(aParentDestProcInfo != EndpointProcInfo::Invalid());
MOZ_RELEASE_ASSERT(aChildDestProcInfo != EndpointProcInfo::Invalid());
auto [parentPort, childPort] =
NodeController::GetSingleton()->CreatePortPair();
nsID channelId = nsID::GenerateUUID();
*aParentEndpoint =
Endpoint<PFooParent>(aPrivate, std::move(parentPort), channelId,
aParentDestPid, aChildDestPid);
*aChildEndpoint = Endpoint<PFooChild>(
aPrivate, std::move(childPort), channelId, aChildDestPid, aParentDestPid);
aParentDestProcInfo, aChildDestProcInfo);
*aChildEndpoint =
Endpoint<PFooChild>(aPrivate, std::move(childPort), channelId,
aChildDestProcInfo, aParentDestProcInfo);
return NS_OK;
}

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

@ -132,8 +132,9 @@ class GeckoChildProcessHost : public SupportsWeakPtr,
UntypedEndpoint TakeInitialEndpoint() {
return UntypedEndpoint{PrivateIPDLInterface{}, std::move(mInitialPort),
mInitialChannelId, base::GetCurrentProcId(),
GetChildProcessId()};
mInitialChannelId, EndpointProcInfo::Current(),
EndpointProcInfo{.mPid = GetChildProcessId(),
.mChildID = GetChildID()}};
}
// Returns a "borrowed" handle to the child process - the handle returned

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

@ -14,8 +14,9 @@ template <typename T>
class Maybe;
namespace ipc {
struct EndpointProcInfo;
class IProtocol;
}
} // namespace ipc
} // namespace mozilla
namespace IPC {

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

@ -134,7 +134,8 @@ void ProcessChild::QuickExit() {
UntypedEndpoint ProcessChild::TakeInitialEndpoint() {
return UntypedEndpoint{PrivateIPDLInterface{},
child_thread()->TakeInitialPort(), mMessageChannelId,
base::GetCurrentProcId(), mParentPid};
EndpointProcInfo::Current(),
EndpointProcInfo{.mPid = mParentPid, .mChildID = 0}};
}
} // namespace ipc

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

@ -76,6 +76,21 @@ template <class PFooSide>
struct ParamTraits<mozilla::ipc::Endpoint<PFooSide>>
: ParamTraits<mozilla::ipc::UntypedEndpoint> {};
template <>
struct ParamTraits<mozilla::ipc::EndpointProcInfo> {
using paramType = mozilla::ipc::EndpointProcInfo;
static void Write(MessageWriter* aWriter, const paramType& aParam) {
IPC::WriteParam(aWriter, aParam.mPid);
IPC::WriteParam(aWriter, aParam.mChildID);
}
static bool Read(MessageReader* aReader, paramType* aResult) {
return IPC::ReadParam(aReader, &aResult->mPid) &&
IPC::ReadParam(aReader, &aResult->mChildID);
}
};
} // namespace IPC
namespace mozilla::ipc {

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

@ -49,6 +49,12 @@ using base::ProcessId;
namespace mozilla {
namespace ipc {
/* static */
EndpointProcInfo EndpointProcInfo::Current() {
return EndpointProcInfo{.mPid = GetCurrentProcId(),
.mChildID = XRE_GetChildID()};
}
/* static */
IPCResult IPCResult::FailImpl(NotNull<IProtocol*> actor, const char* where,
const char* why) {
@ -684,14 +690,16 @@ IToplevelProtocol::IToplevelProtocol(const char* aName, ProtocolId aProtoId,
mToplevel = this;
}
void IToplevelProtocol::SetOtherProcessId(base::ProcessId aOtherPid) {
mOtherPid = aOtherPid;
void IToplevelProtocol::SetOtherEndpointProcInfo(
EndpointProcInfo aOtherProcInfo) {
mOtherPid = aOtherProcInfo.mPid;
mOtherChildID = aOtherProcInfo.mChildID;
}
bool IToplevelProtocol::Open(ScopedPort aPort, const nsID& aMessageChannelId,
base::ProcessId aOtherPid,
EndpointProcInfo aOtherProcInfo,
nsISerialEventTarget* aEventTarget) {
SetOtherProcessId(aOtherPid);
SetOtherEndpointProcInfo(aOtherProcInfo);
return GetIPCChannel()->Open(std::move(aPort), mSide, aMessageChannelId,
aEventTarget);
}
@ -699,15 +707,15 @@ bool IToplevelProtocol::Open(ScopedPort aPort, const nsID& aMessageChannelId,
bool IToplevelProtocol::Open(IToplevelProtocol* aTarget,
nsISerialEventTarget* aEventTarget,
mozilla::ipc::Side aSide) {
SetOtherProcessId(base::GetCurrentProcId());
aTarget->SetOtherProcessId(base::GetCurrentProcId());
SetOtherEndpointProcInfo(EndpointProcInfo::Current());
aTarget->SetOtherEndpointProcInfo(EndpointProcInfo::Current());
return GetIPCChannel()->Open(aTarget->GetIPCChannel(), aEventTarget, aSide);
}
bool IToplevelProtocol::OpenOnSameThread(IToplevelProtocol* aTarget,
Side aSide) {
SetOtherProcessId(base::GetCurrentProcId());
aTarget->SetOtherProcessId(base::GetCurrentProcId());
SetOtherEndpointProcInfo(EndpointProcInfo::Current());
aTarget->SetOtherEndpointProcInfo(EndpointProcInfo::Current());
return GetIPCChannel()->OpenOnSameThread(aTarget->GetIPCChannel(), aSide);
}

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

@ -104,6 +104,23 @@ namespace ipc {
class ProtocolFdMapping;
class ProtocolCloneContext;
// Helper type used to specify process info when constructing endpoints for
// [NeedsOtherPid] toplevel actors.
struct EndpointProcInfo {
base::ProcessId mPid = base::kInvalidProcessId;
GeckoChildID mChildID = kInvalidGeckoChildID;
bool operator==(const EndpointProcInfo& aOther) const {
return mPid == aOther.mPid && mChildID == aOther.mChildID;
}
bool operator!=(const EndpointProcInfo& aOther) const {
return !operator==(aOther);
}
static EndpointProcInfo Invalid() { return {}; }
static EndpointProcInfo Current();
};
// Used to pass references to protocol actors across the wire.
// Actors created on the parent-side have a positive ID, and actors
// allocated on the child side have a negative ID.
@ -448,12 +465,12 @@ class IToplevelProtocol : public IRefCountedProtocol {
MessageChannel* GetIPCChannel() { return &mChannel; }
const MessageChannel* GetIPCChannel() const { return &mChannel; }
void SetOtherProcessId(base::ProcessId aOtherPid);
void SetOtherEndpointProcInfo(EndpointProcInfo aOtherProcInfo);
virtual void ProcessingError(Result aError, const char* aMsgName) {}
bool Open(ScopedPort aPort, const nsID& aMessageChannelId,
base::ProcessId aOtherPid,
EndpointProcInfo aOtherProcInfo,
nsISerialEventTarget* aEventTarget = nullptr);
bool Open(IToplevelProtocol* aTarget, nsISerialEventTarget* aEventTarget,
@ -537,6 +554,7 @@ class IToplevelProtocol : public IRefCountedProtocol {
}
base::ProcessId OtherPidMaybeInvalid() const { return mOtherPid; }
GeckoChildID OtherChildIDMaybeInvalid() const { return mOtherChildID; }
private:
int32_t NextId();
@ -545,6 +563,7 @@ class IToplevelProtocol : public IRefCountedProtocol {
using IDMap = nsTHashMap<nsUint32HashKey, T>;
base::ProcessId mOtherPid;
GeckoChildID mOtherChildID;
// NOTE NOTE NOTE
// Used to be on mState

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

@ -61,7 +61,7 @@ nsresult UtilityAudioDecoderChild::BindToUtilityProcess(
Endpoint<PUtilityAudioDecoderChild> utilityAudioDecoderChildEnd;
Endpoint<PUtilityAudioDecoderParent> utilityAudioDecoderParentEnd;
nsresult rv = PUtilityAudioDecoder::CreateEndpoints(
aUtilityParent->OtherPid(), base::GetCurrentProcId(),
aUtilityParent->OtherEndpointProcInfo(), EndpointProcInfo::Current(),
&utilityAudioDecoderParentEnd, &utilityAudioDecoderChildEnd);
if (NS_FAILED(rv)) {
@ -183,18 +183,18 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
// The child end is the producer of video frames; the parent end is the
// consumer.
base::ProcessId childPid = UtilityProcessManager::GetSingleton()
EndpointProcInfo childInfo = UtilityProcessManager::GetSingleton()
->GetProcessParent(mSandbox)
->OtherPid();
base::ProcessId parentPid = gpuManager->GPUProcessPid();
if (parentPid == base::kInvalidProcessId) {
->OtherEndpointProcInfo();
EndpointProcInfo parentInfo = gpuManager->GPUEndpointProcInfo();
if (parentInfo == EndpointProcInfo::Invalid()) {
NS_WARNING("GPU process Id is invald!");
return false;
}
ipc::Endpoint<layers::PVideoBridgeParent> parentPipe;
ipc::Endpoint<layers::PVideoBridgeChild> childPipe;
nsresult rv = layers::PVideoBridge::CreateEndpoints(parentPid, childPid,
nsresult rv = layers::PVideoBridge::CreateEndpoints(parentInfo, childInfo,
&parentPipe, &childPipe);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to create endpoints for video bridge!");

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

@ -319,7 +319,7 @@ UtilityProcessManager::StartUtility(RefPtr<Actor> aActor,
RefPtr<UtilityProcessManager::StartRemoteDecodingUtilityPromise>
UtilityProcessManager::StartProcessForRemoteMediaDecoding(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
SandboxingKind aSandbox) {
using RetPromise = StartRemoteDecodingUtilityPromise;
@ -363,7 +363,7 @@ UtilityProcessManager::StartProcessForRemoteMediaDecoding(
LaunchError("Start...MediaDecoding: child lost"), __func__);
}
base::ProcessId process = parent->OtherPid();
EndpointProcInfo process = parent->OtherEndpointProcInfo();
Endpoint<PRemoteDecoderManagerChild> childPipe;
Endpoint<PRemoteDecoderManagerParent> parentPipe;

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

@ -65,7 +65,7 @@ class UtilityProcessManager final : public UtilityProcessHost::Listener {
SandboxingKind aSandbox);
RefPtr<StartRemoteDecodingUtilityPromise> StartProcessForRemoteMediaDecoding(
base::ProcessId aOtherProcess, dom::ContentParentId aChildId,
EndpointProcInfo aOtherProcess, dom::ContentParentId aChildId,
SandboxingKind aSandbox);
RefPtr<JSOraclePromise> StartJSOracle(mozilla::dom::JSOracleParent* aParent);

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

@ -1766,8 +1766,8 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
params = []
if includepids:
params = [
Decl(Type("base::ProcessId"), "aParentDestPid"),
Decl(Type("base::ProcessId"), "aChildDestPid"),
Decl(Type("mozilla::ipc::EndpointProcInfo"), "aParentDestInfo"),
Decl(Type("mozilla::ipc::EndpointProcInfo"), "aChildDestInfo"),
]
params += [
Decl(
@ -3881,7 +3881,37 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
return pid;
"""
)
self.cls.addstmts([otherpidmeth, Whitespace.NL])
otherchildidmeth = MethodDefn(
MethodDecl("OtherChildID", ret=Type("::GeckoChildID"), const=True)
)
otherchildidmeth.addcode(
"""
::GeckoChildID childID =
::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid();
MOZ_RELEASE_ASSERT(childID != -1);
return childID;
"""
)
otherendpointprocinfometh = MethodDefn(
MethodDecl(
"OtherEndpointProcInfo",
ret=Type("::mozilla::ipc::EndpointProcInfo"),
const=True,
)
)
otherendpointprocinfometh.addcode(
"""
return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()};
"""
)
self.cls.addstmts(
[
otherpidmeth,
otherchildidmeth,
otherendpointprocinfometh,
Whitespace.NL,
]
)
if not ptype.isToplevel():
if 1 == len(p.managers):

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

@ -108,7 +108,8 @@ bool IPDLUnitTestParent::Start(const char* aName,
ADD_FAILURE() << "IPDLUnitTestParent::SendStart failed";
return false;
}
if (!aActor->Open(std::move(parentPort), channelId, OtherPid())) {
if (!aActor->Open(std::move(parentPort), channelId,
OtherEndpointProcInfo())) {
ADD_FAILURE() << "Unable to open parent actor";
return false;
}
@ -176,7 +177,8 @@ ipc::IPCResult IPDLUnitTestChild::RecvStart(const nsCString& aName,
mojo::core::ports::PortRef port = aPort.Port();
RefPtr<IToplevelProtocol> child = allocChildActor();
if (!child->Open(std::move(aPort), aMessageChannelId, OtherPid())) {
if (!child->Open(std::move(aPort), aMessageChannelId,
OtherEndpointProcInfo())) {
ADD_FAILURE() << "Unable to open child actor";
return IPC_FAIL(this, "Unable to open child actor");
}

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

@ -117,8 +117,7 @@ IPCResult TestEndpointOpensChild::RecvStart() {
Endpoint<PTestEndpointOpensOpenedParent> parent;
Endpoint<PTestEndpointOpensOpenedChild> child;
nsresult rv;
rv = PTestEndpointOpensOpened::CreateEndpoints(
OtherPidMaybeInvalid(), base::GetCurrentProcId(), &parent, &child);
rv = PTestEndpointOpensOpened::CreateEndpoints(&parent, &child);
if (NS_FAILED(rv)) {
ADD_FAILURE() << "opening PTestEndpointOpensOpened";
return IPC_TEST_FAIL(this);

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

@ -26,6 +26,8 @@ enum GeckoProcessType {
// sentinel, and 0 indicates the parent process.
using GeckoChildID = int32_t;
inline constexpr GeckoChildID kInvalidGeckoChildID = -1;
namespace mozilla {
namespace startup {
extern MFBT_DATA GeckoProcessType sChildProcessType;

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

@ -887,8 +887,8 @@ nsresult RemoteProxyAutoConfig::Init(nsIThread* aPACThread) {
ipc::Endpoint<PProxyAutoConfigParent> parent;
ipc::Endpoint<PProxyAutoConfigChild> child;
nsresult rv = PProxyAutoConfig::CreateEndpoints(
base::GetCurrentProcId(), socketProcessParent->OtherPid(), &parent,
&child);
ipc::EndpointProcInfo::Current(),
socketProcessParent->OtherEndpointProcInfo(), &parent, &child);
if (NS_FAILED(rv)) {
return rv;
}

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

@ -745,7 +745,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvInitSocketProcessBridge(
Endpoint<PSocketProcessBridgeParent> parentEndpoint;
Endpoint<PSocketProcessBridgeChild> childEndpoint;
if (NS_WARN_IF(NS_FAILED(PSocketProcessBridge::CreateEndpoints(
parent->OtherPid(), self->Manager()->OtherPid(), &parentEndpoint,
parent->OtherEndpointProcInfo(),
self->Manager()->OtherEndpointProcInfo(), &parentEndpoint,
&childEndpoint)))) {
resolver(std::move(invalidEndpoint));
return;

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

@ -32,9 +32,9 @@ PWinFileDialogParent::nsresult WinFileDialogParent::BindToUtilityProcess(
mozilla::ipc::UtilityProcessParent* aUtilityParent) {
Endpoint<PWinFileDialogParent> parentEnd;
Endpoint<PWinFileDialogChild> childEnd;
nsresult rv = PWinFileDialog::CreateEndpoints(base::GetCurrentProcId(),
aUtilityParent->OtherPid(),
&parentEnd, &childEnd);
nsresult rv = PWinFileDialog::CreateEndpoints(
mozilla::ipc::EndpointProcInfo::Current(),
aUtilityParent->OtherEndpointProcInfo(), &parentEnd, &childEnd);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Protocol endpoints failure");