Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1606)

Unified Diff: device/generic_sensor/platform_sensor_reader_linux.h

Issue 2569763004: [sensors](Linux) Fix tsan data race in sensor reader (Closed)
Patch Set: change threading model. SensorReader now belongs to a polling thread Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
« no previous file with comments | « device/generic_sensor/platform_sensor_provider_linux.cc ('k') | device/generic_sensor/platform_sensor_reader_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698