Backed out changeset d19f076a7451 (bug 923247)
authorEd Morley <emorley@mozilla.com>
Mon, 10 Mar 2014 17:04:01 +0000
changeset 191053 0e567df520fd5bc7f1ba8a07c7a010d00423f33b
parent 191052 c3ffbb04a71e71be5b246d160d537b60c00beeb2
child 191054 5a49b82e21ee4c786dab0a0f9f5e250d36de5584
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs923247
milestone30.0a1
backs outd19f076a7451d050c0c21c0673a3ff31478d9b6c
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
Backed out changeset d19f076a7451 (bug 923247)
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/base/test/audio.ogg
dom/base/test/mochitest.ini
dom/base/test/test_audioNotification.html
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -107,28 +107,16 @@ AudioChannelService::RegisterAudioChanne
   MOZ_ASSERT(aType != AUDIO_CHANNEL_DEFAULT);
 
   AudioChannelAgentData* data = new AudioChannelAgentData(aType,
                                 true /* aElementHidden */,
                                 AUDIO_CHANNEL_STATE_MUTED /* aState */,
                                 aWithVideo);
   mAgents.Put(aAgent, data);
   RegisterType(aType, CONTENT_PROCESS_ID_MAIN, aWithVideo);
-
-  // If this is the first agent for this window, we must notify the observers.
-  uint32_t count = CountWindow(aAgent->Window());
-  if (count == 1) {
-    nsCOMPtr<nsIObserverService> observerService =
-      services::GetObserverService();
-    if (observerService) {
-      observerService->NotifyObservers(ToSupports(aAgent->Window()),
-                                       "media-playback",
-                                       NS_LITERAL_STRING("active").get());
-    }
-  }
 }
 
 void
 AudioChannelService::RegisterType(AudioChannelType aType, uint64_t aChildID, bool aWithVideo)
 {
   if (mDisabled) {
     return;
   }
@@ -187,28 +175,16 @@ AudioChannelService::UnregisterAudioChan
                    CONTENT_PROCESS_ID_MAIN, data->mWithVideo);
   }
 #ifdef MOZ_WIDGET_GONK
   bool active = AnyAudioChannelIsActive();
   for (uint32_t i = 0; i < mSpeakerManager.Length(); i++) {
     mSpeakerManager[i]->SetAudioChannelActive(active);
   }
 #endif
