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

Unified Diff: third_party/WebKit/Source/modules/sensor/SensorProxy.h

Issue 2472403002: [Sensors] Align sensor reading attribute implementation with the specification (Closed)
Patch Set: Comments from Tim Created 4 years, 1 month 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: third_party/WebKit/Source/modules/sensor/SensorProxy.h
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProxy.h b/third_party/WebKit/Source/modules/sensor/SensorProxy.h
index 942b0d7bad0a78bba1934509b17548160c6eb6cc..faf62de4966b148e868f342539482bb56d1af5f9 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProxy.h
+++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.h
@@ -16,6 +16,8 @@
namespace blink {
class SensorProviderProxy;
+class SensorReading;
+class SensorReadingFactory;
// This class wraps 'Sensor' mojo interface and used by multiple
// JS sensor instances of the same type (within a single frame).
@@ -61,20 +63,23 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
device::mojom::blink::SensorType type() const { return m_type; }
device::mojom::blink::ReportingMode reportingMode() const { return m_mode; }
- using Reading = device::SensorReading;
-
- const Reading& reading() const { return m_reading; }
+ // The |SensorReading| instance which is shared between sensor instances
+ // of the same type.
+ // Note: the returned value is reset after updateSensorReading() call.
+ SensorReading* sensorReading() const { return m_reading; }
const device::mojom::blink::SensorConfiguration* defaultConfig() const;
- // Updates internal reading from shared buffer.
- void updateInternalReading();
+ // Updates sensor reading from shared buffer.
+ void updateSensorReading();
DECLARE_VIRTUAL_TRACE();
private:
friend class SensorProviderProxy;
- SensorProxy(device::mojom::blink::SensorType, SensorProviderProxy*);
+ SensorProxy(device::mojom::blink::SensorType,
+ SensorProviderProxy*,
+ std::unique_ptr<SensorReadingFactory>);
// device::mojom::blink::SensorClient overrides.
void RaiseError() override;
@@ -89,7 +94,7 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
void onSensorCreated(device::mojom::blink::SensorInitParamsPtr,
device::mojom::blink::SensorClientRequest);
- bool tryReadFromBuffer();
+ bool tryReadFromBuffer(device::SensorReading& result);
device::mojom::blink::SensorType m_type;
device::mojom::blink::ReportingMode m_mode;
@@ -105,8 +110,10 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
State m_state;
mojo::ScopedSharedBufferHandle m_sharedBufferHandle;
mojo::ScopedSharedBufferMapping m_sharedBuffer;
- Reading m_reading;
bool m_suspended;
+ Member<SensorReading> m_reading;
+ std::unique_ptr<SensorReadingFactory> m_readingFactory;
+
using ReadingBuffer = device::SensorReadingSharedBuffer;
static_assert(
sizeof(ReadingBuffer) ==

Powered by Google App Engine
This is Rietveld 408576698