| 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 05c7c446b6f7d8a58ec576cd661ee3a616593ddb..82ded40bbe4e5d6aa2c7ce714e22e4677859ada8 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;
|
| @@ -88,7 +93,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;
|
| @@ -104,8 +109,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) ==
|
|
|