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

Side by Side Diff: device/wake_lock/wake_lock_service_impl.cc

Issue 2734943003: Device Service: Decouple Wake Lock from //content (Closed)
Patch Set: Rebase Created 3 years, 9 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 | « device/wake_lock/wake_lock_service_impl.h ('k') | services/device/BUILD.gn » ('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 "device/wake_lock/wake_lock_service_impl.h" 5 #include "device/wake_lock/wake_lock_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "device/wake_lock/wake_lock_service_context.h" 9 #include "device/wake_lock/wake_lock_service_context.h"
10 10
11 namespace device { 11 namespace device {
12 12
13 WakeLockServiceImpl::WakeLockServiceImpl( 13 WakeLockServiceImpl::WakeLockServiceImpl(WakeLockServiceContext* context)
14 base::WeakPtr<WakeLockServiceContext> context)
15 : context_(context), wake_lock_request_outstanding_(false) {} 14 : context_(context), wake_lock_request_outstanding_(false) {}
16 15
17 WakeLockServiceImpl::~WakeLockServiceImpl() { 16 WakeLockServiceImpl::~WakeLockServiceImpl() {
18 CancelWakeLock(); 17 CancelWakeLock();
19 } 18 }
20 19
21 void WakeLockServiceImpl::RequestWakeLock() { 20 void WakeLockServiceImpl::RequestWakeLock() {
22 if (!context_ || wake_lock_request_outstanding_) 21 if (wake_lock_request_outstanding_)
23 return; 22 return;
24 23
25 wake_lock_request_outstanding_ = true; 24 wake_lock_request_outstanding_ = true;
26 context_->RequestWakeLock(); 25 context_->RequestWakeLock();
27 } 26 }
28 27
29 void WakeLockServiceImpl::CancelWakeLock() { 28 void WakeLockServiceImpl::CancelWakeLock() {
30 if (!context_ || !wake_lock_request_outstanding_) 29 if (!wake_lock_request_outstanding_)
31 return; 30 return;
32 31
33 wake_lock_request_outstanding_ = false; 32 wake_lock_request_outstanding_ = false;
34 context_->CancelWakeLock(); 33 context_->CancelWakeLock();
35 } 34 }
36 35
37 } // namespace device 36 } // namespace device
OLDNEW
« no previous file with comments | « device/wake_lock/wake_lock_service_impl.h ('k') | services/device/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698