Bug 1642619 - Remove the unused MessageChannel::Echo(). r=froydnj
authorAndrew McCreight <continuation@gmail.com>
Tue, 02 Jun 2020 13:56:07 +0000
changeset 597603 c6362d5d6dcb832d43adcfcc5566ec0d3c664e6d
parent 597602 c3799309b95c400ddfdb1f24f630d4c5dcba6fc6
child 597604 0faec7424b01d7446bfda7a6b1cf93a6b31ecf3d
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1642619
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1642619 - Remove the unused MessageChannel::Echo(). r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D77804
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
ipc/glue/MessageLink.cpp
ipc/glue/MessageLink.h
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -936,36 +936,16 @@ bool MessageChannel::OpenOnSameThread(Me
   aTargetChan->mIsSameThreadChannel = true;
   aTargetChan->mMonitor = mMonitor;
 
   mChannelState = ChannelConnected;
   aTargetChan->mChannelState = ChannelConnected;
   return true;
 }
 
-bool MessageChannel::Echo(Message* aMsg) {
-  UniquePtr<Message> msg(aMsg);
-  AssertWorkerThread();
-  mMonitor->AssertNotCurrentThreadOwns();
-  if (MSG_ROUTING_NONE == msg->routing_id()) {
-    ReportMessageRouteError("MessageChannel::Echo");
-    return false;
-  }
-
-  MonitorAutoLock lock(*mMonitor);
-
-  if (!Connected()) {
-    ReportConnectionError("MessageChannel", msg.get());
-    return false;
-  }
-
-  mLink->EchoMessage(msg.release());
-  return true;
-}
-
 bool MessageChannel::Send(Message* aMsg) {
   if (aMsg->size() >= kMinTelemetryMessageSize) {
     Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE2, aMsg->size());
   }
 
   // If the message was created by the IPC bindings, the create time will be
   // recorded. Use this information to report the
   // IPC_WRITE_MAIN_THREAD_LATENCY_MS (time from message creation to it being
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -237,20 +237,16 @@ class MessageChannel : HasResultCodes, M
                                           std::move(aReject));
     mPendingResponses.insert(std::make_pair(seqno, std::move(callback)));
     gUnresolvedResponses++;
   }
 
   bool SendBuildIDsMatchMessage(const char* aParentBuildI);
   bool DoBuildIDsMatch() { return mBuildIDsConfirmedMatch; }
 
-  // Asynchronously deliver a message back to this side of the
-  // channel
-  bool Echo(Message* aMsg);
-
   // Synchronously send |msg| (i.e., wait for |reply|)
   bool Send(Message* aMsg, Message* aReply);
 
   // Make an Interrupt call to the other side of the channel
   bool Call(Message* aMsg, Message* aReply);
 
   // Wait until a message is received
   bool WaitForIncomingMessage();
--- a/ipc/glue/MessageLink.cpp
+++ b/ipc/glue/MessageLink.cpp
@@ -127,26 +127,16 @@ void ProcessLink::Open(UniquePtr<Transpo
     // changing back to Closed: only the worker thread changes it to closed,
     // and we're on the worker thread, blocked.
     while (mChan->mChannelState == ChannelClosed) {
       mChan->mMonitor->Wait();
     }
   }
 }
 
