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

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

Issue 2874013002: Add GetWakeLockWithoutContext() in WakeLockContextProvider mojo interface. (Closed)
Patch Set: Add GetWakeLockWithoutContext in WakeLockContextProvider mojo interface. 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 unified diff | Download patch
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 "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // mojom::WakeLockReason once all its clients are converted to be the clients 126 // mojom::WakeLockReason once all its clients are converted to be the clients
127 // of WakeLock. 127 // of WakeLock.
128 wake_lock_ = base::MakeUnique<PowerSaveBlocker>( 128 wake_lock_ = base::MakeUnique<PowerSaveBlocker>(
129 ToPowerSaveBlockerType(type_), ToPowerSaveBlockerReason(reason_), 129 ToPowerSaveBlockerType(type_), ToPowerSaveBlockerReason(reason_),
130 *description_, main_task_runner_, file_task_runner_); 130 *description_, main_task_runner_, file_task_runner_);
131 131
132 if (type_ != mojom::WakeLockType::PreventDisplaySleep) 132 if (type_ != mojom::WakeLockType::PreventDisplaySleep)
133 return; 133 return;
134 134
135 #if defined(OS_ANDROID) 135 #if defined(OS_ANDROID)
136 if (context_id_ == WakeLockServiceContext::WakeLockInvalidContextId)
137 return;
blundell 2017/05/12 12:42:18 Maybe we should LOG(ERROR) here, as if the client
ke.he 2017/05/12 16:09:38 Done.
138
136 gfx::NativeView native_view = native_view_getter_.Run(context_id_); 139 gfx::NativeView native_view = native_view_getter_.Run(context_id_);
137 if (native_view) 140 if (native_view)
138 wake_lock_.get()->InitDisplaySleepBlocker(native_view); 141 wake_lock_.get()->InitDisplaySleepBlocker(native_view);
139 #endif 142 #endif
140 } 143 }
141 144
142 void WakeLockServiceImpl::RemoveWakeLock() { 145 void WakeLockServiceImpl::RemoveWakeLock() {
143 DCHECK(wake_lock_); 146 DCHECK(wake_lock_);
144 wake_lock_.reset(); 147 wake_lock_.reset();
145 } 148 }
146 149
147 void WakeLockServiceImpl::OnConnectionError() { 150 void WakeLockServiceImpl::OnConnectionError() {
148 // If this client has an outstanding wake lock request, decrease the 151 // If this client has an outstanding wake lock request, decrease the
149 // num_lock_requests and call UpdateWakeLock(). 152 // num_lock_requests and call UpdateWakeLock().
150 if (*binding_set_.dispatch_context() && num_lock_requests_ > 0) { 153 if (*binding_set_.dispatch_context() && num_lock_requests_ > 0) {
151 num_lock_requests_--; 154 num_lock_requests_--;
152 UpdateWakeLock(); 155 UpdateWakeLock();
153 } 156 }
154 157
155 if (binding_set_.empty()) 158 if (binding_set_.empty())
156 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 159 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
157 } 160 }
158 161
159 } // namespace device 162 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698