| Index: device/generic_sensor/platform_sensor.h
|
| diff --git a/device/generic_sensor/platform_sensor.h b/device/generic_sensor/platform_sensor.h
|
| index 0485fc6861fcc2bd68dbcd30970dee2c1ecc8113..2ec1d5200195c3660a41b3c0c0416de5ba8da205 100644
|
| --- a/device/generic_sensor/platform_sensor.h
|
| +++ b/device/generic_sensor/platform_sensor.h
|
| @@ -12,6 +12,7 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/observer_list.h"
|
| +#include "device/base/synchronization/shared_memory_seqlock_buffer.h"
|
| #include "device/generic_sensor/public/interfaces/sensor.mojom.h"
|
| #include "mojo/public/cpp/system/buffer.h"
|
|
|
| @@ -50,6 +51,12 @@ class PlatformSensor : public base::RefCountedThreadSafe<PlatformSensor> {
|
| void RemoveClient(Client*);
|
|
|
| protected:
|
| + using ReadingBuffer = SharedMemorySeqLockBuffer<mojom::SensorReading>;
|
| +
|
| + public:
|
| + static const size_t kReadingBufferSize = sizeof(ReadingBuffer);
|
| +
|
| + protected:
|
| virtual ~PlatformSensor();
|
| PlatformSensor(mojom::SensorType type,
|
| mojo::ScopedSharedBufferMapping mapping,
|
| @@ -64,17 +71,19 @@ class PlatformSensor : public base::RefCountedThreadSafe<PlatformSensor> {
|
| virtual bool CheckSensorConfiguration(
|
| const PlatformSensorConfiguration& configuration) = 0;
|
|
|
| + // Updates shared buffer with new sensor reading data.
|
| + // Note: this method is thread-safe.
|
| + void UpdateSensorReading(const mojom::SensorReading& reading);
|
| +
|
| void NotifySensorReadingChanged();
|
| void NotifySensorError();
|
|
|
| - mojo::ScopedSharedBufferMapping shared_buffer_mapping_;
|
| -
|
| // For testing purposes.
|
| const ConfigMap& config_map() const { return config_map_; }
|
|
|
| private:
|
| friend class base::RefCountedThreadSafe<PlatformSensor>;
|
| -
|
| + mojo::ScopedSharedBufferMapping shared_buffer_mapping_;
|
| mojom::SensorType type_;
|
| base::ObserverList<Client, true> clients_;
|
| ConfigMap config_map_;
|
|
|