Bug 1908725 - Part 4: Switch some basic uses of OtherPid over to OtherChildID, r=smaug

There are many other uses of OtherPid which could be switched over to
OtherChildID, but these were a couple of obvious low-hanging fruit use-cases
which will work better when using OtherChildID.

Differential Revision: https://phabricator.services.mozilla.com/D217120
This commit is contained in:
Nika Layzell 2024-08-07 20:39:40 +00:00
Родитель d2c96b2361
Коммит 22a4aacd26
12 изменённых файлов: 32 добавлений и 32 удалений

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

@ -277,13 +277,14 @@ typename Transaction<Context>::IndexSet Transaction<Context>::Validate(
if (!revertTxn.mModified.isEmpty()) {
// NOTE: Logging with modified IndexSet from revert transaction, and values
// from this transaction, so we log the failed values we're going to revert.
MOZ_LOG(
Context::GetSyncLog(), LogLevel::Debug,
("Transaction::PartialRevert(#%" PRIx64 ", pid %" PRIPID "): %s",
aOwner->Id(), aSource ? aSource->OtherPid() : base::kInvalidProcessId,
FormatTransaction<Context>(revertTxn.mModified, mValues,
revertTxn.mValues)
.get()));
MOZ_LOG(Context::GetSyncLog(), LogLevel::Debug,
("Transaction::PartialRevert(#%" PRIx64 ", childid %d, pid %" PRIPID
"): %s",
aOwner->Id(), aSource ? aSource->OtherChildID() : -1,
aSource ? aSource->OtherPid() : base::kInvalidProcessId,
FormatTransaction<Context>(revertTxn.mModified, mValues,
revertTxn.mValues)
.get()));
mModified -= revertTxn.mModified;

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

@ -142,7 +142,7 @@ void BroadcastChannelService::PostMessage(BroadcastChannelParent* aParent,
continue;
}
if (parent->OtherPid() == aParent->OtherPid()) {
if (parent->OtherChildID() == aParent->OtherChildID()) {
++selectedActorsOnSamePid;
}

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

@ -1558,8 +1558,8 @@ mozilla::ipc::IPCResult ContentChild::RecvInitProcessHangMonitor(
}
mozilla::ipc::IPCResult ContentChild::GetResultForRenderingInitFailure(
base::ProcessId aOtherPid) {
if (aOtherPid == base::GetCurrentProcId() || aOtherPid == OtherPid()) {
GeckoChildID aOtherChildID) {
if (aOtherChildID == XRE_GetChildID() || aOtherChildID == OtherChildID()) {
// If we are talking to ourselves, or the UI process, then that is a fatal
// protocol error.
return IPC_FAIL_NO_REASON(this);
@ -1593,17 +1593,17 @@ mozilla::ipc::IPCResult ContentChild::RecvInitRendering(
// there are localized failures (e.g. failed to spawn a thread), then it
// should MOZ_RELEASE_ASSERT or MOZ_CRASH as necessary instead.
if (!CompositorManagerChild::Init(std::move(aCompositor), namespaces[0])) {
return GetResultForRenderingInitFailure(aCompositor.OtherPid());
return GetResultForRenderingInitFailure(aCompositor.OtherChildID());
}
if (!CompositorManagerChild::CreateContentCompositorBridge(namespaces[1])) {
return GetResultForRenderingInitFailure(aCompositor.OtherPid());
return GetResultForRenderingInitFailure(aCompositor.OtherChildID());
}
if (!ImageBridgeChild::InitForContent(std::move(aImageBridge),
namespaces[2])) {
return GetResultForRenderingInitFailure(aImageBridge.OtherPid());
return GetResultForRenderingInitFailure(aImageBridge.OtherChildID());
}
if (!gfx::VRManagerChild::InitForContent(std::move(aVRBridge))) {
return GetResultForRenderingInitFailure(aVRBridge.OtherPid());
return GetResultForRenderingInitFailure(aVRBridge.OtherChildID());
}
RemoteDecoderManagerChild::InitForGPUProcess(std::move(aVideoManager));
@ -1630,17 +1630,17 @@ mozilla::ipc::IPCResult ContentChild::RecvReinitRendering(
// Re-establish singleton bridges to the compositor.
if (!CompositorManagerChild::Init(std::move(aCompositor), namespaces[0])) {
return GetResultForRenderingInitFailure(aCompositor.OtherPid());
return GetResultForRenderingInitFailure(aCompositor.OtherChildID());
}
if (!CompositorManagerChild::CreateContentCompositorBridge(namespaces[1])) {
return GetResultForRenderingInitFailure(aCompositor.OtherPid());
return GetResultForRenderingInitFailure(aCompositor.OtherChildID());
}
if (!ImageBridgeChild::ReinitForContent(std::move(aImageBridge),
namespaces[2])) {
return GetResultForRenderingInitFailure(aImageBridge.OtherPid());
return GetResultForRenderingInitFailure(aImageBridge.OtherChildID());
}
if (!gfx::VRManagerChild::InitForContent(std::move(aVRBridge))) {
return GetResultForRenderingInitFailure(aVRBridge.OtherPid());
return GetResultForRenderingInitFailure(aVRBridge.OtherChildID());
}
gfxPlatform::GetPlatform()->CompositorUpdated();
@ -3332,12 +3332,11 @@ mozilla::ipc::IPCResult ContentChild::RecvGetFilesResponse(
/* static */
void ContentChild::FatalErrorIfNotUsingGPUProcess(const char* const aErrorMsg,
base::ProcessId aOtherPid) {
GeckoChildID aChildID) {
// If we're communicating with the same process or the UI process then we
// want to crash normally. Otherwise we want to just warn as the other end
// must be the GPU process and it crashing shouldn't be fatal for us.
if (aOtherPid == base::GetCurrentProcId() ||
(GetSingleton() && GetSingleton()->OtherPid() == aOtherPid)) {
if (aChildID == XRE_GetChildID() || aChildID == 0) {
mozilla::ipc::FatalError(aErrorMsg, false);
} else {
nsAutoCString formattedMessage("IPDL error: \"");

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

@ -566,7 +566,7 @@ class ContentChild final : public PContentChild,
* GPU process crashes.
*/
static void FatalErrorIfNotUsingGPUProcess(const char* const aErrorMsg,
base::ProcessId aOtherPid);
GeckoChildID aOtherChildID);
using AnonymousTemporaryFileCallback = std::function<void(PRFileDesc*)>;
nsresult AsyncOpenAnonymousTemporaryFile(
@ -626,7 +626,7 @@ class ContentChild final : public PContentChild,
void ShutdownInternal();
mozilla::ipc::IPCResult GetResultForRenderingInitFailure(
base::ProcessId aOtherPid);
GeckoChildID aOtherChildID);
virtual void ActorDestroy(ActorDestroyReason why) override;

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

@ -4240,9 +4240,9 @@ void ContentParent::HandleOrphanedMinidump(nsString* aDumpId) {
CrashReporterHost::RecordCrash(GeckoProcessType_Content,
nsICrashService::CRASH_TYPE_CRASH, *aDumpId);
} else {
NS_WARNING(nsPrintfCString("content process pid = %" PRIPID
NS_WARNING(nsPrintfCString("content process childid = %d pid = %" PRIPID
" crashed without leaving a minidump behind",
OtherPid())
OtherChildID(), OtherPid())
.get());
}
}

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

@ -910,7 +910,7 @@ void RemoteDecoderManagerChild::DeallocateSurfaceDescriptor(
}
void RemoteDecoderManagerChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
void RemoteDecoderManagerChild::SetSupported(

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

@ -120,7 +120,7 @@ void VsyncBridgeChild::ProcessingError(Result aCode, const char* aReason) {
}
void VsyncBridgeChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
} // namespace gfx

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

@ -218,7 +218,7 @@ void CompositorManagerChild::ActorDestroy(ActorDestroyReason aReason) {
}
void CompositorManagerChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
void CompositorManagerChild::ProcessingError(Result aCode,

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

@ -958,7 +958,7 @@ bool ImageBridgeChild::CanSend() const {
}
void ImageBridgeChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
wr::MaybeExternalImageId ImageBridgeChild::GetNextExternalImageId() {

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

@ -212,7 +212,7 @@ void UiCompositorControllerChild::ProcessingError(Result aCode,
}
void UiCompositorControllerChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
mozilla::ipc::IPCResult

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

@ -176,7 +176,7 @@ bool VideoBridgeChild::IsSameProcess() const {
}
void VideoBridgeChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
mozilla::ipc::IPCResult VideoBridgeChild::RecvPing(PingResolver&& aResolver) {

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

@ -590,7 +590,7 @@ void VRManagerChild::StopActivity() {
}
void VRManagerChild::HandleFatalError(const char* aMsg) {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherChildID());
}
void VRManagerChild::AddPromise(const uint32_t& aID, dom::Promise* aPromise) {