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

Unified Diff: device/wake_lock/public/interfaces/wake_lock_param_traits.cc

Issue 2843353003: Move ownership of PowerSaveBlocker from WakeLockServiceContext to WakeLockServiceImpl (Closed)
Patch Set: error fix, non-frame client. Created 3 years, 8 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
Index: device/wake_lock/public/interfaces/wake_lock_param_traits.cc
diff --git a/device/wake_lock/public/interfaces/wake_lock_param_traits.cc b/device/wake_lock/public/interfaces/wake_lock_param_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e6427ec9c23945cc2cadb24dda1115177c75d578
--- /dev/null
+++ b/device/wake_lock/public/interfaces/wake_lock_param_traits.cc
@@ -0,0 +1,83 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/wake_lock/public/interfaces/wake_lock_param_traits.h"
+
+namespace mojo {
+
+// static
+device::mojom::WakeLockType
+EnumTraits<device::mojom::WakeLockType,
+ device::PowerSaveBlocker::PowerSaveBlockerType>::
+ ToMojom(device::PowerSaveBlocker::PowerSaveBlockerType input) {
+ switch (input) {
+ case device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension:
+ return device::mojom::WakeLockType::PreventAppSuspension;
+ case device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep:
+ return device::mojom::WakeLockType::PreventDisplaySleep;
+ }
+
+ NOTREACHED();
+ return device::mojom::WakeLockType::PreventAppSuspension;
+}
+
+// static
+bool EnumTraits<device::mojom::WakeLockType,
+ device::PowerSaveBlocker::PowerSaveBlockerType>::
+ FromMojom(device::mojom::WakeLockType input,
+ device::PowerSaveBlocker::PowerSaveBlockerType* output) {
+ switch (input) {
+ case device::mojom::WakeLockType::PreventAppSuspension:
+ *output = device::PowerSaveBlocker::PowerSaveBlockerType::
+ kPowerSaveBlockPreventAppSuspension;
+ return true;
+ case device::mojom::WakeLockType::PreventDisplaySleep:
+ *output = device::PowerSaveBlocker::PowerSaveBlockerType::
+ kPowerSaveBlockPreventDisplaySleep;
+ return true;
+ }
+
+ NOTREACHED();
+ return false;
+}
+
+// static
+device::mojom::WakeLockReason
+EnumTraits<device::mojom::WakeLockReason, device::PowerSaveBlocker::Reason>::
+ ToMojom(device::PowerSaveBlocker::Reason input) {
+ switch (input) {
+ case device::PowerSaveBlocker::Reason::kReasonAudioPlayback:
+ return device::mojom::WakeLockReason::ReasonAudioPlayback;
+ case device::PowerSaveBlocker::Reason::kReasonVideoPlayback:
+ return device::mojom::WakeLockReason::ReasonVideoPlayback;
+ case device::PowerSaveBlocker::Reason::kReasonOther:
+ return device::mojom::WakeLockReason::ReasonOther;
+ }
+
+ NOTREACHED();
+ return device::mojom::WakeLockReason::ReasonOther;
+}
+
+// static
+bool EnumTraits<device::mojom::WakeLockReason,
+ device::PowerSaveBlocker::Reason>::
+ FromMojom(device::mojom::WakeLockReason input,
+ device::PowerSaveBlocker::Reason* output) {
+ switch (input) {
+ case device::mojom::WakeLockReason::ReasonAudioPlayback:
+ *output = device::PowerSaveBlocker::Reason::kReasonAudioPlayback;
+ return true;
+ case device::mojom::WakeLockReason::ReasonVideoPlayback:
+ *output = device::PowerSaveBlocker::Reason::kReasonVideoPlayback;
+ return true;
+ case device::mojom::WakeLockReason::ReasonOther:
+ *output = device::PowerSaveBlocker::Reason::kReasonOther;
+ return true;
+ }
+
+ NOTREACHED();
+ return false;
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698