OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_POLLING_PLATFORM_SENSOR_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_POLLING_PLATFORM_SENSOR_H_ |
| 7 |
| 8 #include "base/timer/timer.h" |
| 9 #include "device/generic_sensor/platform_sensor.h" |
| 10 |
| 11 namespace base { |
| 12 class SingleThreadTaskRunner; |
| 13 } |
| 14 |
| 15 namespace device { |
| 16 |
| 17 class PollingPlatformSensor : public PlatformSensor { |
| 18 public: |
| 19 PollingPlatformSensor( |
| 20 mojom::SensorType type, |
| 21 mojo::ScopedSharedBufferMapping mapping, |
| 22 PlatformSensorProvider* provider, |
| 23 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); |
| 24 |
| 25 virtual void UpdateReading() = 0; |
| 26 |
| 27 protected: |
| 28 ~PollingPlatformSensor() override; |
| 29 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 30 void StopSensor() override; |
| 31 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_; |
| 32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 33 base::RepeatingTimer timer_; |
| 34 |
| 35 private: |
| 36 void BeginPoll(const PlatformSensorConfiguration& configuration); |
| 37 void StopPoll(); |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(PollingPlatformSensor); |
| 40 }; |
| 41 |
| 42 } // namespace device |
| 43 |
| 44 #endif // DEVICE_GENERIC_SENSOR_POLLING_PLATFORM_SENSOR_H_ |
OLD | NEW |