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

Unified Diff: device/wake_lock/wake_lock_service_impl.cc

Issue 2867303003: Generalize the API of WakeLockContext mojo interface. (Closed)
Patch Set: remove typemap, call InitDisplaySleepBlocker with condition. 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 | « device/wake_lock/wake_lock_service_impl.h ('k') | 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..254fd27b9513033f736781c20800940192255fd2 100644
--- a/device/wake_lock/wake_lock_service_impl.cc
+++ b/device/wake_lock/wake_lock_service_impl.cc
@@ -12,8 +12,8 @@ namespace device {
WakeLockServiceImpl::WakeLockServiceImpl(
mojom::WakeLockServiceRequest request,
- device::PowerSaveBlocker::PowerSaveBlockerType type,
- device::PowerSaveBlocker::Reason reason,
+ mojom::WakeLockType type,
+ mojom::WakeLockReason reason,
const std::string& description,
int context_id,
WakeLockContextCallback native_view_getter,
@@ -88,16 +88,24 @@ void WakeLockServiceImpl::UpdateWakeLock() {
void WakeLockServiceImpl::CreateWakeLock() {
DCHECK(!wake_lock_);
- if (type_ != device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep ||
- reason_ != device::PowerSaveBlocker::kReasonOther ||
- *description_ != "Wake Lock API") {
- // TODO(ke.he@intel.com): Fully generalize the WakeLock interface and impl.
- NOTREACHED();
- return;
- }
+ // TODO(heke): Remove below static_cast, and switch PowerSaveBlocker to use
+ // mojom::WakeLockType and mojom::WakeLockReason once all its clients are
+ // converted to be the clients of WakeLock.
+
+ // It is safe to static_cast because the definition of mojom::WakeLockType
+ // and mojom::WakeLockReason are just copied from
+ // PowerSaveBlocker::PowerSaveBlockerType and PowerSaveBlocker::Reason.
+ PowerSaveBlocker::PowerSaveBlockerType type =
+ static_cast<PowerSaveBlocker::PowerSaveBlockerType>(type_);
blundell 2017/05/10 10:05:11 hmm, I think it would be safer to explicitly do th
ke.he 2017/05/10 13:12:03 Done.
+ PowerSaveBlocker::Reason reason =
+ static_cast<PowerSaveBlocker::Reason>(reason_);
- wake_lock_ = base::MakeUnique<device::PowerSaveBlocker>(
- type_, reason_, *description_, main_task_runner_, file_task_runner_);
+ wake_lock_ = base::MakeUnique<PowerSaveBlocker>(
+ type, reason, *description_, main_task_runner_, file_task_runner_);
+
+ if (type != PowerSaveBlocker::PowerSaveBlockerType::
+ kPowerSaveBlockPreventDisplaySleep)
+ return;
#if defined(OS_ANDROID)
gfx::NativeView native_view = native_view_getter_.Run(context_id_);
« no previous file with comments | « device/wake_lock/wake_lock_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698