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/mojo/sensor_type_converters.h" |
| 6 |
| 7 #include "device/sensors/platform/platform_sensor.h" |
| 8 #include "device/sensors/platform/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::sensors::SensorConfigurationPtr>:: |
| 20 Convert( |
| 21 const device::sensors::SensorConfigurationPtr& sensor_configuration) { |
| 22 return device::PlatformSensorConfiguration(sensor_configuration->frequency); |
| 23 } |
| 24 |
| 25 // static |
| 26 device::SensorType |
| 27 TypeConverter<device::SensorType, device::sensors::SensorType>::Convert( |
| 28 device::sensors::SensorType sensor_type) { |
| 29 CHECK_ENUM(device::SensorType::FIRST, device::sensors::SensorType::FIRST); |
| 30 CHECK_ENUM(device::SensorType::AMBIENT_LIGHT, |
| 31 device::sensors::SensorType::AMBIENT_LIGHT); |
| 32 CHECK_ENUM(device::SensorType::PROXIMITY, |
| 33 device::sensors::SensorType::PROXIMITY); |
| 34 CHECK_ENUM(device::SensorType::LINEAR_ACCELERATION, |
| 35 device::sensors::SensorType::LINEAR_ACCELERATION); |
| 36 CHECK_ENUM(device::SensorType::GYROSCOPE, |
| 37 device::sensors::SensorType::GYROSCOPE); |
| 38 CHECK_ENUM(device::SensorType::PRESSURE, |
| 39 device::sensors::SensorType::PRESSURE); |
| 40 CHECK_ENUM(device::SensorType::LAST, device::sensors::SensorType::LAST); |
| 41 |
| 42 return static_cast<device::SensorType>(sensor_type); |
| 43 } |
| 44 |
| 45 // static |
| 46 device::sensors::ReportingMode |
| 47 TypeConverter<device::sensors::ReportingMode, device::ReportingMode>::Convert( |
| 48 device::ReportingMode reporting_mode) { |
| 49 CHECK_ENUM(device::ReportingMode::ON_CHANGE, |
| 50 device::sensors::ReportingMode::ON_CHANGE); |
| 51 CHECK_ENUM(device::ReportingMode::CONTINUOUS, |
| 52 device::sensors::ReportingMode::CONTINUOUS); |
| 53 return static_cast<device::sensors::ReportingMode>(reporting_mode); |
| 54 } |
| 55 |
| 56 } // namespace mojo |
OLD | NEW |