Bug 1312960 - MessageChannel compiler fixes on a CLOSED TREE
☠☠ backed out by c4f2be33044f ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Fri, 28 Oct 2016 20:46:51 -0700
changeset 320127 a171aae3ae491dd52e184735c51924c7a467a0bf
parent 320126 b15d4e773bdd7005280e572a02112f838e5230a9
child 320128 c4f2be33044f293bba6518622bbf4043b48e57bb
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1312960
milestone52.0a1
Bug 1312960 - MessageChannel compiler fixes on a CLOSED TREE
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -933,16 +933,20 @@ MessageChannel::OnMessageReceivedFromLin
                                IPC::Message::COMPRESSION_ENABLED);
             mPending.popLast();
         }
     } else if (aMsg.compress_type() == IPC::Message::COMPRESSION_ALL && !mPending.isEmpty()) {
         for (RefPtr<MessageTask> p = mPending.getLast(); p; p = p->getPrevious()) {
             if (p->Msg().type() == aMsg.type() &&
                 p->Msg().routing_id() == aMsg.routing_id())
             {
+                // This message type has compression enabled, and the queue
+                // holds a message with the same message type and routed to the
+                // same destination. Erase it. Note that, since we always
+                // compress these redundancies, There Can Be Only One.
                 compress = true;
                 MOZ_RELEASE_ASSERT(p->Msg().compress_type() == IPC::Message::COMPRESSION_ALL);
                 p->remove();
                 break;
             }
         }
     }
 
@@ -1533,17 +1537,17 @@ void
 MessageChannel::RunMessage(MessageTask& aTask)
 {
     AssertWorkerThread();
     mMonitor->AssertCurrentThreadOwns();
 
     Message& msg = aTask.Msg();
 
     if (!Connected()) {
-        ReportConnectionError("OnMaybeDequeueOne");
+        ReportConnectionError("RunMessage");
         return;
     }
 
     // Check that we're going to run the first message that's valid to run.
 #ifdef DEBUG
     for (RefPtr<MessageTask> task : mPending) {
         if (task == &aTask) {
             break;
@@ -1592,16 +1596,17 @@ MessageChannel::MessageTask::Run()
     if (!isInList()) {
         return NS_OK;
     }
 
     mChannel->RunMessage(*this);
     return NS_OK;
 }
 
+// Warning: This method removes the receiver from whatever list it might be in.
 nsresult
 MessageChannel::MessageTask::Cancel()
 {
     if (!mChannel) {
         return NS_OK;
     }
 
     mChannel->AssertWorkerThread();
@@ -1618,19 +1623,20 @@ MessageChannel::MessageTask::Cancel()
 }
 
 void
 MessageChannel::MessageTask::Post()
 {
     MOZ_RELEASE_ASSERT(!mScheduled);
     MOZ_RELEASE_ASSERT(isInList());
 
+    mScheduled = true;
+
     RefPtr<MessageTask> self = this;
     mChannel->mWorkerLoop->PostTask(self.forget());
-    mScheduled = true;
 }
 
 void
 MessageChannel::MessageTask::Clear()
 {
     mChannel->AssertWorkerThread();
 
     mChannel = nullptr;
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -457,17 +457,17 @@ class MessageChannel : HasResultCodes
         public LinkedListElement<RefPtr<MessageTask>>
     {
     public:
         explicit MessageTask(MessageChannel* aChannel, Message&& aMessage)
           : mChannel(aChannel), mMessage(Move(aMessage)), mScheduled(false)
         {}
 
         NS_IMETHOD Run() override;
-        NS_IMETHOD Cancel() override;
+        nsresult Cancel() override;
         void Post();
         void Clear();
 
         bool IsScheduled() const { return mScheduled; }
 
         Message& Msg() { return mMessage; }
         const Message& Msg() const { return mMessage; }