Bug 1375235 - Don't create the AudioChannelWindow unnecessarily when checking for audio activity in the window. r=padenot
authorBen Kelly <ben@wanderview.com>
Thu, 22 Jun 2017 06:40:00 -0400
changeset 601740 85d5713965972c042a8b5a0d3bc4b9a50e381730
parent 601739 8702d42d3fffc20c2764a446d205bfef2df08257
child 601741 806591fab334acf6d96862efd597a91eddc77dcf
push id66200
push userhchang@mozilla.com
push dateThu, 29 Jun 2017 03:53:43 +0000
reviewerspadenot
bugs1375235
milestone56.0a1
Bug 1375235 - Don't create the AudioChannelWindow unnecessarily when checking for audio activity in the window. r=padenot
dom/audiochannel/AudioChannelService.cpp
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -629,17 +629,22 @@ bool
 AudioChannelService::IsWindowActive(nsPIDOMWindowOuter* aWindow)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
   if (!window) {
     return false;
   }
-  AudioChannelWindow* winData = GetOrCreateWindowData(window);
+
+  AudioChannelWindow* winData = GetWindowData(window->WindowID());
+  if (!winData) {
+    return false;
+  }
+
   return !winData->mAudibleAgents.IsEmpty();
 }
 
 void
 AudioChannelService::RefreshAgentsAudioFocusChanged(AudioChannelAgent* aAgent)
 {
   MOZ_ASSERT(aAgent);