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

Unified Diff: device/generic_sensor/platform_sensor.h

Issue 2395853003: [Sensors] Improvements in shared buffer managing (Closed)
Patch Set: Test compilation fix + comment from Ken Created 4 years, 2 months 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
« no previous file with comments | « device/generic_sensor/fake_platform_sensor_provider.cc ('k') | device/generic_sensor/platform_sensor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9a40e3f5531ec518a417a75f67b4c43c01f7a1f1 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/generic_sensor/public/cpp/sensor_reading.h"
#include "device/generic_sensor/public/interfaces/sensor.mojom.h"
#include "mojo/public/cpp/system/buffer.h"
@@ -56,6 +57,7 @@ class PlatformSensor : public base::RefCountedThreadSafe<PlatformSensor> {
PlatformSensorProvider* provider);
using ConfigMap = std::map<Client*, std::list<PlatformSensorConfiguration>>;
+ using ReadingBuffer = SensorReadingSharedBuffer;
virtual bool UpdateSensorInternal(const ConfigMap& configurations);
virtual bool StartSensor(
@@ -64,17 +66,24 @@ 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 SensorReading& reading, bool notify_clients);
+
void NotifySensorReadingChanged();
void NotifySensorError();
- mojo::ScopedSharedBufferMapping shared_buffer_mapping_;
-
// For testing purposes.
const ConfigMap& config_map() const { return config_map_; }
+ // Task runner that is used by mojo objects for the IPC.
+ // If platfrom sensor events are processed on a different
+ // thread, notifications are forwarded to |task_runner_|.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
private:
friend class base::RefCountedThreadSafe<PlatformSensor>;
-
+ const mojo::ScopedSharedBufferMapping shared_buffer_mapping_;
mojom::SensorType type_;
base::ObserverList<Client, true> clients_;
ConfigMap config_map_;
« no previous file with comments | « device/generic_sensor/fake_platform_sensor_provider.cc ('k') | device/generic_sensor/platform_sensor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698