OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELER
OMETER_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELER
OMETER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/timer/timer.h" |
| 12 #include "device/generic_sensor/platform_sensor.h" |
| 13 |
| 14 namespace device { |
| 15 |
| 16 class SensorSharedBufferReader; |
| 17 |
| 18 // Implementation of relative orientation PlatformSensor using accelerometer. |
| 19 // This is a single instance object per browser process which is created by |
| 20 // The singleton PlatformSensorProvider. If there are no clients, this instance |
| 21 // is not created. |
| 22 class PlatformSensorRelativeOrientationUsingAccelerometer |
| 23 : public PlatformSensor { |
| 24 public: |
| 25 // Construct a platform sensor of type RELATIVE_ORIENTATION, given a buffer |
| 26 // |mapping| where readings will be written. |
| 27 PlatformSensorRelativeOrientationUsingAccelerometer( |
| 28 mojo::ScopedSharedBufferMapping mapping, |
| 29 PlatformSensorProvider* provider); |
| 30 |
| 31 mojom::ReportingMode GetReportingMode() override; |
| 32 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 33 // Can only be called once, the first time or after a StopSensor call. |
| 34 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 35 void StopSensor() override; |
| 36 |
| 37 protected: |
| 38 ~PlatformSensorRelativeOrientationUsingAccelerometer() override; |
| 39 bool CheckSensorConfiguration( |
| 40 const PlatformSensorConfiguration& configuration) override; |
| 41 |
| 42 private: |
| 43 void CreateAccelerometerCallback(scoped_refptr<PlatformSensor> accelerometer); |
| 44 void PollForData(); |
| 45 |
| 46 SensorReading reading_; |
| 47 // Repeating timer for data polling. |
| 48 base::RepeatingTimer timer_; |
| 49 scoped_refptr<PlatformSensor> accelerometer_; |
| 50 std::unique_ptr<SensorSharedBufferReader> accelerometer_reader_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(PlatformSensorRelativeOrientationUsingAccelerometer); |
| 53 }; |
| 54 |
| 55 } // namespace device |
| 56 |
| 57 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCE
LEROMETER_H_ |
OLD | NEW |