Chromium Code Reviews| 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..410642f2c8fe094c66747fdadbda5ddcd1d9bba5 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; |
| @@ -117,7 +124,7 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>, |
| bool tryReadFromBuffer(device::SensorReading& result); |
| void updatePollingStatus(); |
| - void onTimerFired(TimerBase*); |
| + 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; |
| + WeakMember<Document> m_document; |
|
haraken
2016/12/06 02:38:30
Is there any reason you want to make it a WeakMemb
|
| 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( |