Bug 1312960 - Use CancelableRunnable for mOnChannelConnectedTask (r=dvander)
authorBill McCloskey <billm@mozilla.com>
Sat, 15 Oct 2016 11:54:56 -0700
changeset 320262 f1d9568cc12f
parent 320261 b30dfbf5fe2a
child 320263 13826b3d90c7
push id20754
push usercbook@mozilla.com
push date2016-10-31 15:58 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1312960
milestone52.0a1
Bug 1312960 - Use CancelableRunnable for mOnChannelConnectedTask (r=dvander)
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -507,18 +507,18 @@ MessageChannel::MessageChannel(MessageLi
     mTopFrame = nullptr;
     mIsSyncWaitingOnNonMainThread = false;
 #endif
 
     RefPtr<CancelableRunnable> runnable =
         NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne);
     mDequeueOneTask = new RefCountedTask(runnable.forget());
 
-    runnable = NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected);
-    mOnChannelConnectedTask = new RefCountedTask(runnable.forget());
+    mOnChannelConnectedTask =
+        NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected);
 
 #ifdef OS_WIN
     mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
     MOZ_RELEASE_ASSERT(mEvent, "CreateEvent failed! Nothing is going to work!");
 #endif
 }
 
 MessageChannel::~MessageChannel()
@@ -1938,17 +1938,17 @@ MessageChannel::SetReplyTimeoutMs(int32_
 }
 
 void
 MessageChannel::OnChannelConnected(int32_t peer_id)
 {
     MOZ_RELEASE_ASSERT(!mPeerPidSet);
     mPeerPidSet = true;
     mPeerPid = peer_id;
-    RefPtr<DequeueTask> task = new DequeueTask(mOnChannelConnectedTask);
+    RefPtr<CancelableRunnable> task = mOnChannelConnectedTask;
     mWorkerLoop->PostTask(task.forget());
 }
 
 void
 MessageChannel::DispatchOnChannelConnected()
 {
     AssertWorkerThread();
     MOZ_RELEASE_ASSERT(mPeerPidSet);
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -783,17 +783,17 @@ class MessageChannel : HasResultCodes
     bool mNotifiedChannelDone;
 
     // 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<RefCountedTask> mOnChannelConnectedTask;
+    RefPtr<CancelableRunnable> mOnChannelConnectedTask;
     bool mPeerPidSet;
     int32_t mPeerPid;
 };
 
 void
 CancelCPOWs();
 
 } // namespace ipc