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

Side by Side 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, 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/wake_lock/public/interfaces/wake_lock_param_traits.h"
6
7 namespace mojo {
8
9 // static
10 device::mojom::WakeLockType
11 EnumTraits<device::mojom::WakeLockType,
12 device::PowerSaveBlocker::PowerSaveBlockerType>::
13 ToMojom(device::PowerSaveBlocker::PowerSaveBlockerType input) {
14 switch (input) {
15 case device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension:
16 return device::mojom::WakeLockType::PreventAppSuspension;
17 case device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep:
18 return device::mojom::WakeLockType::PreventDisplaySleep;
19 }
20
21 NOTREACHED();
22 return device::mojom::WakeLockType::PreventAppSuspension;
23 }
24
25 // static
26 bool EnumTraits<device::mojom::WakeLockType,
27 device::PowerSaveBlocker::PowerSaveBlockerType>::
28 FromMojom(device::mojom::WakeLockType input,
29 device::PowerSaveBlocker::PowerSaveBlockerType* output) {
30 switch (input) {
31 case device::mojom::WakeLockType::PreventAppSuspension:
32 *output = device::PowerSaveBlocker::PowerSaveBlockerType::
33 kPowerSaveBlockPreventAppSuspension;
34 return true;
35 case device::mojom::WakeLockType::PreventDisplaySleep:
36 *output = device::PowerSaveBlocker::PowerSaveBlockerType::
37 kPowerSaveBlockPreventDisplaySleep;
38 return true;
39 }
40
41 NOTREACHED();
42 return false;
43 }
44
45 // static
46 device::mojom::WakeLockReason
47 EnumTraits<device::mojom::WakeLockReason, device::PowerSaveBlocker::Reason>::
48 ToMojom(device::PowerSaveBlocker::Reason input) {
49 switch (input) {
50 case device::PowerSaveBlocker::Reason::kReasonAudioPlayback:
51 return device::mojom::WakeLockReason::ReasonAudioPlayback;
52 case device::PowerSaveBlocker::Reason::kReasonVideoPlayback:
53 return device::mojom::WakeLockReason::ReasonVideoPlayback;
54 case device::PowerSaveBlocker::Reason::kReasonOther:
55 return device::mojom::WakeLockReason::ReasonOther;
56 }
57
58 NOTREACHED();
59 return device::mojom::WakeLockReason::ReasonOther;
60 }
61
62 // static
63 bool EnumTraits<device::mojom::WakeLockReason,
64 device::PowerSaveBlocker::Reason>::
65 FromMojom(device::mojom::WakeLockReason input,
66 device::PowerSaveBlocker::Reason* output) {
67 switch (input) {
68 case device::mojom::WakeLockReason::ReasonAudioPlayback:
69 *output = device::PowerSaveBlocker::Reason::kReasonAudioPlayback;
70 return true;
71 case device::mojom::WakeLockReason::ReasonVideoPlayback:
72 *output = device::PowerSaveBlocker::Reason::kReasonVideoPlayback;
73 return true;
74 case device::mojom::WakeLockReason::ReasonOther:
75 *output = device::PowerSaveBlocker::Reason::kReasonOther;
76 return true;
77 }
78
79 NOTREACHED();
80 return false;
81 }
82
83 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698