Chromium Code Reviews| 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_PLATFORM_SENSOR_READER_LINUX_H_ | |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_LINUX_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "device/generic_sensor/generic_sensor_export.h" | |
| 10 | |
| 11 namespace base { | |
| 12 class SingleThreadTaskRunner; | |
| 13 } | |
| 14 | |
| 15 namespace device { | |
| 16 | |
| 17 class PlatformSensorLinux; | |
| 18 class PlatformSensorConfiguration; | |
| 19 struct SensorInfoLinux; | |
| 20 | |
| 21 // A generic reader class that can be implemented with two different strategies: | |
| 22 // polling and on trigger. | |
| 23 class SensorReader { | |
| 24 public: | |
| 25 // Creates a new instance of SensorReader. At the moment, only polling | |
| 26 // reader is supported. | |
| 27 static std::unique_ptr<SensorReader> Create( | |
| 28 SensorInfoLinux* sensor_device, | |
|
Reilly Grant (use Gerrit)
2016/12/08 02:31:15
This should probably be const.
maksims (do not use this acc)
2016/12/08 18:39:18
Done.
| |
| 29 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); | |
| 30 | |
| 31 virtual ~SensorReader(); | |
| 32 | |
| 33 // Starts fetching data based on strategy this reader has chosen. | |
| 34 // Only polling strategy is supported at the moment. Thread safe. | |
| 35 virtual bool StartFetchingData( | |
| 36 const PlatformSensorConfiguration& configuration, | |
| 37 PlatformSensorLinux* sensor) = 0; | |
| 38 | |
| 39 // Stops fetching data. Thread safe. | |
| 40 virtual void StopFetchingData() = 0; | |
| 41 | |
| 42 protected: | |
| 43 SensorReader(scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner); | |
| 44 | |
| 45 // Notifies |sensor_| about an error. | |
| 46 void NotifyReadError(); | |
| 47 | |
| 48 // Non-owned pointer to a sensor that created this reader. | |
| 49 PlatformSensorLinux* sensor_; | |
| 50 | |
| 51 // A task runner that is used to poll data. | |
| 52 scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner_; | |
| 53 | |
| 54 // A task runner that belongs to a thread this reader is created on. | |
| 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(SensorReader); | |
| 58 }; | |
| 59 | |
| 60 } // namespace device | |
| 61 | |
| 62 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_LINUX_H_ | |
| OLD | NEW |