diff --git a/docshell/base/SyncedContextInlines.h b/docshell/base/SyncedContextInlines.h index a12ddfdda6ed..31c901b0ffc7 100644 --- a/docshell/base/SyncedContextInlines.h +++ b/docshell/base/SyncedContextInlines.h @@ -278,7 +278,7 @@ typename Transaction::IndexSet Transaction::Validate( // from this transaction, so we log the failed values we're going to revert. MOZ_LOG(Context::GetSyncLog(), LogLevel::Debug, ("Transaction::PartialRevert(#%" PRIx64 ", pid %d): %s", - aOwner->Id(), aSource ? aSource->OtherPid() : -1, + aOwner->Id(), aSource ? aSource->OtherPid() : base::kInvalidProcessId, FormatTransaction(revertTxn.mModified, mValues, revertTxn.mValues) .get())); diff --git a/dom/media/ipc/RDDProcessHost.cpp b/dom/media/ipc/RDDProcessHost.cpp index c3cff03123bd..5aebcc88dba0 100644 --- a/dom/media/ipc/RDDProcessHost.cpp +++ b/dom/media/ipc/RDDProcessHost.cpp @@ -127,7 +127,7 @@ RefPtr RDDProcessHost::LaunchPromise() { return mLaunchPromise; } -void RDDProcessHost::OnChannelConnected(int32_t peer_pid) { +void RDDProcessHost::OnChannelConnected(base::ProcessId peer_pid) { MOZ_ASSERT(!NS_IsMainThread()); GeckoChildProcessHost::OnChannelConnected(peer_pid); diff --git a/dom/media/ipc/RDDProcessHost.h b/dom/media/ipc/RDDProcessHost.h index 199c41402423..8893a5ee9eaf 100644 --- a/dom/media/ipc/RDDProcessHost.h +++ b/dom/media/ipc/RDDProcessHost.h @@ -88,7 +88,7 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost { TimeStamp GetLaunchTime() const { return mLaunchTime; } // Called on the IO thread. - void OnChannelConnected(int32_t peer_pid) override; + void OnChannelConnected(base::ProcessId peer_pid) override; void OnChannelError() override; void SetListener(Listener* aListener); diff --git a/dom/media/ipc/RDDProcessManager.cpp b/dom/media/ipc/RDDProcessManager.cpp index c69d9fa67824..76a1f0267177 100644 --- a/dom/media/ipc/RDDProcessManager.cpp +++ b/dom/media/ipc/RDDProcessManager.cpp @@ -306,7 +306,8 @@ bool RDDProcessManager::CreateVideoBridge() { ipc::Endpoint childPipe; GPUProcessManager* gpuManager = GPUProcessManager::Get(); - base::ProcessId gpuProcessPid = gpuManager ? gpuManager->GPUProcessPid() : -1; + base::ProcessId gpuProcessPid = + gpuManager ? gpuManager->GPUProcessPid() : base::kInvalidProcessId; // Build content device data first; this ensure that the GPU process is fully // ready. @@ -316,8 +317,9 @@ 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 != -1 ? gpuProcessPid : base::GetCurrentProcId(); + base::ProcessId parentPid = gpuProcessPid != base::kInvalidProcessId + ? gpuProcessPid + : base::GetCurrentProcId(); nsresult rv = PVideoBridge::CreateEndpoints(parentPid, childPid, &parentPipe, &childPipe); @@ -329,7 +331,7 @@ bool RDDProcessManager::CreateVideoBridge() { mRDDChild->SendInitVideoBridge(std::move(childPipe), mNumUnexpectedCrashes == 0, contentDeviceData); - if (gpuProcessPid != -1) { + if (gpuProcessPid != base::kInvalidProcessId) { gpuManager->InitVideoBridge(std::move(parentPipe)); } else { VideoBridgeParent::Open(std::move(parentPipe), @@ -341,7 +343,8 @@ bool RDDProcessManager::CreateVideoBridge() { base::ProcessId RDDProcessManager::RDDProcessPid() { MOZ_ASSERT(NS_IsMainThread()); - base::ProcessId rddPid = mRDDChild ? mRDDChild->OtherPid() : -1; + base::ProcessId rddPid = + mRDDChild ? mRDDChild->OtherPid() : base::kInvalidProcessId; return rddPid; } diff --git a/gfx/ipc/GPUProcessHost.cpp b/gfx/ipc/GPUProcessHost.cpp index 69e79c8b98ce..49ab26e9e2aa 100644 --- a/gfx/ipc/GPUProcessHost.cpp +++ b/gfx/ipc/GPUProcessHost.cpp @@ -88,7 +88,7 @@ bool GPUProcessHost::WaitForLaunch() { return result; } -void GPUProcessHost::OnChannelConnected(int32_t peer_pid) { +void GPUProcessHost::OnChannelConnected(base::ProcessId peer_pid) { MOZ_ASSERT(!NS_IsMainThread()); GeckoChildProcessHost::OnChannelConnected(peer_pid); diff --git a/gfx/ipc/GPUProcessHost.h b/gfx/ipc/GPUProcessHost.h index 37dd4ec6c30a..cffc495cf31b 100644 --- a/gfx/ipc/GPUProcessHost.h +++ b/gfx/ipc/GPUProcessHost.h @@ -100,7 +100,7 @@ class GPUProcessHost final : public mozilla::ipc::GeckoChildProcessHost { TimeStamp GetLaunchTime() const { return mLaunchTime; } // Called on the IO thread. - void OnChannelConnected(int32_t peer_pid) override; + void OnChannelConnected(base::ProcessId peer_pid) override; void OnChannelError() override; void SetListener(Listener* aListener); diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index ac6c627a585c..d789d0dc00b5 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -1098,7 +1098,8 @@ bool GPUProcessManager::CreateContentImageBridge( } base::ProcessId GPUProcessManager::GPUProcessPid() { - base::ProcessId gpuPid = mGPUChild ? mGPUChild->OtherPid() : -1; + base::ProcessId gpuPid = + mGPUChild ? mGPUChild->OtherPid() : base::kInvalidProcessId; return gpuPid; } diff --git a/gfx/layers/ipc/SharedSurfacesParent.cpp b/gfx/layers/ipc/SharedSurfacesParent.cpp index 05771254e05a..bb1cc11dbabc 100644 --- a/gfx/layers/ipc/SharedSurfacesParent.cpp +++ b/gfx/layers/ipc/SharedSurfacesParent.cpp @@ -357,7 +357,7 @@ bool SharedSurfacesParent::AccumulateMemoryReport( SharedSurfacesMemoryReport& aReport) { if (XRE_IsParentProcess()) { GPUProcessManager* gpm = GPUProcessManager::Get(); - if (!gpm || gpm->GPUProcessPid() != -1) { + if (!gpm || gpm->GPUProcessPid() != base::kInvalidProcessId) { return false; } } else if (!XRE_IsGPUProcess()) { diff --git a/gfx/vr/ipc/VRProcessParent.cpp b/gfx/vr/ipc/VRProcessParent.cpp index 37187bb57693..eba06adafaa7 100644 --- a/gfx/vr/ipc/VRProcessParent.cpp +++ b/gfx/vr/ipc/VRProcessParent.cpp @@ -198,7 +198,7 @@ void VRProcessParent::OnChannelError() { MOZ_ASSERT(false, "VR process channel error."); } -void VRProcessParent::OnChannelConnected(int32_t peer_pid) { +void VRProcessParent::OnChannelConnected(base::ProcessId peer_pid) { MOZ_ASSERT(!NS_IsMainThread()); GeckoChildProcessHost::OnChannelConnected(peer_pid); diff --git a/gfx/vr/ipc/VRProcessParent.h b/gfx/vr/ipc/VRProcessParent.h index efe1708af088..75c65e594ef8 100644 --- a/gfx/vr/ipc/VRProcessParent.h +++ b/gfx/vr/ipc/VRProcessParent.h @@ -49,7 +49,7 @@ class VRProcessParent final : public mozilla::ipc::GeckoChildProcessHost { bool CanShutdown() override { return true; } void OnChannelError() override; - void OnChannelConnected(int32_t peer_pid) override; + void OnChannelConnected(base::ProcessId peer_pid) override; void OnChannelConnectedTask(); void OnChannelErrorTask(); void OnChannelClosed(); diff --git a/ipc/chromium/src/chrome/common/child_process_host.cc b/ipc/chromium/src/chrome/common/child_process_host.cc index 8734c0d86695..f6dea61fcdcf 100644 --- a/ipc/chromium/src/chrome/common/child_process_host.cc +++ b/ipc/chromium/src/chrome/common/child_process_host.cc @@ -47,7 +47,8 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(IPC::Message&& msg) { host_->OnMessageReceived(std::move(msg)); } -void ChildProcessHost::ListenerHook::OnChannelConnected(int32_t peer_pid) { +void ChildProcessHost::ListenerHook::OnChannelConnected( + base::ProcessId peer_pid) { host_->opening_channel_ = false; host_->OnChannelConnected(peer_pid); } diff --git a/ipc/chromium/src/chrome/common/child_process_host.h b/ipc/chromium/src/chrome/common/child_process_host.h index a3845d6b7af5..8a2f790bd72a 100644 --- a/ipc/chromium/src/chrome/common/child_process_host.h +++ b/ipc/chromium/src/chrome/common/child_process_host.h @@ -40,7 +40,7 @@ class ChildProcessHost : public IPC::Channel::Listener { // IPC::Channel::Listener implementation: virtual void OnMessageReceived(IPC::Message&& msg) override {} - virtual void OnChannelConnected(int32_t peer_pid) override {} + virtual void OnChannelConnected(base::ProcessId peer_pid) override {} virtual void OnChannelError() override {} bool opening_channel() { return opening_channel_; } @@ -57,7 +57,7 @@ class ChildProcessHost : public IPC::Channel::Listener { public: explicit ListenerHook(ChildProcessHost* host); virtual void OnMessageReceived(IPC::Message&& msg) override; - virtual void OnChannelConnected(int32_t peer_pid) override; + virtual void OnChannelConnected(base::ProcessId peer_pid) override; virtual void OnChannelError() override; virtual void GetQueuedMessages(std::queue& queue) override; diff --git a/ipc/chromium/src/chrome/common/ipc_channel.h b/ipc/chromium/src/chrome/common/ipc_channel.h index 7b61e78c2012..f7b6009c0df5 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel.h +++ b/ipc/chromium/src/chrome/common/ipc_channel.h @@ -10,6 +10,7 @@ #include #include #include "base/basictypes.h" +#include "base/process.h" #include "build/build_config.h" #include "mozilla/UniquePtr.h" #include "mozilla/UniquePtrExtensions.h" @@ -60,7 +61,7 @@ class Channel { // Called when the channel is connected and we have received the internal // Hello message from the peer. - virtual void OnChannelConnected(int32_t peer_pid) {} + virtual void OnChannelConnected(base::ProcessId peer_pid) {} // Called when an error is detected that causes the channel to close. // This method is not called when a channel is closed normally. diff --git a/ipc/chromium/src/chrome/common/ipc_channel_utils.cc b/ipc/chromium/src/chrome/common/ipc_channel_utils.cc index 46645a962c01..a12b3aee87d7 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_utils.cc +++ b/ipc/chromium/src/chrome/common/ipc_channel_utils.cc @@ -16,7 +16,7 @@ void AddIPCProfilerMarker(const Message& aMessage, int32_t aOtherPid, mozilla::ipc::MessagePhase aPhase) { if (aMessage.routing_id() != MSG_ROUTING_NONE && profiler_feature_active(ProfilerFeature::IPCMessages)) { - if (aOtherPid == -1) { + if (aOtherPid == base::kInvalidProcessId) { DLOG(WARNING) << "Unable to record IPC profile marker, other PID not set"; return; } diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 8596f4e2a9ec..f1758d710f40 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -1575,7 +1575,7 @@ bool GeckoChildProcessHost::OpenPrivilegedHandle(base::ProcessId aPid) { return base::OpenPrivilegedProcessHandle(aPid, &mChildProcessHandle); } -void GeckoChildProcessHost::OnChannelConnected(int32_t peer_pid) { +void GeckoChildProcessHost::OnChannelConnected(base::ProcessId peer_pid) { if (!OpenPrivilegedHandle(peer_pid)) { MOZ_CRASH("can't open handle to child process"); } diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index 8aea290667f9..ca235a1d6e70 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -109,7 +109,7 @@ class GeckoChildProcessHost : public ChildProcessHost, bool SyncLaunch(StringVector aExtraOpts = StringVector(), int32_t timeoutMs = 0); - virtual void OnChannelConnected(int32_t peer_pid) override; + virtual void OnChannelConnected(base::ProcessId peer_pid) override; virtual void OnMessageReceived(IPC::Message&& aMsg) override; virtual void OnChannelError() override; virtual void GetQueuedMessages(std::queue& queue) override; diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 331da2724ef6..0ccd0ec6fe95 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -2137,7 +2137,7 @@ void MessageChannel::AddProfilerMarker(const IPC::Message& aMessage, mMonitor->AssertCurrentThreadOwns(); if (profiler_feature_active(ProfilerFeature::IPCMessages)) { - int32_t pid = mListener->OtherPidMaybeInvalid(); + base::ProcessId pid = mListener->OtherPidMaybeInvalid(); // Only record markers for IPCs with a valid pid. // And if one of the profiler mutexes is locked on this thread, don't record // markers, because we don't want to expose profiler IPCs due to the diff --git a/ipc/glue/NodeChannel.cpp b/ipc/glue/NodeChannel.cpp index 2670492ce87c..475df00a4e6b 100644 --- a/ipc/glue/NodeChannel.cpp +++ b/ipc/glue/NodeChannel.cpp @@ -37,7 +37,7 @@ namespace mozilla::ipc { NodeChannel::NodeChannel(const NodeName& aName, UniquePtr aChannel, Listener* aListener, - int32_t aPid) + base::ProcessId aPid) : mListener(aListener), mName(aName), mOtherPid(aPid), @@ -97,8 +97,8 @@ void NodeChannel::Start(bool aCallConnect) { } } else { // Check if our channel has already been connected, and knows the other PID. - int32_t otherPid = mChannel->OtherPid(); - if (otherPid != -1) { + base::ProcessId otherPid = mChannel->OtherPid(); + if (otherPid != base::kInvalidProcessId) { SetOtherPid(otherPid); } @@ -121,11 +121,11 @@ void NodeChannel::Close() { mClosed = true; } -void NodeChannel::SetOtherPid(int32_t aNewPid) { +void NodeChannel::SetOtherPid(base::ProcessId aNewPid) { AssertIOThread(); - MOZ_ASSERT(aNewPid != -1); + MOZ_ASSERT(aNewPid != base::kInvalidProcessId); - int32_t previousPid = -1; + base::ProcessId previousPid = base::kInvalidProcessId; if (!mOtherPid.compare_exchange_strong(previousPid, aNewPid)) { // The PID was already set before this call, double-check that it's correct. MOZ_RELEASE_ASSERT(previousPid == aNewPid, @@ -282,7 +282,7 @@ void NodeChannel::OnMessageReceived(IPC::Message&& aMessage) { OnChannelError(); } -void NodeChannel::OnChannelConnected(int32_t aPeerPid) { +void NodeChannel::OnChannelConnected(base::ProcessId aPeerPid) { AssertIOThread(); SetOtherPid(aPeerPid); diff --git a/ipc/glue/NodeChannel.h b/ipc/glue/NodeChannel.h index 75d4a7a8c945..102a195925a4 100644 --- a/ipc/glue/NodeChannel.h +++ b/ipc/glue/NodeChannel.h @@ -9,6 +9,7 @@ #include "mojo/core/ports/node.h" #include "mojo/core/ports/node_delegate.h" +#include "base/process.h" #include "chrome/common/ipc_message.h" #include "chrome/common/ipc_channel.h" #include "mozilla/ipc/ProtocolUtils.h" @@ -37,8 +38,8 @@ class NodeChannel final : public IPC::Channel::Listener { NodeName mName; IPC::Channel::ChannelHandle mHandle; IPC::Channel::Mode mMode; - int32_t mMyPid = -1; - int32_t mOtherPid = -1; + base::ProcessId mMyPid = base::kInvalidProcessId; + base::ProcessId mOtherPid = base::kInvalidProcessId; }; class Listener { @@ -62,7 +63,7 @@ class NodeChannel final : public IPC::Channel::Listener { }; NodeChannel(const NodeName& aName, UniquePtr aChannel, - Listener* aListener, int32_t aPid = -1); + Listener* aListener, base::ProcessId aPid = base::kInvalidProcessId); // Send the given message over this peer channel link. May be called from any // thread. @@ -82,7 +83,7 @@ class NodeChannel final : public IPC::Channel::Listener { void AcceptInvite(const NodeName& aRealName, const PortName& aInitialPort); // The PID of the remote process, once known. May be called from any thread. - int32_t OtherPid() const { return mOtherPid; } + base::ProcessId OtherPid() const { return mOtherPid; } // Start communicating with the remote process using this NodeChannel. MUST BE // CALLED FROM THE IO THREAD. @@ -109,14 +110,14 @@ class NodeChannel final : public IPC::Channel::Listener { void FinalDestroy(); // Update the known PID for the remote process. IO THREAD ONLY - void SetOtherPid(int32_t aNewPid); + void SetOtherPid(base::ProcessId aNewPid); void SendMessage(UniquePtr aMessage); void DoSendMessage(UniquePtr aMessage); // IPC::Channel::Listener implementation void OnMessageReceived(IPC::Message&& aMessage) override; - void OnChannelConnected(int32_t aPeerPid) override; + void OnChannelConnected(base::ProcessId aPeerPid) override; void OnChannelError() override; // NOTE: This strong reference will create a reference cycle between the @@ -133,7 +134,7 @@ class NodeChannel final : public IPC::Channel::Listener { // NOTE: This won't change once the connection has been established, but may // be `-1` until then. This will only be written to on the IO thread, but may // be read from other threads. - std::atomic mOtherPid; + std::atomic mOtherPid; // WARNING: This must only be accessed on the IO thread. mozilla::UniquePtr mChannel; diff --git a/ipc/glue/NodeController.cpp b/ipc/glue/NodeController.cpp index b31760cb8fef..d610d080b1d2 100644 --- a/ipc/glue/NodeController.cpp +++ b/ipc/glue/NodeController.cpp @@ -283,7 +283,7 @@ void NodeController::DropPeer(NodeName aNodeName) { NODECONTROLLER_LOG(LogLevel::Info, "Dropping Peer %s (pid: %d)", ToString(aNodeName).c_str(), - channel ? channel->OtherPid() : -1); + channel ? channel->OtherPid() : base::kInvalidProcessId); if (channel) { channel->Close(); @@ -670,7 +670,7 @@ void NodeController::OnRequestIntroduction(const NodeName& aFromNode, // an invalid introduction to content to clean up any pending outbound // messages. NodeChannel::Introduction intro{aName, nullptr, IPC::Channel::MODE_SERVER, - peerA->OtherPid(), -1}; + peerA->OtherPid(), base::kInvalidProcessId}; peerA->Introduce(std::move(intro)); return; } diff --git a/ipc/glue/UtilityProcessHost.cpp b/ipc/glue/UtilityProcessHost.cpp index 45e7e59f02d6..1e2433752cc5 100644 --- a/ipc/glue/UtilityProcessHost.cpp +++ b/ipc/glue/UtilityProcessHost.cpp @@ -141,7 +141,7 @@ RefPtr UtilityProcessHost::LaunchPromise() { return mLaunchPromise; } -void UtilityProcessHost::OnChannelConnected(int32_t peer_pid) { +void UtilityProcessHost::OnChannelConnected(base::ProcessId peer_pid) { MOZ_ASSERT(!NS_IsMainThread()); GeckoChildProcessHost::OnChannelConnected(peer_pid); diff --git a/ipc/glue/UtilityProcessHost.h b/ipc/glue/UtilityProcessHost.h index 70cd73a62ee9..154a4d90b3e4 100644 --- a/ipc/glue/UtilityProcessHost.h +++ b/ipc/glue/UtilityProcessHost.h @@ -83,7 +83,7 @@ class UtilityProcessHost final : public mozilla::ipc::GeckoChildProcessHost { } // Called on the IO thread. - void OnChannelConnected(int32_t peer_pid) override; + void OnChannelConnected(base::ProcessId peer_pid) override; void OnChannelError() override; #if defined(XP_MACOSX) && defined(MOZ_SANDBOX) diff --git a/netwerk/ipc/SocketProcessHost.cpp b/netwerk/ipc/SocketProcessHost.cpp index b9e3ca93b512..44ad98dca288 100644 --- a/netwerk/ipc/SocketProcessHost.cpp +++ b/netwerk/ipc/SocketProcessHost.cpp @@ -96,7 +96,7 @@ static void HandleErrorAfterDestroy( })); } -void SocketProcessHost::OnChannelConnected(int32_t peer_pid) { +void SocketProcessHost::OnChannelConnected(base::ProcessId peer_pid) { MOZ_ASSERT(!NS_IsMainThread()); GeckoChildProcessHost::OnChannelConnected(peer_pid); diff --git a/netwerk/ipc/SocketProcessHost.h b/netwerk/ipc/SocketProcessHost.h index 105a90e3a296..1993d796be2d 100644 --- a/netwerk/ipc/SocketProcessHost.h +++ b/netwerk/ipc/SocketProcessHost.h @@ -74,7 +74,7 @@ class SocketProcessHost final : public mozilla::ipc::GeckoChildProcessHost { } // Called on the IO thread. - void OnChannelConnected(int32_t peer_pid) override; + void OnChannelConnected(base::ProcessId peer_pid) override; void OnChannelError() override; #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)