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