Bug 1595657 - Add MediaQueue::Push that takes an already_AddRefed. r=jya
authorMichael Froman <mfroman@mozilla.com>
Tue, 12 Nov 2019 10:58:39 +0000
changeset 501745 149d044837d69f645972cc10319baee944cd121b
parent 501744 70738ac7ba9b76a586cedc22ca11e02ebf659f16
child 501746 ffc59a6dfbd58dcc28114acc38a7ef29f55d0aab
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)
reviewersjya
bugs1595657
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 1595657 - Add MediaQueue::Push that takes an already_AddRefed. r=jya Differential Revision: https://phabricator.services.mozilla.com/D52622
dom/media/MediaQueue.h
--- a/dom/media/MediaQueue.h
+++ b/dom/media/MediaQueue.h
@@ -36,22 +36,27 @@ class MediaQueue : private nsDeque {
   ~MediaQueue() { Reset(); }
 
   inline size_t GetSize() const {
     RecursiveMutexAutoLock lock(mRecursiveMutex);
     return nsDeque::GetSize();
   }
 
   inline void Push(T* aItem) {
+    MOZ_DIAGNOSTIC_ASSERT(aItem);
+    Push(do_AddRef(aItem));
+  }
+
+  inline void Push(already_AddRefed<T> aItem) {
     RecursiveMutexAutoLock lock(mRecursiveMutex);
-    MOZ_DIAGNOSTIC_ASSERT(aItem);
-    NS_ADDREF(aItem);
-    MOZ_ASSERT(aItem->GetEndTime() >= aItem->mTime);
-    nsDeque::Push(aItem);
-    mPushEvent.Notify(RefPtr<T>(aItem));
+    T* item = aItem.take();
+    MOZ_DIAGNOSTIC_ASSERT(item);
+    MOZ_ASSERT(item->GetEndTime() >= item->mTime);
+    nsDeque::Push(item);
+    mPushEvent.Notify(RefPtr<T>(item));
     // Pushing new data after queue has ended means that the stream is active
     // again, so we should not mark it as ended.
     if (mEndOfStream) {
       mEndOfStream = false;
     }
   }
 
   inline already_AddRefed<T> PopFront() {