Index: device/generic_sensor/platform_sensor_fusion_relative_orientation.h |
diff --git a/device/generic_sensor/platform_sensor_fusion_relative_orientation.h b/device/generic_sensor/platform_sensor_fusion_relative_orientation.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75bae74be6e7d03464cb8f14c706b5ee7c5fc844 |
--- /dev/null |
+++ b/device/generic_sensor/platform_sensor_fusion_relative_orientation.h |
@@ -0,0 +1,64 @@ |
+// 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_FUSION_RELATIVE_ORIENTATION_H_ |
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_FUSION_RELATIVE_ORIENTATION_H_ |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "base/timer/timer.h" |
+#include "device/generic_sensor/platform_sensor.h" |
+#include "device/generic_sensor/platform_sensor_provider_base.h" |
+ |
+namespace device { |
+ |
+class RelativeOrientationFusionAlgorithm; |
+ |
+// Implementation of relative orientation PlatformSensor using fusion. |
+// 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 PlatformSensorFusionRelativeOrientation : public PlatformSensor, |
+ public PlatformSensor::Client { |
+ public: |
+ // Construct a platform fusion sensor of type RELATIVE_ORIENTATION, given a |
+ // buffer |mapping| where readings will be written. |
+ PlatformSensorFusionRelativeOrientation( |
+ mojo::ScopedSharedBufferMapping mapping, |
+ PlatformSensorProvider* provider, |
+ const PlatformSensorProviderBase::CreateSensorCallback& callback); |
+ |
+ // PlatformSensor: |
+ 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; |
+ bool CheckSensorConfiguration( |
+ const PlatformSensorConfiguration& configuration) override; |
+ |
+ // PlatformSensor::Client: |
+ void OnSensorReadingChanged() override; |
+ void OnSensorError() override; |
+ bool IsNotificationSuspended() override; |
+ |
+ protected: |
+ ~PlatformSensorFusionRelativeOrientation() override; |
+ |
+ private: |
+ void CreateAccelerometerCallback(scoped_refptr<PlatformSensor> accelerometer); |
+ void CreateAccelerometerSucceeded(); |
+ |
+ PlatformSensorProviderBase::CreateSensorCallback callback_; |
+ SensorReading reading_; |
+ scoped_refptr<PlatformSensor> accelerometer_; |
+ std::unique_ptr<RelativeOrientationFusionAlgorithm> fusion_algorithm_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorFusionRelativeOrientation); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_FUSION_RELATIVE_ORIENTATION_H_ |