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

Side by Side Diff: device/sensors/mojo/sensor_type_converters.cc

Issue 2078433002: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Interfaces + implementation of common part. Created 4 years, 6 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 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698