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

Unified Diff: device/generic_sensor/public/interfaces/sensor_struct_traits.cc

Issue 2144623003: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Definition for PlatformSensorProvider ctor/dtor Created 4 years, 4 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/generic_sensor/public/interfaces/sensor_struct_traits.cc
diff --git a/device/generic_sensor/public/interfaces/sensor_struct_traits.cc b/device/generic_sensor/public/interfaces/sensor_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..164e3231b49a9a9e5564d4207ae6238a582ac275
--- /dev/null
+++ b/device/generic_sensor/public/interfaces/sensor_struct_traits.cc
@@ -0,0 +1,25 @@
+// 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/generic_sensor/public/interfaces/sensor_struct_traits.h"
+
+namespace mojo {
+
+// static
+bool StructTraits<device::mojom::SensorConfiguration,
+ device::PlatformSensorConfiguration>::
+ Read(device::mojom::SensorConfigurationDataView data,
+ device::PlatformSensorConfiguration* out) {
+ // Maximum allowed frequency is capped to 60Hz.
+ if (data.frequency() >
+ device::PlatformSensorConfiguration::kMaxAllowedFrequency ||
+ data.frequency() <= 0.0) {
+ return false;
+ }
+
+ out->set_frequency(data.frequency());
+ return true;
+}
+
+} // namespace mojo
« no previous file with comments | « device/generic_sensor/public/interfaces/sensor_struct_traits.h ('k') | device/generic_sensor/public/interfaces/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698