Bug 1344654 - Label runnables in dom/media/MediaCache.cpp; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Mon, 06 Mar 2017 17:45:41 +0800
changeset 494498 15f59ba562a2a9965d5ce0dfc26753bb7c5dd339
parent 494263 b7e42143bbbc9dc3e5c05bd1e93b6485ce1d0ad4
child 494513 b9599efed740f2e36418d52f8e61b617c094bdc8
child 494891 0fda46a4d80d673ea778ee001edb4564ab6587a7
child 494892 74aaf154584f399f6c4d86aaf20b541619fcd8a5
push id48037
push userbmo:kaku@mozilla.com
push dateTue, 07 Mar 2017 06:24:01 +0000
reviewersjwwang
bugs1344654
milestone55.0a1
Bug 1344654 - Label runnables in dom/media/MediaCache.cpp; r?jwwang MozReview-Commit-ID: LU5rdu3Zx48
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1376,16 +1376,18 @@ MediaCache::Update()
     }
   }
   mSuspendedStatusToNotify.Clear();
 }
 
 class UpdateEvent : public Runnable
 {
 public:
+  UpdateEvent() : Runnable("MediaCache::UpdateEvent") {}
+
   NS_IMETHOD Run() override
   {
     if (gMediaCache) {
       gMediaCache->Update();
     }
     return NS_OK;
   }
 };
@@ -1400,21 +1402,20 @@ MediaCache::QueueUpdate()
   NS_ASSERTION(!mInUpdate,
                "Queuing an update while we're in an update");
   if (mUpdateQueued)
     return;
   mUpdateQueued = true;
   // XXX MediaCache does updates when decoders are still running at
   // shutdown and get freed in the final cycle-collector cleanup.  So
   // don't leak a runnable in that case.
-  nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
-  if (mainThread) {
-    nsCOMPtr<nsIRunnable> event = new UpdateEvent();
-    mainThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
-  }
+  nsCOMPtr<nsIRunnable> event = new UpdateEvent();
+  SystemGroup::Dispatch("MediaCache::UpdateEvent",
+                        TaskCategory::Other,
+                        event.forget());
 }
 
 void
 MediaCache::QueueSuspendedStatusUpdate(int64_t aResourceID)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   if (!mSuspendedStatusToNotify.Contains(aResourceID)) {
     mSuspendedStatusToNotify.AppendElement(aResourceID);