| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "content/browser/media/media_web_contents_observer.h" | 5 #include "content/browser/media/media_web_contents_observer.h" | 
| 6 | 6 | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 | 8 | 
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" | 
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 187 } | 187 } | 
| 188 | 188 | 
| 189 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { | 189 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { | 
| 190   DCHECK(!video_power_save_blocker_); | 190   DCHECK(!video_power_save_blocker_); | 
| 191   DCHECK(!active_video_players_.empty()); | 191   DCHECK(!active_video_players_.empty()); | 
| 192   video_power_save_blocker_ = CreatePowerSaveBlocker( | 192   video_power_save_blocker_ = CreatePowerSaveBlocker( | 
| 193       PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 193       PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 
| 194       PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); | 194       PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); | 
| 195 #if defined(OS_ANDROID) | 195 #if defined(OS_ANDROID) | 
| 196   static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | 196   static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | 
| 197       ->InitDisplaySleepBlocker(web_contents()); | 197       ->InitDisplaySleepBlocker(web_contents()->GetNativeView()); | 
| 198 #endif | 198 #endif | 
| 199 } | 199 } | 
| 200 | 200 | 
| 201 void MediaWebContentsObserver::MaybeReleasePowerSaveBlockers() { | 201 void MediaWebContentsObserver::MaybeReleasePowerSaveBlockers() { | 
| 202   // If there are no more audio players and we don't have audio stream | 202   // If there are no more audio players and we don't have audio stream | 
| 203   // monitoring, release the audio power save blocker here instead of during | 203   // monitoring, release the audio power save blocker here instead of during | 
| 204   // NotifyNavigationStateChanged(). | 204   // NotifyNavigationStateChanged(). | 
| 205   if (active_audio_players_.empty() && | 205   if (active_audio_players_.empty() && | 
| 206       !AudioStreamMonitor::monitoring_available()) { | 206       !AudioStreamMonitor::monitoring_available()) { | 
| 207     audio_power_save_blocker_.reset(); | 207     audio_power_save_blocker_.reset(); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 245   if (it == player_map->end()) | 245   if (it == player_map->end()) | 
| 246     return; | 246     return; | 
| 247 | 247 | 
| 248   for (int delegate_id : it->second) | 248   for (int delegate_id : it->second) | 
| 249     removed_players->insert(MediaPlayerId(render_frame_host, delegate_id)); | 249     removed_players->insert(MediaPlayerId(render_frame_host, delegate_id)); | 
| 250 | 250 | 
| 251   player_map->erase(it); | 251   player_map->erase(it); | 
| 252 } | 252 } | 
| 253 | 253 | 
| 254 }  // namespace content | 254 }  // namespace content | 
| OLD | NEW | 
|---|