Bug 1345314. P1 - move DeleteOnMainThread() to WMFVideoMFTManager.cpp to discourage the use of nsAutoPtr. r?jya draft
authorJW Wang <jwwang@mozilla.com>
Tue, 07 Mar 2017 15:19:29 +0800
changeset 495599 439b388977acd56914277196c373bb781bbed7d5
parent 495598 6448f8ff1c03c631f5d8ac6ca8f85cc887193275
child 495600 50ba073fc8190106556abbb1ce209a7dfdff0dbd
push id48382
push userjwwang@mozilla.com
push dateThu, 09 Mar 2017 02:49:45 +0000
reviewersjya
bugs1345314
milestone55.0a1
Bug 1345314. P1 - move DeleteOnMainThread() to WMFVideoMFTManager.cpp to discourage the use of nsAutoPtr. r?jya MozReview-Commit-ID: LxIQcdZtVx7
dom/media/VideoUtils.h
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -96,39 +96,16 @@ public:
     mThread->Shutdown();
     mThread = nullptr;
     return NS_OK;
   }
 private:
   nsCOMPtr<nsIThread> mThread;
 };
 
-template<class T>
-class DeleteObjectTask: public Runnable {
-public:
-  explicit DeleteObjectTask(nsAutoPtr<T>& aObject)
-    : Runnable("VideoUtils::DeleteObjectTask")
-    , mObject(aObject)
-  {
-  }
-  NS_IMETHOD Run() override {
-    NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
-    mObject = nullptr;
-    return NS_OK;
-  }
-private:
-  nsAutoPtr<T> mObject;
-};
-
-template<class T>
-void DeleteOnMainThread(nsAutoPtr<T>& aObject) {
-  nsCOMPtr<nsIRunnable> r = new DeleteObjectTask<T>(aObject);
-  SystemGroup::Dispatch("VideoUtils::DeleteObjectTask", TaskCategory::Other, r.forget());
-}
-
 class MediaResource;
 
 // Estimates the buffered ranges of a MediaResource using a simple
 // (byteOffset/length)*duration method. Probably inaccurate, but won't
 // do file I/O, and can be used when we don't have detailed knowledge
 // of the byte->time mapping of a resource. aDurationUsecs is the duration
 // of the media in microseconds. Estimated buffered ranges are stored in
 // aOutBuffered. Ranges are 0-normalized, i.e. in the range of (0,duration].
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -66,16 +66,39 @@ const CLSID CLSID_WebmMfVpxDec =
   0xe3aaf548,
   0xc9a4,
   0x4c6e,
   { 0x23, 0x4d, 0x5a, 0xda, 0x37, 0x4b, 0x00, 0x00 }
 };
 
 namespace mozilla {
 
+template<class T>
+class DeleteObjectTask: public Runnable {
+public:
+  explicit DeleteObjectTask(nsAutoPtr<T>& aObject)
+    : Runnable("VideoUtils::DeleteObjectTask")
+    , mObject(aObject)
+  {
+  }
+  NS_IMETHOD Run() override {
+    NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
+    mObject = nullptr;
+    return NS_OK;
+  }
+private:
+  nsAutoPtr<T> mObject;
+};
+
+template<class T>
+void DeleteOnMainThread(nsAutoPtr<T>& aObject) {
+  nsCOMPtr<nsIRunnable> r = new DeleteObjectTask<T>(aObject);
+  SystemGroup::Dispatch("VideoUtils::DeleteObjectTask", TaskCategory::Other, r.forget());
+}
+
 LayersBackend
 GetCompositorBackendType(layers::KnowsCompositor* aKnowsCompositor)
 {
   if (aKnowsCompositor) {
     return aKnowsCompositor->GetCompositorBackendType();
   }
   return LayersBackend::LAYERS_NONE;
 }