Index: device/generic_sensor/platform_sensor_iio.h |
diff --git a/device/generic_sensor/platform_sensor_iio.h b/device/generic_sensor/platform_sensor_iio.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9d40049babae6fee19185f503194ae3b8074b01e |
--- /dev/null |
+++ b/device/generic_sensor/platform_sensor_iio.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 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_IIO_H_ |
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_IIO_H_ |
+ |
+#include "device/generic_sensor/platform_sensor.h" |
+ |
+#include "base/timer/timer.h" |
+ |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
+namespace device { |
+ |
+class PlatformSensorIio : public PlatformSensor { |
+ public: |
+ PlatformSensorIio( |
+ mojom::SensorType type, |
+ mojo::ScopedSharedBufferMapping mapping, |
+ PlatformSensorProvider* provider, |
+ scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner); |
+ |
+ virtual void UpdateReading() = 0; |
Mikhail
2016/10/11 14:46:47
rename to 'PollForReadingData()'. Can it be protec
maksims (do not use this acc)
2016/10/14 12:31:45
Done.
|
+ |
+ protected: |
+ ~PlatformSensorIio() override; |
+ bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
+ void StopSensor() override; |
+ bool CheckSensorConfiguration( |
+ const PlatformSensorConfiguration& configuration) override; |
+ |
+ void OnSensorReadFailed(); |
+ |
+ // Task runner that is used to poll sensor data from |
+ // sensor files. |
+ scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_; |
+ |
+ private: |
+ void BeginPoll(const PlatformSensorConfiguration& configuration); |
+ void StopPoll(); |
+ void OnStop(); |
+ |
+ // Owned timer to be deleted on polling thread. |
+ base::RepeatingTimer* timer_; |
+ |
+ base::WeakPtrFactory<PlatformSensorIio> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorIio); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_IIO_H_ |