Bug 1588241 - P1. Use move semantics with PrependEvent. r=mattwoodrow
☠☠ backed out by 2f19e7b646e0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 07 Nov 2019 23:25:20 +0000
changeset 501691 17e7f137067f89c0d82cada3af77b1bc5161c547
parent 501690 ef26ae2ee4c22fc88d6590244862066f1974c6ce
child 501692 8d2cf0fc6b9bd03e2a34b6cefc0bd3be36bd06c0
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1588241
milestone72.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 1588241 - P1. Use move semantics with PrependEvent. r=mattwoodrow PrepentEvent was already moving the argument passed by reference. This makes it clear that the object will be moved. Differential Revision: https://phabricator.services.mozilla.com/D52260
netwerk/ipc/ChannelEventQueue.cpp
netwerk/ipc/ChannelEventQueue.h
netwerk/protocol/http/HttpChannelChild.cpp
--- a/netwerk/ipc/ChannelEventQueue.cpp
+++ b/netwerk/ipc/ChannelEventQueue.cpp
@@ -70,17 +70,17 @@ void ChannelEventQueue::FlushQueue() {
       MOZ_DIAGNOSTIC_ASSERT(false);
       isCurrentThread = true;
     }
 
     if (!isCurrentThread) {
       // Next event needs to run on another thread. Put it back to
       // the front of the queue can try resume on that thread.
       Suspend();
-      PrependEvent(event);
+      PrependEvent(std::move(event));
 
       needResumeOnOtherThread = true;
       {
         MutexAutoLock lock(mMutex);
         MOZ_ASSERT(mFlushing);
         mFlushing = false;
         MOZ_ASSERT(!mEventQueue.IsEmpty());
       }
--- a/netwerk/ipc/ChannelEventQueue.h
+++ b/netwerk/ipc/ChannelEventQueue.h
@@ -97,17 +97,17 @@ class ChannelEventQueue final {
   //
   // @param aCallback - the ChannelEvent
   // @param aAssertionWhenNotQueued - this optional param will be used in an
   //   assertion when the event is executed directly.
   inline void RunOrEnqueue(ChannelEvent* aCallback,
                            bool aAssertionWhenNotQueued = false);
 
   // Append ChannelEvent in front of the event queue.
-  inline nsresult PrependEvent(UniquePtr<ChannelEvent>& aEvent);
+  inline nsresult PrependEvent(UniquePtr<ChannelEvent>&& aEvent);
   inline nsresult PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents);
 
   // After StartForcedQueueing is called, RunOrEnqueue() will start enqueuing
   // events that will be run/flushed when EndForcedQueueing is called.
   // - Note: queueing may still be required after EndForcedQueueing() (if the
   //   queue is suspended, etc):  always call RunOrEnqueue() to avoid race
   //   conditions.
   inline void StartForcedQueueing();
@@ -226,17 +226,17 @@ inline void ChannelEventQueue::EndForced
   }
 
   if (tryFlush) {
     MaybeFlushQueue();
   }
 }
 
 inline nsresult ChannelEventQueue::PrependEvent(
-    UniquePtr<ChannelEvent>& aEvent) {
+    UniquePtr<ChannelEvent>&& aEvent) {
   MutexAutoLock lock(mMutex);
 
   // Prepending event while no queue flush foreseen might cause the following
   // channel events not run. This assertion here guarantee there must be a
   // queue flush, either triggered by Resume or EndForcedQueueing, to execute
   // the added event.
   MOZ_ASSERT(mSuspended || !!mForcedCount);
 
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -3772,18 +3772,17 @@ void HttpChannelChild::CancelOnMainThrea
     Cancel(aRv);
     return;
   }
 
   mEventQ->Suspend();
   // Cancel is expected to preempt any other channel events, thus we put this
   // event in the front of mEventQ to make sure nsIStreamListener not receiving
   // any ODA/OnStopRequest callbacks.
-  UniquePtr<ChannelEvent> cancelEvent = MakeUnique<CancelEvent>(this, aRv);
-  mEventQ->PrependEvent(cancelEvent);
+  mEventQ->PrependEvent(MakeUnique<CancelEvent>(this, aRv));
   mEventQ->Resume();
 }
 
 void HttpChannelChild::OverrideWithSynthesizedResponse(
     nsAutoPtr<nsHttpResponseHead>& aResponseHead,
     nsIInputStream* aSynthesizedInput,
     nsIInterceptedBodyCallback* aSynthesizedCallback,
     InterceptStreamListener* aStreamListener,