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

Unified Diff: device/wake_lock/wake_lock_service_impl.cc

Issue 2866243002: Fix nits after refactoring WakeLockServiceImpl. (Closed)
Patch Set: Fix nits after refactoring WakeLockServiceImpl. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/wake_lock/wake_lock_service_impl.cc
diff --git a/device/wake_lock/wake_lock_service_impl.cc b/device/wake_lock/wake_lock_service_impl.cc
index 6e1571806cb7d185afabe6c7f05e679defa165a7..ba7c2ada799f40ff258eee5bba45f24edf9024f8 100644
--- a/device/wake_lock/wake_lock_service_impl.cc
+++ b/device/wake_lock/wake_lock_service_impl.cc
@@ -62,11 +62,10 @@ void WakeLockServiceImpl::CancelWakeLock() {
if (!(*binding_set_.dispatch_context()))
return;
+ DCHECK(num_lock_requests_ > 0);
*binding_set_.dispatch_context() = false;
- if (num_lock_requests_ > 0) {
- num_lock_requests_--;
- UpdateWakeLock();
- }
+ num_lock_requests_--;
+ UpdateWakeLock();
}
void WakeLockServiceImpl::HasWakeLockForTests(
@@ -112,16 +111,13 @@ void WakeLockServiceImpl::RemoveWakeLock() {
}
void WakeLockServiceImpl::OnConnectionError() {
- DCHECK(binding_set_.dispatch_context());
-
- // If the error-happening client's wakelock is in outstanding status,
- // decrease the num_lock_requests and call UpdateWakeLock().
+ // If this client has an outstanding wake lock request, decrease the
+ // num_lock_requests and call UpdateWakeLock().
if (*binding_set_.dispatch_context() && num_lock_requests_ > 0) {
num_lock_requests_--;
UpdateWakeLock();
}
- // If |binding_set_| is empty, WakeLockServiceImpl should delele itself.
if (binding_set_.empty())
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698