Bug 1588241 - P1. Use move semantics with PrependEvent. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 15 Nov 2019 02:41:59 +0000
changeset 502102 2a6684436b37e2dff61a160105790e0a44d1c655
parent 502101 46348d491bc2337bb5c46a5dc4e5c674feb49604
child 502103 a00f164555ff94b19f25485908288dcadc563624
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,