Bug 1458383 - Don't dispatch mediaBlockStop notification. r=baku draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 09 May 2018 16:22:40 +1200
changeset 795042 37ca839bdf9f323b11e010df643c31f895c602f5
parent 795041 3b169c324b4a0c5163151805d9fcdb0b90a37517
child 795043 deb240bda1980bcefbfc63f9ec0b00693c5777d2
child 795083 c961015cc7decd6ea03722869610e139a263f2bf
push id109848
push userbmo:cpearce@mozilla.com
push dateMon, 14 May 2018 22:46:33 +0000
reviewersbaku
bugs1458383, 1347791
milestone62.0a1
Bug 1458383 - Don't dispatch mediaBlockStop notification. r=baku This is a partial backout of Bug 1347791 part 3; a5fbb7e2d1d0. We don't need to track in the front end code when a tab is foregrounded, so we don't need to dispatch this message any more. MozReview-Commit-ID: 6M0n9Ik65vE
dom/audiochannel/AudioChannelService.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -786,35 +786,19 @@ AudioChannelService::AudioChannelWindow:
   AudioAudibleChanged(aAgent,
                       AudibleState::eNotAudible,
                       AudibleChangedReasons::ePauseStateChanged);
 }
 
 void
 AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop(nsPIDOMWindowOuter* aWindow)
 {
-  // Can't use raw pointer for lamba variable capturing, use smart ptr.
-  nsCOMPtr<nsPIDOMWindowOuter> window = aWindow;
-  NS_DispatchToCurrentThread(NS_NewRunnableFunction(
-    "dom::AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop",
-    [window]() -> void {
-      nsCOMPtr<nsIObserverService> observerService =
-        services::GetObserverService();
-      if (NS_WARN_IF(!observerService)) {
-        return;
-      }
-
-      observerService->NotifyObservers(ToSupports(window),
-                                       "audio-playback",
-                                       u"mediaBlockStop");
-    })
-  );
-
   if (mShouldSendActiveMediaBlockStopEvent) {
     mShouldSendActiveMediaBlockStopEvent = false;
+    nsCOMPtr<nsPIDOMWindowOuter> window = aWindow;
     NS_DispatchToCurrentThread(NS_NewRunnableFunction(
       "dom::AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop",
       [window]() -> void {
         nsCOMPtr<nsIObserverService> observerService =
           services::GetObserverService();
         if (NS_WARN_IF(!observerService)) {
           return;
         }