-void ProcessLink::EchoMessage(Message* msg) {
-  mChan->AssertWorkerThread();
-  mChan->mMonitor->AssertCurrentThreadOwns();
-
-  mIOLoop->PostTask(NewNonOwningRunnableMethod<Message*>(
-      "ipc::ProcessLink::OnEchoMessage", this, &ProcessLink::OnEchoMessage,
-      msg));
-  // OnEchoMessage takes ownership of |msg|
-}
-
 void ProcessLink::SendMessage(Message* msg) {
   if (msg->size() > IPC::Channel::kMaximumMessageSize) {
     CrashReporter::AnnotateCrashReport(
         CrashReporter::Annotation::IPCMessageName,
         nsDependentCString(msg->name()));
     CrashReporter::AnnotateCrashReport(
         CrashReporter::Annotation::IPCMessageSize,
         static_cast<unsigned int>(msg->size()));
@@ -198,24 +188,16 @@ ThreadLink::~ThreadLink() {
   // also protects against the two ~ThreadLink() calls racing.
   if (mTargetChan) {
     MOZ_ASSERT(mTargetChan->mLink);
     static_cast<ThreadLink*>(mTargetChan->mLink)->mTargetChan = nullptr;
   }
   mTargetChan = nullptr;
 }
 
-void ThreadLink::EchoMessage(Message* msg) {
-  mChan->AssertWorkerThread();
-  mChan->mMonitor->AssertCurrentThreadOwns();
-
-  mChan->OnMessageReceivedFromLink(std::move(*msg));
-  delete msg;
-}
-
 void ThreadLink::SendMessage(Message* msg) {
   if (!mChan->mIsPostponingSends) {
     mChan->AssertWorkerThread();
   }
   mChan->mMonitor->AssertCurrentThreadOwns();
 
   if (mTargetChan) mTargetChan->OnMessageReceivedFromLink(std::move(*msg));
   delete msg;
@@ -251,22 +233,16 @@ uint32_t ThreadLink::Unsound_NumQueuedMe
 
 void ProcessLink::OnMessageReceived(Message&& msg) {
   AssertIOThread();
   NS_ASSERTION(mChan->mChannelState != ChannelError, "Shouldn't get here!");
   MonitorAutoLock lock(*mChan->mMonitor);
   mChan->OnMessageReceivedFromLink(std::move(msg));
 }
 
-void ProcessLink::OnEchoMessage(Message* msg) {
-  AssertIOThread();
-  OnMessageReceived(std::move(*msg));
-  delete msg;
-}
-
 void ProcessLink::OnChannelOpened() {
   AssertIOThread();
 
   {
     MonitorAutoLock lock(*mChan->mMonitor);
 
     mExistingListener = mTransport->set_listener(this);
 #ifdef DEBUG
--- a/ipc/glue/MessageLink.h
+++ b/ipc/glue/MessageLink.h
@@ -39,32 +39,30 @@ class MessageLink {
  public:
   typedef IPC::Message Message;
 
   explicit MessageLink(MessageChannel* aChan);
   virtual ~MessageLink();
 
   // n.b.: These methods all require that the channel monitor is
   // held when they are invoked.
-  virtual void EchoMessage(Message* msg) = 0;
   virtual void SendMessage(Message* msg) = 0;
   virtual void SendClose() = 0;
 
   virtual bool Unsound_IsClosed() const = 0;
   virtual uint32_t Unsound_NumQueuedMessages() const = 0;
 
  protected:
   MessageChannel* mChan;
 };
 
 class ProcessLink : public MessageLink, public Transport::Listener {
   void OnCloseChannel();
   void OnChannelOpened();
   void OnTakeConnectedChannel();
-  void OnEchoMessage(Message* msg);
 
   void AssertIOThread() const {
     MOZ_ASSERT(mIOLoop == MessageLoop::current(), "not on I/O thread!");
   }
 
  public:
   explicit ProcessLink(MessageChannel* chan);
   virtual ~ProcessLink();
@@ -81,17 +79,16 @@ class ProcessLink : public MessageLink, 
   // Run on the I/O thread, only when using inter-process link.
   // These methods acquire the monitor and forward to the
   // similarly named methods in AsyncChannel below
   // (OnMessageReceivedFromLink(), etc)
   virtual void OnMessageReceived(Message&& msg) override;
   virtual void OnChannelConnected(int32_t peer_pid) override;
   virtual void OnChannelError() override;
 
-  virtual void EchoMessage(Message* msg) override;
   virtual void SendMessage(Message* msg) override;
   virtual void SendClose() override;
 
   virtual bool Unsound_IsClosed() const override;
   virtual uint32_t Unsound_NumQueuedMessages() const override;
 
  protected:
   void OnChannelConnectError();
@@ -102,17 +99,16 @@ class ProcessLink : public MessageLink, 
   Transport::Listener* mExistingListener;  // channel's previous listener
 };
 
 class ThreadLink : public MessageLink {
  public:
   ThreadLink(MessageChannel* aChan, MessageChannel* aTargetChan);
   virtual ~ThreadLink();
 
-  virtual void EchoMessage(Message* msg) override;
   virtual void SendMessage(Message* msg) override;
   virtual void SendClose() override;
 
   virtual bool Unsound_IsClosed() const override;
   virtual uint32_t Unsound_NumQueuedMessages() const override;
 
  protected:
   MessageChannel* mTargetChan;