Index: device/generic_sensor/platform_sensor_reader_linux.h |
diff --git a/device/generic_sensor/platform_sensor_reader_linux.h b/device/generic_sensor/platform_sensor_reader_linux.h |
index 755ad2671af5f80937cd470d8f3ac8851d64f733..b2a224461c044ed599f647545813df0496173924 100644 |
--- a/device/generic_sensor/platform_sensor_reader_linux.h |
+++ b/device/generic_sensor/platform_sensor_reader_linux.h |
@@ -19,29 +19,33 @@ class PlatformSensorConfiguration; |
struct SensorInfoLinux; |
// A generic reader class that can be implemented with two different strategies: |
-// polling and on trigger. |
+// polling and on trigger. All methods except SetPlatformSensorLinux |
+// are not safe and must be called on the same thread which this reader belongs |
+// to. |
class SensorReader { |
public: |
// Creates a new instance of SensorReader. At the moment, only polling |
// reader is supported. |
static std::unique_ptr<SensorReader> Create( |
const SensorInfoLinux* sensor_device, |
- PlatformSensorLinux* sensor, |
- scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
virtual ~SensorReader(); |
// Starts fetching data based on strategy this reader has chosen. |
// Only polling strategy is supported at the moment. Thread safe. |
- virtual bool StartFetchingData( |
+ virtual void StartFetchingData( |
const PlatformSensorConfiguration& configuration) = 0; |
// Stops fetching data. Thread safe. |
virtual void StopFetchingData() = 0; |
+ // Sets sensor that this reader reports to. Must be called only once. |
+ // Thread safe. |
gab
2016/12/14 14:52:21
From the implementation this isn't "thread-safe",
|
+ void SetPlatformSensorLinux(PlatformSensorLinux* sensor); |
+ |
protected: |
- SensorReader(PlatformSensorLinux* sensor, |
- scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner); |
+ SensorReader(scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
// Notifies |sensor_| about an error. |
void NotifyReadError(); |