From 4a956a2673e561410c27ec9aa0657b5f2d93c69c Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Mon, 21 Jun 2021 21:53:10 +0000 Subject: [PATCH] Bug 1706374 - Part 10: Remove unnecessary IToplevelProtocol::OnChannelConnected, r=handyman,jgilbert Differential Revision: https://phabricator.services.mozilla.com/D116665 --- dom/ipc/ContentParent.cpp | 6 ------ dom/ipc/ContentParent.h | 2 -- gfx/vr/ipc/VRManagerParent.cpp | 12 ++++++++---- gfx/vr/ipc/VRManagerParent.h | 2 +- ipc/glue/MessageChannel.cpp | 24 ------------------------ ipc/glue/MessageChannel.h | 12 ------------ ipc/glue/MessageLink.cpp | 7 ------- ipc/glue/ProtocolUtils.h | 1 - 8 files changed, 9 insertions(+), 57 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 3e1d3d4937ee..369d00a0fc46 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1971,12 +1971,6 @@ void ContentParent::OnChannelError() { PContentParent::OnChannelError(); } -void ContentParent::OnChannelConnected(int32_t pid) { - MOZ_ASSERT(NS_IsMainThread()); - - SetOtherProcessId(pid); -} - void ContentParent::ProcessingError(Result aCode, const char* aReason) { if (MsgDropped == aCode) { return; diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 760284be50fc..ca3b3251a32f 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -716,8 +716,6 @@ class ContentParent final bool CheckBrowsingContextEmbedder(CanonicalBrowsingContext* aBC, const char* aOperation) const; - void OnChannelConnected(int32_t pid) override; - void ActorDestroy(ActorDestroyReason why) override; void ActorDealloc() override; diff --git a/gfx/vr/ipc/VRManagerParent.cpp b/gfx/vr/ipc/VRManagerParent.cpp index 3f0140596fcf..5d154e1b32d0 100644 --- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -145,16 +145,20 @@ void VRManagerParent::Shutdown() { void VRManagerParent::ActorDestroy(ActorDestroyReason why) {} +void VRManagerParent::ActorAlloc() { + // FIXME: This actor should probably use proper refcounting instead of manual + // reference management, and probably shouldn't manage + // `mCompositorThreadHolder` in the alloc/dealloc methods. + PVRManagerParent::ActorAlloc(); + mCompositorThreadHolder = CompositorThreadHolder::GetSingleton(); +} + void VRManagerParent::ActorDealloc() { UnregisterFromManager(); mCompositorThreadHolder = nullptr; mSelfRef = nullptr; } -void VRManagerParent::OnChannelConnected(int32_t aPid) { - mCompositorThreadHolder = CompositorThreadHolder::GetSingleton(); -} - mozilla::ipc::IPCResult VRManagerParent::RecvDetectRuntimes() { // Detect runtime capabilities. This will return the presense of VR and/or AR // runtime software, without enumerating or activating any hardware devices. diff --git a/gfx/vr/ipc/VRManagerParent.h b/gfx/vr/ipc/VRManagerParent.h index fee9569b78a2..bc23d541a6a4 100644 --- a/gfx/vr/ipc/VRManagerParent.h +++ b/gfx/vr/ipc/VRManagerParent.h @@ -48,7 +48,6 @@ class VRManagerParent final : public PVRManagerParent { bool DeallocPVRLayerParent(PVRLayerParent* actor); virtual void ActorDestroy(ActorDestroyReason why) override; - void OnChannelConnected(int32_t pid) override; mozilla::ipc::IPCResult RecvDetectRuntimes(); mozilla::ipc::IPCResult RecvRefreshDisplays(); @@ -74,6 +73,7 @@ class VRManagerParent final : public PVRManagerParent { mozilla::ipc::IPCResult RecvResetPuppet(); private: + void ActorAlloc() override; void ActorDealloc() override; void RegisterWithManager(); void UnregisterFromManager(); diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index a819fb16e80b..6af480938a64 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -583,8 +583,6 @@ MessageChannel::MessageChannel(const char* aName, IToplevelProtocol* aListener) mAbortOnError(false), mNotifiedChannelDone(false), mFlags(REQUIRE_DEFAULT), - mPeerPidSet(false), - mPeerPid(-1), mIsPostponingSends(false), mBuildIDsConfirmedMatch(false), mIsSameThreadChannel(false) { @@ -593,13 +591,7 @@ MessageChannel::MessageChannel(const char* aName, IToplevelProtocol* aListener) #ifdef OS_WIN mTopFrame = nullptr; mIsSyncWaitingOnNonMainThread = false; -#endif - mOnChannelConnectedTask = NewNonOwningCancelableRunnableMethod( - "ipc::MessageChannel::DispatchOnChannelConnected", this, - &MessageChannel::DispatchOnChannelConnected); - -#ifdef OS_WIN mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr); MOZ_RELEASE_ASSERT(mEvent, "CreateEvent failed! Nothing is going to work!"); #endif @@ -773,8 +765,6 @@ void MessageChannel::Clear() { mLink = nullptr; } - mOnChannelConnectedTask->Cancel(); - if (mChannelErrorTask) { mChannelErrorTask->Cancel(); mChannelErrorTask = nullptr; @@ -2386,20 +2376,6 @@ void MessageChannel::SetReplyTimeoutMs(int32_t aTimeoutMs) { (aTimeoutMs <= 0) ? kNoTimeout : (int32_t)ceil((double)aTimeoutMs / 2.0); } -void MessageChannel::OnChannelConnected(int32_t peer_id) { - MOZ_RELEASE_ASSERT(!mPeerPidSet); - mPeerPidSet = true; - mPeerPid = peer_id; - RefPtr task = mOnChannelConnectedTask; - mWorkerThread->Dispatch(task.forget()); -} - -void MessageChannel::DispatchOnChannelConnected() { - AssertWorkerThread(); - MOZ_RELEASE_ASSERT(mPeerPidSet); - mListener->OnChannelConnected(mPeerPid); -} - void MessageChannel::ReportMessageRouteError(const char* channelName) const { PrintErrorMessage(mSide, channelName, "Need a route"); mListener->ProcessingError(MsgRouteError, "MsgRouteError"); diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index 0952256b1099..10d4a627161c 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -394,9 +394,6 @@ class MessageChannel : HasResultCodes { void Clear(); - // Send OnChannelConnected notification to listeners. - void DispatchOnChannelConnected(); - bool InterruptEventOccurred(); bool HasPendingEvents(); @@ -531,8 +528,6 @@ class MessageChannel : HasResultCodes { // thread, in which case it shouldn't be delivered to the worker. bool MaybeInterceptSpecialIOMessage(const Message& aMsg); - void OnChannelConnected(int32_t peer_id); - // Tell the IO thread to close the channel and wait for it to ACK. void SynchronouslyClose(); @@ -851,13 +846,6 @@ class MessageChannel : HasResultCodes { // See SetChannelFlags ChannelFlags mFlags; - // Task and state used to asynchronously notify channel has been connected - // safely. This is necessary to be able to cancel notification if we are - // closed at the same time. - RefPtr mOnChannelConnectedTask; - bool mPeerPidSet; - int32_t mPeerPid; - // Channels can enter messages are not sent immediately; instead, they are // held in a queue until another thread deems it is safe to send them. bool mIsPostponingSends; diff --git a/ipc/glue/MessageLink.cpp b/ipc/glue/MessageLink.cpp index 3c6b8e51c8a9..65c2319d4009 100644 --- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -315,8 +315,6 @@ void ProcessLink::OnTakeConnectedChannel() { void ProcessLink::OnChannelConnected(int32_t peer_pid) { AssertIOThread(); - bool notifyChannel = false; - { MonitorAutoLock lock(*mChan->mMonitor); // Do not force it into connected if it has errored out, started @@ -326,17 +324,12 @@ void ProcessLink::OnChannelConnected(int32_t peer_pid) { mChan->mChannelState == ChannelConnected) { mChan->mChannelState = ChannelConnected; mChan->mMonitor->Notify(); - notifyChannel = true; } } if (mExistingListener) { mExistingListener->OnChannelConnected(peer_pid); } - - if (notifyChannel) { - mChan->OnChannelConnected(peer_pid); - } } void ProcessLink::OnChannelConnectError() { diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index c3ad79d0e18f..103544cceb95 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -434,7 +434,6 @@ class IToplevelProtocol : public IProtocol { virtual void OnChannelClose() = 0; virtual void OnChannelError() = 0; virtual void ProcessingError(Result aError, const char* aMsgName) {} - virtual void OnChannelConnected(int32_t peer_pid) {} bool Open(UniquePtr aTransport, base::ProcessId aOtherPid, MessageLoop* aThread = nullptr,