Bug 1190495 - Switch TaskQueue entirely to nsRefPtr. r=cpearce
authorBobby Holley <bobbyholley@gmail.com>
Fri, 07 Aug 2015 17:01:55 -0700
changeset 277165 030f756097026386cce95b67b6110f51985b2ef1
parent 277164 9f162f396c26b23cf09b88ccdbc2a21bc5ae0200
child 277166 f78347b683ee4be6d28adb49b94ea1335750e87d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-esr52@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1190495
milestone43.0a1
Bug 1190495 - Switch TaskQueue entirely to nsRefPtr. r=cpearce
dom/media/TaskQueue.cpp
dom/media/TaskQueue.h
--- a/dom/media/TaskQueue.cpp
+++ b/dom/media/TaskQueue.cpp
@@ -57,17 +57,17 @@ TaskQueue::DispatchLocked(already_AddRef
   }
   if (mIsShutdown) {
     return NS_ERROR_FAILURE;
   }
   mTasks.push(r.forget());
   if (mIsRunning) {
     return NS_OK;
   }
-  RefPtr<nsIRunnable> runner(new Runner(this));
+  nsRefPtr<nsIRunnable> runner(new Runner(this));
   nsresult rv = mPool->Dispatch(runner, NS_DISPATCH_NORMAL);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch runnable to run TaskQueue");
     return rv;
   }
   mIsRunning = true;
 
   return NS_OK;
@@ -140,17 +140,17 @@ TaskQueue::IsCurrentThreadIn()
   bool in = NS_GetCurrentThread() == mRunningThread;
   MOZ_ASSERT(in == (GetCurrent() == this));
   return in;
 }
 
 nsresult
 TaskQueue::Runner::Run()
 {
-  RefPtr<nsIRunnable> event;
+  nsRefPtr<nsIRunnable> event;
   {
     MonitorAutoLock mon(mQueue->mQueueMonitor);
     MOZ_ASSERT(mQueue->mIsRunning);
     if (mQueue->mTasks.size() == 0) {
       mQueue->mIsRunning = false;
       mQueue->MaybeResolveShutdown();
       mon.NotifyAll();
       return NS_OK;
--- a/dom/media/TaskQueue.h
+++ b/dom/media/TaskQueue.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TaskQueue_h_
 #define TaskQueue_h_
 
 #include "mozilla/Monitor.h"
 #include "mozilla/MozPromise.h"
-#include "mozilla/RefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/TaskDispatcher.h"
 #include "mozilla/unused.h"
 
 #include <queue>
 
 #include "mozilla/SharedThreadPool.h"
 #include "nsThreadUtils.h"
 
@@ -89,17 +89,17 @@ protected:
   {
     mQueueMonitor.AssertCurrentThreadOwns();
     if (mIsShutdown && !mIsRunning) {
       mShutdownPromise.ResolveIfExists(true, __func__);
       mPool = nullptr;
     }
   }
 
-  RefPtr<SharedThreadPool> mPool;
+  nsRefPtr<SharedThreadPool> mPool;
 
   // Monitor that protects the queue and mIsRunning;
   Monitor mQueueMonitor;
 
   // Queue of tasks to run.
   std::queue<nsCOMPtr<nsIRunnable>> mTasks;
 
   // The thread currently running the task queue. We store a reference
@@ -162,15 +162,15 @@ protected:
   class Runner : public nsRunnable {
   public:
     explicit Runner(TaskQueue* aQueue)
       : mQueue(aQueue)
     {
     }
     NS_METHOD Run() override;
   private:
-    RefPtr<TaskQueue> mQueue;
+    nsRefPtr<TaskQueue> mQueue;
   };
 };
 
 } // namespace mozilla
 
 #endif // TaskQueue_h_