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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: device/sensors/mojo/sensor_type_converters.cc
diff --git a/device/sensors/mojo/sensor_type_converters.cc b/device/sensors/mojo/sensor_type_converters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1ada4e67756331127ff54988151f9ca5667d1619
--- /dev/null
+++ b/device/sensors/mojo/sensor_type_converters.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 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/sensors/mojo/sensor_type_converters.h"
+
+#include "device/sensors/platform/platform_sensor.h"
+#include "device/sensors/platform/platform_sensor_configuration.h"
+
+#define CHECK_ENUM(VALUE1, VALUE2) \
+ static_assert(static_cast<int32_t>(VALUE1) == static_cast<int32_t>(VALUE2), \
+ "Enum value mismatch.")
+
+namespace mojo {
+
+// static
+device::PlatformSensorConfiguration
+TypeConverter<device::PlatformSensorConfiguration,
+ device::sensors::SensorConfigurationPtr>::
+ Convert(
+ const device::sensors::SensorConfigurationPtr& sensor_configuration) {
+ return device::PlatformSensorConfiguration(sensor_configuration->frequency);
+}
+
+// static
+device::SensorType
+TypeConverter<device::SensorType, device::sensors::SensorType>::Convert(
+ device::sensors::SensorType sensor_type) {
+ CHECK_ENUM(device::SensorType::FIRST, device::sensors::SensorType::FIRST);
+ CHECK_ENUM(device::SensorType::AMBIENT_LIGHT,
+ device::sensors::SensorType::AMBIENT_LIGHT);
+ CHECK_ENUM(device::SensorType::PROXIMITY,
+ device::sensors::SensorType::PROXIMITY);
+ CHECK_ENUM(device::SensorType::LINEAR_ACCELERATION,
+ device::sensors::SensorType::LINEAR_ACCELERATION);
+ CHECK_ENUM(device::SensorType::GYROSCOPE,
+ device::sensors::SensorType::GYROSCOPE);
+ CHECK_ENUM(device::SensorType::PRESSURE,
+ device::sensors::SensorType::PRESSURE);
+ CHECK_ENUM(device::SensorType::LAST, device::sensors::SensorType::LAST);
+
+ return static_cast<device::SensorType>(sensor_type);
+}
+
+// static
+device::sensors::ReportingMode
+TypeConverter<device::sensors::ReportingMode, device::ReportingMode>::Convert(
+ device::ReportingMode reporting_mode) {
+ CHECK_ENUM(device::ReportingMode::ON_CHANGE,
+ device::sensors::ReportingMode::ON_CHANGE);
+ CHECK_ENUM(device::ReportingMode::CONTINUOUS,
+ device::sensors::ReportingMode::CONTINUOUS);
+ return static_cast<device::sensors::ReportingMode>(reporting_mode);
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698