Bug 1411803 - ensure MediaCache is deleted on the main thread. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 24 Oct 2017 10:32:47 +0800
changeset 687257 3d1138d52be195ad8037b71fa6978448637b3618
parent 687250 fc4e976431be6f65f78ffd9d78815935eac499ef
child 687258 285216febaf01caf7550009f8a91b95d5be6cd36
push id86463
push userjwwang@mozilla.com
push dateFri, 27 Oct 2017 03:14:09 +0000
bugs1411803
milestone58.0a1
Bug 1411803 - ensure MediaCache is deleted on the main thread. MozReview-Commit-ID: 4JzTyyPF1uT
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -21,16 +21,17 @@
 #include "mozilla/StaticPtr.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/Telemetry.h"
 #include "nsContentUtils.h"
 #include "nsIObserverService.h"
 #include "nsIPrincipal.h"
 #include "nsISeekableStream.h"
 #include "nsPrintfCString.h"
+#include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "prio.h"
 #include <algorithm>
 
 namespace mozilla {
 
 #undef LOG
 #undef LOGI
@@ -1533,16 +1534,20 @@ public:
     : Runnable("MediaCache::UpdateEvent")
     , mMediaCache(aMediaCache)
   {
   }
 
   NS_IMETHOD Run() override
   {
     mMediaCache->Update();
+    // Ensure MediaCache is deleted on the main thread.
+    NS_ProxyRelease("UpdateEvent::mMediaCache",
+                    SystemGroup::EventTargetFor(mozilla::TaskCategory::Other),
+                    mMediaCache.forget());
     return NS_OK;
   }
 
 private:
   RefPtr<MediaCache> mMediaCache;
 };
 
 void