Bug 1343796 - Label runnables in TextTrack.cpp. r=jwwang
authorbechen <bechen@mozilla.com>
Wed, 15 Mar 2017 11:58:50 +0800
changeset 348103 88f569da02fc403e4859abc40b7710fc99d5cb33
parent 348102 fb2f75b195e8800376b008ca860401e4c5aabf68
child 348104 fc2516eb942385a7c65549123b416e7e1d4d9b6f
push id88164
push usercbook@mozilla.com
push dateFri, 17 Mar 2017 13:55:35 +0000
treeherdermozilla-inbound@e46c08babe02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1343796
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343796 - Label runnables in TextTrack.cpp. r=jwwang MozReview-Commit-ID: GvqwG181R4i
dom/media/TextTrack.cpp
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -8,16 +8,17 @@
 #include "mozilla/dom/TextTrack.h"
 #include "mozilla/dom/TextTrackBinding.h"
 #include "mozilla/dom/TextTrackList.h"
 #include "mozilla/dom/TextTrackCue.h"
 #include "mozilla/dom/TextTrackCueList.h"
 #include "mozilla/dom/TextTrackRegion.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/dom/HTMLTrackElement.h"
+#include "nsGlobalWindow.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(TextTrack,
                                    DOMEventTargetHelper,
                                    mCueList,
                                    mActiveCueList,
@@ -325,18 +326,23 @@ TextTrack::GetLanguage(nsAString& aLangu
   } else {
     aLanguage = mLanguage;
   }
 }
 
 void
 TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName)
 {
+  nsPIDOMWindowInner* win = GetOwner();
+  if (!win) {
+    return;
+  }
   RefPtr<TextTrack> self = this;
-  NS_DispatchToMainThread(
+  nsGlobalWindow::Cast(win)->Dispatch(
+    "TextTrack::DispatchAsyncTrustedEvent", TaskCategory::Other,
     NS_NewRunnableFunction([self, aEventName]() {
       self->DispatchTrustedEvent(aEventName);
     })
   );
 }
 
 bool
 TextTrack::IsLoaded()