Bug 1387314-Remove NS_DispatchToMainThread and use nsIEventTarget to dispatch instead. r?cpearce draft
authorJames Cheng <jacheng@mozilla.com>
Fri, 04 Aug 2017 11:31:15 +0800
changeset 620940 b1ab286a0e36f142edf2b17c35bcba682a7cf2bf
parent 620343 4bf373558d5f167c3346c9fc8539dc1d527ac0c3
child 640849 82d81777ed0892c8ec1f05667a86d6378b1af99c
push id72198
push userbmo:jacheng@mozilla.com
push dateFri, 04 Aug 2017 05:30:47 +0000
reviewerscpearce
bugs1387314
milestone57.0a1
Bug 1387314-Remove NS_DispatchToMainThread and use nsIEventTarget to dispatch instead. r?cpearce MozReview-Commit-ID: EcEQlLLhU5z
dom/media/gmp/GMPServiceParent.cpp
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -56,16 +56,18 @@ namespace mozilla {
 #define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
 #define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
 
 #ifdef __CLASS__
 #undef __CLASS__
 #endif
 #define __CLASS__ "GMPService"
 
+#define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead
+
 namespace gmp {
 
 static const uint32_t NodeIdSaltLength = 32;
 
 already_AddRefed<GeckoMediaPluginServiceParent>
 GeckoMediaPluginServiceParent::GetSingleton()
 {
   MOZ_ASSERT(XRE_IsParentProcess());
@@ -1882,18 +1884,20 @@ GMPServiceParent::ActorDestroy(ActorDest
 
   // Dispatch a task to the current thread to ensure we don't delete the
   // GMPServiceParent until the current calling context is finished with
   // the object.
   GMPServiceParent* self = this;
   NS_DispatchToCurrentThread(
     NS_NewRunnableFunction("gmp::GMPServiceParent::ActorDestroy", [self]() {
       // The GMPServiceParent must be destroyed on the main thread.
-      NS_DispatchToMainThread(NS_NewRunnableFunction(
-        "gmp::GMPServiceParent::ActorDestroy", [self]() { delete self; }));
+      self->mService->mMainThread->Dispatch(
+        NS_NewRunnableFunction(
+          "gmp::GMPServiceParent::ActorDestroy", [self]() { delete self; }),
+        NS_DISPATCH_NORMAL);
     }));
 }
 
 class OpenPGMPServiceParent : public mozilla::Runnable
 {
 public:
   OpenPGMPServiceParent(GMPServiceParent* aGMPServiceParent,
                         ipc::Endpoint<PGMPServiceParent>&& aEndpoint,
@@ -1948,8 +1952,10 @@ GMPServiceParent::Create(Endpoint<PGMPSe
   // ActorDestroy.
   Unused << serviceParent.forget();
 
   return true;
 }
 
 } // namespace gmp
 } // namespace mozilla
+
+#undef NS_DispatchToMainThread
\ No newline at end of file