Bug 1344621 - Label runnables in dom/media/MediaResource.cpp; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Mon, 06 Mar 2017 15:30:49 +0800
changeset 493870 57db27003cae030d545e6c81d3e23969d799b85d
parent 493721 8d026c60151005ad942e3d4389318fe28a0c8c54
child 493890 1298cedcf057e5a536229f4937f30f32116c11d7
push id47872
push userbmo:kaku@mozilla.com
push dateMon, 06 Mar 2017 07:51:28 +0000
reviewersjwwang
bugs1344621
milestone54.0a1
Bug 1344621 - Label runnables in dom/media/MediaResource.cpp; r?jwwang MozReview-Commit-ID: EEZoUIdKOkK
dom/media/MediaResource.cpp
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -49,18 +49,21 @@ namespace mozilla {
 void
 MediaResource::Destroy()
 {
   // Ensures we only delete the MediaResource on the main thread.
   if (NS_IsMainThread()) {
     delete this;
     return;
   }
-  MOZ_ALWAYS_SUCCEEDS(
-    NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &MediaResource::Destroy)));
+  nsresult rv =
+    SystemGroup::Dispatch("MediaResource::Destroy",
+                          TaskCategory::Other,
+                          NewNonOwningRunnableMethod(this, &MediaResource::Destroy));
+  MOZ_ALWAYS_SUCCEEDS(rv);
 }
 
 NS_IMPL_ADDREF(MediaResource)
 NS_IMPL_RELEASE_WITH_DESTROY(MediaResource, Destroy())
 NS_IMPL_QUERY_INTERFACE0(MediaResource)
 
 ChannelMediaResource::ChannelMediaResource(MediaResourceCallback* aCallback,
                                            nsIChannel* aChannel,
@@ -861,17 +864,20 @@ ChannelMediaResource::CacheClientNotifyD
   // block or do anything which might try to acquire a lock!
 
   if (mDataReceivedEvent.IsPending())
     return;
 
   mDataReceivedEvent =
     NewNonOwningRunnableMethod("ChannelMediaResource::DoNotifyDataReceived",
                                this, &ChannelMediaResource::DoNotifyDataReceived);
-  NS_DispatchToMainThread(mDataReceivedEvent.get());
+
+  nsCOMPtr<nsIRunnable> event = mDataReceivedEvent.get();
+
+  SystemGroup::AbstractMainThreadFor(TaskCategory::Other)->Dispatch(event.forget());
 }
 
 void
 ChannelMediaResource::CacheClientNotifyDataEnded(nsresult aStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
   mCallback->NotifyDataEnded(aStatus);
 }