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

Side by Side Diff: content/browser/wake_lock/wake_lock_service_context.cc

Issue 2072403002: Remove content/browser/power_save_blocker_factory.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: component Created 4 years, 6 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/wake_lock/wake_lock_service_context.h" 5 #include "content/browser/wake_lock/wake_lock_service_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "content/browser/power_save_blocker_factory.h"
12 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/service_registry.h" 15 #include "content/public/common/service_registry.h"
16 #include "device/power_save_blocker/power_save_blocker.h"
17 #include "device/power_save_blocker/power_save_blocker_impl.h" 17 #include "device/power_save_blocker/power_save_blocker_impl.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 WakeLockServiceContext::WakeLockServiceContext(WebContents* web_contents) 21 WakeLockServiceContext::WakeLockServiceContext(WebContents* web_contents)
22 : WebContentsObserver(web_contents), weak_factory_(this) {} 22 : WebContentsObserver(web_contents), weak_factory_(this) {}
23 23
24 WakeLockServiceContext::~WakeLockServiceContext() {} 24 WakeLockServiceContext::~WakeLockServiceContext() {}
25 25
26 void WakeLockServiceContext::CreateService( 26 void WakeLockServiceContext::CreateService(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 std::pair<int, int>(render_process_id, render_frame_id)); 61 std::pair<int, int>(render_process_id, render_frame_id));
62 UpdateWakeLock(); 62 UpdateWakeLock();
63 } 63 }
64 64
65 bool WakeLockServiceContext::HasWakeLockForTests() const { 65 bool WakeLockServiceContext::HasWakeLockForTests() const {
66 return !!wake_lock_; 66 return !!wake_lock_;
67 } 67 }
68 68
69 void WakeLockServiceContext::CreateWakeLock() { 69 void WakeLockServiceContext::CreateWakeLock() {
70 DCHECK(!wake_lock_); 70 DCHECK(!wake_lock_);
71 wake_lock_ = CreatePowerSaveBlocker( 71 wake_lock_ = device::PowerSaveBlocker::CreateWithTaskRunners(
jam 2016/06/17 22:11:57 can we also get rid of this method? what about th
72 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, 72 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
73 device::PowerSaveBlocker::kReasonOther, "Wake Lock API"); 73 device::PowerSaveBlocker::kReasonOther, "Wake Lock API",
74 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
75 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
74 76
75 #if defined(OS_ANDROID) 77 #if defined(OS_ANDROID)
76 // On Android, additionaly associate the blocker with this WebContents. 78 // On Android, additionaly associate the blocker with this WebContents.
77 DCHECK(web_contents()); 79 DCHECK(web_contents());
78 80
79 if (web_contents()->GetNativeView()) { 81 if (web_contents()->GetNativeView()) {
80 view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>( 82 view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>(
81 web_contents()->GetNativeView())); 83 web_contents()->GetNativeView()));
82 static_cast<device::PowerSaveBlockerImpl*>(wake_lock_.get()) 84 static_cast<device::PowerSaveBlockerImpl*>(wake_lock_.get())
83 ->InitDisplaySleepBlocker(view_weak_factory_->GetWeakPtr()); 85 ->InitDisplaySleepBlocker(view_weak_factory_->GetWeakPtr());
(...skipping 10 matching lines...) Expand all
94 if (!frames_requesting_lock_.empty()) { 96 if (!frames_requesting_lock_.empty()) {
95 if (!wake_lock_) 97 if (!wake_lock_)
96 CreateWakeLock(); 98 CreateWakeLock();
97 } else { 99 } else {
98 if (wake_lock_) 100 if (wake_lock_)
99 RemoveWakeLock(); 101 RemoveWakeLock();
100 } 102 }
101 } 103 }
102 104
103 } // namespace content 105 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698