Bug 1345314. P1 - move DeleteOnMainThread() to WMFVideoMFTManager.cpp to discourage the use of nsAutoPtr. r?jya
MozReview-Commit-ID: LxIQcdZtVx7
--- 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;
}