Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: content/browser/media/media_web_contents_observer.cc

Issue 2006143006: Revert of Pass SequencedTaskRunner to PowerSaveBlocker for ui/file operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@device-power-save-blocker
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "content/browser/media/audible_metrics.h" 11 #include "content/browser/media/audible_metrics.h"
12 #include "content/browser/media/audio_stream_monitor.h" 12 #include "content/browser/media/audio_stream_monitor.h"
13 #include "content/browser/power_save_blocker_impl.h" 13 #include "content/browser/power_save_blocker_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/common/media/media_player_delegate_messages.h" 15 #include "content/common/media/media_player_delegate_messages.h"
16 #include "content/public/browser/power_save_blocker_factory.h"
17 #include "content/public/browser/render_frame_host.h" 16 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "ipc/ipc_message_macros.h" 18 #include "ipc/ipc_message_macros.h"
20 19
21 namespace content { 20 namespace content {
22 21
23 namespace { 22 namespace {
24 23
25 static base::LazyInstance<AudibleMetrics>::Leaky g_audible_metrics = 24 static base::LazyInstance<AudibleMetrics>::Leaky g_audible_metrics =
26 LAZY_INSTANCE_INITIALIZER; 25 LAZY_INSTANCE_INITIALIZER;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 MaybeReleasePowerSaveBlockers(); 173 MaybeReleasePowerSaveBlockers();
175 174
176 // Notify all observers the player has been "paused". 175 // Notify all observers the player has been "paused".
177 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents()); 176 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents());
178 for (const auto& id : removed_players) 177 for (const auto& id : removed_players)
179 wci->MediaStoppedPlaying(id); 178 wci->MediaStoppedPlaying(id);
180 } 179 }
181 180
182 void MediaWebContentsObserver::CreateAudioPowerSaveBlocker() { 181 void MediaWebContentsObserver::CreateAudioPowerSaveBlocker() {
183 DCHECK(!audio_power_save_blocker_); 182 DCHECK(!audio_power_save_blocker_);
184 audio_power_save_blocker_ = CreatePowerSaveBlocker( 183 audio_power_save_blocker_ = PowerSaveBlocker::Create(
185 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, 184 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
186 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); 185 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio");
187 } 186 }
188 187
189 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { 188 void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() {
190 DCHECK(!video_power_save_blocker_); 189 DCHECK(!video_power_save_blocker_);
191 DCHECK(!active_video_players_.empty()); 190 DCHECK(!active_video_players_.empty());
192 video_power_save_blocker_ = CreatePowerSaveBlocker( 191 video_power_save_blocker_ = PowerSaveBlocker::Create(
193 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, 192 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
194 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); 193 PowerSaveBlocker::kReasonVideoPlayback, "Playing video");
195 #if defined(OS_ANDROID) 194 #if defined(OS_ANDROID)
196 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) 195 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get())
197 ->InitDisplaySleepBlocker(web_contents()); 196 ->InitDisplaySleepBlocker(web_contents());
198 #endif 197 #endif
199 } 198 }
200 199
201 void MediaWebContentsObserver::MaybeReleasePowerSaveBlockers() { 200 void MediaWebContentsObserver::MaybeReleasePowerSaveBlockers() {
202 // If there are no more audio players and we don't have audio stream 201 // If there are no more audio players and we don't have audio stream
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (it == player_map->end()) 244 if (it == player_map->end())
246 return; 245 return;
247 246
248 for (int delegate_id : it->second) 247 for (int delegate_id : it->second)
249 removed_players->insert(MediaPlayerId(render_frame_host, delegate_id)); 248 removed_players->insert(MediaPlayerId(render_frame_host, delegate_id));
250 249
251 player_map->erase(it); 250 player_map->erase(it);
252 } 251 }
253 252
254 } // namespace content 253 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/desktop_capture_device.cc ('k') | content/browser/media/webrtc/webrtc_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698