Index: third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h |
diff --git a/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h b/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h |
index 086a132794de74bf69e7f2eaaf79d1d5cd8737bb..c92839f646daf04e74603a5582c70f5f351e6dd6 100644 |
--- a/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h |
+++ b/third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h |
@@ -6,6 +6,7 @@ |
#define SensorPollingStrategy_h |
#include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" |
+#include "platform/Timer.h" |
#include "platform/heap/Handle.h" |
#include "wtf/Functional.h" |
@@ -14,19 +15,27 @@ namespace blink { |
// This class provides different polling behaviour depending on |
// the given 'ReportingMode': |
// - for 'CONTINUOUS' mode the polling function is invoked periodically |
-// with the given frequency (on timer event). |
+// with the given polling period (on timer event). |
// - for 'ONCHANGE' mode the polling function is invoked only after client |
-// calls 'onSensorReadingChanged()' however considering the given frequency: |
+// calls 'onSensorReadingChanged()' however considering the given polling period: |
// guaranteed not to be called more often than expected. |
class SensorPollingStrategy { |
public: |
- static std::unique_ptr<SensorPollingStrategy> create(double frequency, std::unique_ptr<Function<void()>> pollFunc, device::mojom::blink::ReportingMode); |
+ static std::unique_ptr<SensorPollingStrategy> create(double pollingPeriod, std::unique_ptr<Function<void()>> pollFunc, device::mojom::blink::ReportingMode); |
virtual void onSensorReadingChanged() {} |
virtual void startPolling() = 0; |
virtual void stopPolling() = 0; |
- virtual ~SensorPollingStrategy() {} |
+ virtual ~SensorPollingStrategy(); |
+ |
+protected: |
+ SensorPollingStrategy(double pollingPeriod, std::unique_ptr<Function<void()>>); |
+ virtual void pollForData(TimerBase*) = 0; |
+ |
+ double m_pollingPeriod; |
+ std::unique_ptr<Function<void()>> m_pollFunc; |
+ Timer<SensorPollingStrategy> m_timer; |
}; |
} // namespace blink |