| 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_
|
|
|