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

Unified Diff: device/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h

Issue 2929603003: Add RELATIVE_ORIENTATION sensor implementation on macOS to //device/generic_sensor (Closed)
Patch Set: updated readme file Created 3 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/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h
diff --git a/device/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h b/device/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h
new file mode 100644
index 0000000000000000000000000000000000000000..6ff3b638cb94e04955f5cf9b062c4996356cc89c
--- /dev/null
+++ b/device/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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.
+
+#ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELEROMETER_H_
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELEROMETER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/timer/timer.h"
+#include "device/generic_sensor/platform_sensor.h"
+
+namespace device {
+
+class SensorSharedBufferReader;
+
+// Implementation of relative orientation PlatformSensor using accelerometer.
+// This is a single instance object per browser process which is created by
+// The singleton PlatformSensorProvider. If there are no clients, this instance
+// is not created.
+class PlatformSensorRelativeOrientationUsingAccelerometer
+ : public PlatformSensor {
+ public:
+ // Construct a platform sensor of type RELATIVE_ORIENTATION, given a buffer
+ // |mapping| where readings will be written.
+ PlatformSensorRelativeOrientationUsingAccelerometer(
+ mojo::ScopedSharedBufferMapping mapping,
+ PlatformSensorProvider* provider);
+
+ mojom::ReportingMode GetReportingMode() override;
+ PlatformSensorConfiguration GetDefaultConfiguration() override;
+ // Can only be called once, the first time or after a StopSensor call.
+ bool StartSensor(const PlatformSensorConfiguration& configuration) override;
+ void StopSensor() override;
+
+ protected:
+ ~PlatformSensorRelativeOrientationUsingAccelerometer() override;
+ bool CheckSensorConfiguration(
+ const PlatformSensorConfiguration& configuration) override;
+
+ private:
+ void CreateAccelerometerCallback(scoped_refptr<PlatformSensor> accelerometer);
+ void PollForData();
+
+ SensorReading reading_;
+ // Repeating timer for data polling.
+ base::RepeatingTimer timer_;
+ scoped_refptr<PlatformSensor> accelerometer_;
+ std::unique_ptr<SensorSharedBufferReader> accelerometer_reader_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorRelativeOrientationUsingAccelerometer);
+};
+
+} // namespace device
+
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELEROMETER_H_

Powered by Google App Engine
This is Rietveld 408576698