-
-  // If this is the last agent for this window, we must notify the observers.
-  uint32_t count = CountWindow(aAgent->Window());
-  if (count == 0) {
-    nsCOMPtr<nsIObserverService> observerService =
-      services::GetObserverService();
-    if (observerService) {
-      observerService->NotifyObservers(ToSupports(aAgent->Window()),
-                                       "media-playback",
-                                       NS_LITERAL_STRING("inactive").get());
-    }
-  }
 }
 
 void
 AudioChannelService::UnregisterType(AudioChannelType aType,
                                     bool aElementHidden,
                                     uint64_t aChildID,
                                     bool aWithVideo)
 {
@@ -840,42 +816,8 @@ AudioChannelService::RefreshAgentsVolume
 {
   RefreshAgentsVolumeData data(aWindow);
   mAgents.EnumerateRead(RefreshAgentsVolumeEnumerator, &data);
 
   for (uint32_t i = 0; i < data.mAgents.Length(); ++i) {
     data.mAgents[i]->WindowVolumeChanged();
   }
 }
-
-struct CountWindowData
-{
-  CountWindowData(nsIDOMWindow* aWindow)
-    : mWindow(aWindow)
-    , mCount(0)
-  {}
-
-  nsIDOMWindow* mWindow;
-  uint32_t mCount;
-};
-
-PLDHashOperator
-AudioChannelService::CountWindowEnumerator(AudioChannelAgent* aAgent,
-                                           AudioChannelAgentData* aUnused,
-                                           void* aPtr)
-{
-  CountWindowData* data = static_cast<CountWindowData*>(aPtr);
-  MOZ_ASSERT(aAgent);
-
-  if (aAgent->Window() == data->mWindow) {
-    ++data->mCount;
-  }
-
-  return PL_DHASH_NEXT;
-}
-
-uint32_t
-AudioChannelService::CountWindow(nsIDOMWindow* aWindow)
-{
-  CountWindowData data(aWindow);
-  mAgents.EnumerateRead(CountWindowEnumerator, &data);
-  return data.mCount;
-}
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -183,23 +183,16 @@ protected:
   NotifyEnumerator(AudioChannelAgent* aAgent,
                    AudioChannelAgentData* aData, void *aUnused);
 
   static PLDHashOperator
   RefreshAgentsVolumeEnumerator(AudioChannelAgent* aAgent,
                                 AudioChannelAgentData* aUnused,
                                 void *aPtr);
 
-  static PLDHashOperator
-  CountWindowEnumerator(AudioChannelAgent* aAgent,
-                        AudioChannelAgentData* aUnused,
-                        void *aPtr);
-
-  uint32_t CountWindow(nsIDOMWindow* aWindow);
-
   nsClassHashtable< nsPtrHashKey<AudioChannelAgent>, AudioChannelAgentData > mAgents;
 #ifdef MOZ_WIDGET_GONK
   nsTArray<SpeakerManagerService*>  mSpeakerManager;
 #endif
   nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
 
   AudioChannelType mCurrentHigherChannel;
   AudioChannelType mCurrentVisibleHigherChannel;
deleted file mode 100644
index d7f6a0ccf47fbc30e936b47e3f4d2cf8f4a90a16..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -1,21 +1,19 @@
 [DEFAULT]
 support-files =
-  audio.ogg
   iframe_messageChannel_cloning.html
   iframe_messageChannel_pingpong.html
   iframe_messageChannel_post.html
   file_empty.html
   iframe_postMessage_solidus.html
 
 [test_Image_constructor.html]
 [test_appname_override.html]
 [test_audioWindowUtils.html]
-[test_audioNotification.html]
 [test_bug913761.html]
 [test_bug978522.html]
 [test_bug979109.html]
 [test_clearTimeoutIntervalNoArg.html]
 [test_consoleEmptyStack.html]
 [test_constructor-assignment.html]
 [test_constructor.html]
 [test_document.all_unqualified.html]
deleted file mode 100644
--- a/dom/base/test/test_audioNotification.html
+++ /dev/null
@@ -1,75 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for audio controller in windows</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<pre id="test">
-</pre>
-
-<script type="application/javascript">
-
-SimpleTest.waitForExplicitFinish();
-
-var expectedNotification = null;
-
-var observer = {
-  observe: function(subject, topic, data) {
-    is(topic, "media-playback", "media-playback received");
-    is(data, expectedNotification, "This is the right notification");
-    runTest();
-  }
-};
-
-var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
-                                   .getService(SpecialPowers.Ci.nsIObserverService);
-
-var audio = new Audio();
-audio.src = "audio.ogg";
-
-var tests = [
-  function() {
-    SpecialPowers.pushPrefEnv({"set": [["media.useAudioChannelService", true]]}, runTest);
-  },
-
-  function() {
-    observerService.addObserver(observer, "media-playback", false);
-    ok(true, "Observer set");
-    runTest();
-  },
-
-  function() {
-    expectedNotification = 'active';
-    audio.play();
-  },
-
-  function() {
-    expectedNotification = 'inactive';
-    audio.pause();
-  },
-
-  function() {
-    observerService.removeObserver(observer, "media-playback");
-    ok(true, "Observer removed");
-    runTest();
-  }
-];
-
-function runTest() {
-  if (!tests.length) {
-    SimpleTest.finish();
-    return;
-  }
-
-  var test = tests.shift();
-  test();
-}
-
-runTest();
-
-</script>
-</body>
-</html>
-