Skip to content

Commit

Permalink
Bug 1706374 - Part 10: Remove unnecessary IToplevelProtocol::OnChanne…
Browse files Browse the repository at this point in the history
…lConnected, r=handyman,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D116665
  • Loading branch information
mystor committed Jun 22, 2021
1 parent 98a0559 commit b9a55d9
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 57 deletions.
6 changes: 0 additions & 6 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions dom/ipc/ContentParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 8 additions & 4 deletions gfx/vr/ipc/VRManagerParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gfx/vr/ipc/VRManagerParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -74,6 +73,7 @@ class VRManagerParent final : public PVRManagerParent {
mozilla::ipc::IPCResult RecvResetPuppet();

private:
void ActorAlloc() override;
void ActorDealloc() override;
void RegisterWithManager();
void UnregisterFromManager();
Expand Down
24 changes: 0 additions & 24 deletions ipc/glue/MessageChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -773,8 +765,6 @@ void MessageChannel::Clear() {
mLink = nullptr;
}

mOnChannelConnectedTask->Cancel();

if (mChannelErrorTask) {
mChannelErrorTask->Cancel();
mChannelErrorTask = nullptr;
Expand Down Expand Up @@ -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<CancelableRunnable> 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");
Expand Down
12 changes: 0 additions & 12 deletions ipc/glue/MessageChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,6 @@ class MessageChannel : HasResultCodes {

void Clear();

// Send OnChannelConnected notification to listeners.
void DispatchOnChannelConnected();

bool InterruptEventOccurred();
bool HasPendingEvents();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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<CancelableRunnable> 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;
Expand Down
7 changes: 0 additions & 7 deletions ipc/glue/MessageLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion ipc/glue/ProtocolUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transport> aTransport, base::ProcessId aOtherPid,
MessageLoop* aThread = nullptr,
Expand Down

0 comments on commit b9a55d9

Please sign in to comment.