| 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 3243636775cef146e6edd103933ced25ff4c15ad..c18d0543d0cd4fde62696e7a18b5c26cf6c05d0b 100644
|
| --- a/third_party/WebKit/Source/modules/sensor/SensorProxy.h
|
| +++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.h
|
| @@ -21,6 +21,7 @@ namespace blink {
|
| class SensorProviderProxy;
|
| class SensorReading;
|
| class SensorReadingFactory;
|
| +class SensorFrameRequestCallback;
|
|
|
| // This class wraps 'Sensor' mojo interface and used by multiple
|
| // JS sensor instances of the same type (within a single frame).
|
| @@ -38,7 +39,12 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
|
| // methods can be called.
|
| virtual void onSensorInitialized() {}
|
| // Platfrom sensort reading has changed.
|
| - virtual void onSensorReadingChanged() {}
|
| + // |timestamp| Reference timestamp in seconds of the moment when
|
| + // sensor reading was updated from the buffer.
|
| + // Note: |timestamp| values are only used to calculate elapsed time
|
| + // between shared buffer readings. These values *do not* correspond
|
| + // to sensor reading timestamps which are obtained on platform side.
|
| + virtual void onSensorReadingChanged(double timestamp) {}
|
| // An error has occurred.
|
| virtual void onSensorError(ExceptionCode,
|
| const String& sanitizedMessage,
|
| @@ -83,16 +89,17 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
|
|
|
| private:
|
| friend class SensorProviderProxy;
|
| + friend class SensorFrameRequestCallback;
|
| SensorProxy(device::mojom::blink::SensorType,
|
| SensorProviderProxy*,
|
| - Page*,
|
| + Document*,
|
| std::unique_ptr<SensorReadingFactory>);
|
| - // Returns true if this instance is using polling timer to
|
| + // Returns true if this instance is using rAF to
|
| // periodically fetch reading data from shared buffer.
|
| - bool usesPollingTimer() const;
|
| + bool isPollingBuffer() const;
|
|
|
| // Updates sensor reading from shared buffer.
|
| - void updateSensorReading();
|
| + void updateSensorReading(double timestamp);
|
|
|
| // device::mojom::blink::SensorClient overrides.
|
| void RaiseError() override;
|
| @@ -116,8 +123,8 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
|
| void onRemoveConfigurationCompleted(double frequency, bool result);
|
|
|
| bool tryReadFromBuffer(device::SensorReading& result);
|
| - void updatePollingStatus();
|
| - void onTimerFired(TimerBase*);
|
| + bool processRAFQueue();
|
| + void onAnimationFrame(double timestamp);
|
|
|
| device::mojom::blink::SensorType m_type;
|
| device::mojom::blink::ReportingMode m_mode;
|
| @@ -134,13 +141,16 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
|
| mojo::ScopedSharedBufferHandle m_sharedBufferHandle;
|
| mojo::ScopedSharedBufferMapping m_sharedBuffer;
|
| bool m_suspended;
|
| + Member<Document> m_document;
|
| Member<SensorReading> m_reading;
|
| std::unique_ptr<SensorReadingFactory> m_readingFactory;
|
| double m_maximumFrequency;
|
|
|
| // Used for continious reporting mode.
|
| - Timer<SensorProxy> m_timer;
|
| + Member<SensorFrameRequestCallback> m_rafCallback;
|
| + int m_rafCallbackId;
|
| WTF::Vector<double> m_frequenciesUsed;
|
| + double m_lastRafTimestamp;
|
|
|
| using ReadingBuffer = device::SensorReadingSharedBuffer;
|
| static_assert(
|
|
|