Chromium Code Reviews| Index: device/generic_sensor/platform_sensor_accelerometer_mac.h |
| diff --git a/device/generic_sensor/platform_sensor_accelerometer_mac.h b/device/generic_sensor/platform_sensor_accelerometer_mac.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6d85e7867f8065f87b9be25a31527982db180b3a |
| --- /dev/null |
| +++ b/device/generic_sensor/platform_sensor_accelerometer_mac.h |
| @@ -0,0 +1,55 @@ |
| +// 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_ACCELEROMETER_MAC_H_ |
| +#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ACCELEROMETER_MAC_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/timer/timer.h" |
| +#include "device/generic_sensor/platform_sensor.h" |
| + |
| +class SuddenMotionSensor; |
| + |
| +namespace device { |
| + |
| +// Implementation of PlatformSensor for MacOS to query the accelerometer |
|
Reilly Grant (use Gerrit)
2017/05/13 00:33:16
MacOS -> macOS
juncai
2017/05/13 00:53:49
Done.
|
| +// sensor. |
| +// This is a single instance object per browser process which is created by |
| +// The singleton PlatformSensorProviderMac. If there are no clients, this |
| +// instance is not created. |
| +class PlatformSensorAccelerometerMac : public PlatformSensor { |
| + public: |
| + // Construct a platform sensor of ACCELEROMETER, given a buffer |mapping| |
| + // to write the result back. |
|
Reilly Grant (use Gerrit)
2017/05/13 00:33:16
Construct a platform sensor of type ACCELEROMETER,
juncai
2017/05/13 00:53:49
Done.
|
| + PlatformSensorAccelerometerMac(mojo::ScopedSharedBufferMapping mapping, |
| + PlatformSensorProvider* provider); |
| + |
| + mojom::ReportingMode GetReportingMode() override; |
| + // Can only be called once, the first time or after a StopSensor call. |
| + bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| + void StopSensor() override; |
| + |
| + protected: |
| + ~PlatformSensorAccelerometerMac() override; |
| + bool CheckSensorConfiguration( |
| + const PlatformSensorConfiguration& configuration) override; |
| + PlatformSensorConfiguration GetDefaultConfiguration() override; |
| + |
| + private: |
| + void PollForData(); |
| + |
| + std::unique_ptr<SuddenMotionSensor> sudden_motion_sensor_; |
| + |
| + SensorReading reading_; |
| + |
| + // Repeating timer for data polling. |
| + base::RepeatingTimer timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PlatformSensorAccelerometerMac); |
| +}; |
| + |
| +} // namespace device |
| + |
| +#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ACCELEROMETER_MAC_H_ |