Bug 1338137 - part2 : remove function IsServiceStarted(). draft
authorAlastor Wu <alwu@mozilla.com>
Sat, 04 Mar 2017 01:14:28 +0800
changeset 493239 b3cd4bcde37258263d7435934ef5eab010727ff5
parent 493238 5b9a36bddec939d7f77252ce53ce5b408e1d716a
child 493240 9b8271bc5354b2d59849a5cfcb1924095d70a810
push id47694
push useralwu@mozilla.com
push dateFri, 03 Mar 2017 17:17:14 +0000
bugs1338137, 1338466
milestone54.0a1
Bug 1338137 - part2 : remove function IsServiceStarted(). The reason we introduced the IsServiceStarted(), check bug1338466 comment5 for more details. The patch1 introduces more robust way to check the alive media component, so we can remove IsServiceStarted(). MozReview-Commit-ID: LIma8hZTuhA
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/base/nsGlobalWindow.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -198,23 +198,16 @@ AudioChannelService::CreateServiceIfNeed
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!gAudioChannelService) {
     gAudioChannelService = new AudioChannelService();
   }
 }
 
-/* static */ bool
-AudioChannelService::IsServiceStarted()
-{
-  // The service would start when the first AudioChannelAgent is created.
-  return !!gAudioChannelService;
-}
-
 /* static */ already_AddRefed<AudioChannelService>
 AudioChannelService::GetOrCreate()
 {
   if (sXPCOMShuttingDown) {
     return nullptr;
   }
 
   CreateServiceIfNeeded();
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -101,18 +101,16 @@ public:
   static already_AddRefed<AudioChannelService> Get();
 
   static bool IsAudioChannelMutedByDefault();
 
   static PRLogModuleInfo* GetAudioChannelLog();
 
   static bool IsEnableAudioCompeting();
 
-  static bool IsServiceStarted();
-
   /**
    * Any audio channel agent that starts playing should register itself to
    * this service, sharing the AudioChannel.
    */
   void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
                                  AudibleState aAudible);
 
   /**
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4236,18 +4236,17 @@ nsPIDOMWindowOuter::MaybeActiveMediaComp
   }
 
   nsCOMPtr<nsIDocument> doc = inner->GetExtantDoc();
   if (!doc) {
     return;
   }
 
   if (!doc->Hidden() &&
-      mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK &&
-      AudioChannelService::IsServiceStarted()) {
+      mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK) {
     SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
   }
 }
 
 SuspendTypes
 nsPIDOMWindowOuter::GetMediaSuspend() const
 {
   if (IsInnerWindow()) {