| 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) ==
|
|
|