OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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/sensors/sensor_type_converters.h" | |
6 | |
7 #include "device/sensors/platform_sensor.h" | |
8 #include "device/sensors/platform_sensor_configuration.h" | |
9 | |
10 #define CHECK_ENUM(VALUE1, VALUE2) \ | |
11 static_assert(static_cast<int32_t>(VALUE1) == static_cast<int32_t>(VALUE2), \ | |
12 "Enum value mismatch.") | |
13 | |
14 namespace mojo { | |
15 | |
16 // static | |
17 device::PlatformSensorConfiguration | |
18 TypeConverter<device::PlatformSensorConfiguration, | |
19 device::mojom::SensorConfigurationPtr>:: | |
20 Convert(const device::mojom::SensorConfigurationPtr& sensor_configuration) { | |
21 return device::PlatformSensorConfiguration(sensor_configuration->frequency); | |
dcheng
2016/07/01 09:17:24
Instead of adding new type converters, please use
shalamov
2016/07/01 14:22:47
Done.
| |
22 } | |
23 | |
24 // static | |
25 device::SensorType | |
26 TypeConverter<device::SensorType, device::mojom::SensorType>::Convert( | |
27 device::mojom::SensorType sensor_type) { | |
28 CHECK_ENUM(device::SensorType::FIRST, device::mojom::SensorType::FIRST); | |
29 CHECK_ENUM(device::SensorType::AMBIENT_LIGHT, | |
30 device::mojom::SensorType::AMBIENT_LIGHT); | |
31 CHECK_ENUM(device::SensorType::PROXIMITY, | |
32 device::mojom::SensorType::PROXIMITY); | |
33 CHECK_ENUM(device::SensorType::LINEAR_ACCELERATION, | |
34 device::mojom::SensorType::LINEAR_ACCELERATION); | |
35 CHECK_ENUM(device::SensorType::GYROSCOPE, | |
36 device::mojom::SensorType::GYROSCOPE); | |
37 CHECK_ENUM(device::SensorType::PRESSURE, device::mojom::SensorType::PRESSURE); | |
38 CHECK_ENUM(device::SensorType::LAST, device::mojom::SensorType::LAST); | |
39 | |
40 return static_cast<device::SensorType>(sensor_type); | |
41 } | |
42 | |
43 // static | |
44 device::mojom::ReportingMode | |
45 TypeConverter<device::mojom::ReportingMode, device::ReportingMode>::Convert( | |
46 device::ReportingMode reporting_mode) { | |
47 CHECK_ENUM(device::ReportingMode::ON_CHANGE, | |
48 device::mojom::ReportingMode::ON_CHANGE); | |
49 CHECK_ENUM(device::ReportingMode::CONTINUOUS, | |
50 device::mojom::ReportingMode::CONTINUOUS); | |
51 return static_cast<device::mojom::ReportingMode>(reporting_mode); | |
52 } | |
53 | |
54 } // namespace mojo | |
OLD | NEW |