Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/SensorPollingStrategy.h

Issue 2503853002: [Sensors] Improvements in fetching reading for sensors with continuous reporting mode (Closed)
Patch Set: Fixed assertion hit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SensorPollingStrategy_h
6 #define SensorPollingStrategy_h
7
8 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h"
9 #include "platform/Timer.h"
10 #include "platform/heap/Handle.h"
11 #include "wtf/Functional.h"
12
13 namespace blink {
14
15 // This class provides different polling behaviour depending on
16 // the given 'ReportingMode':
17 // - for 'CONTINUOUS' mode the polling function is invoked periodically
18 // with the given polling period (on timer event).
19 // - for 'ONCHANGE' mode the polling function is invoked only after client
20 // calls 'onSensorReadingChanged()' however considering the given polling
21 // period: guaranteed not to be called more often than expected.
22 class SensorPollingStrategy {
23 public:
24 static std::unique_ptr<SensorPollingStrategy> create(
25 double pollingPeriod,
26 std::unique_ptr<Function<void()>> pollFunc,
27 device::mojom::blink::ReportingMode);
28
29 virtual void onSensorReadingChanged() {}
30 virtual void startPolling() = 0;
31 virtual void stopPolling() = 0;
32
33 virtual ~SensorPollingStrategy();
34
35 protected:
36 SensorPollingStrategy(double pollingPeriod,
37 std::unique_ptr<Function<void()>>);
38 virtual void pollForData(TimerBase*) = 0;
39
40 double m_pollingPeriod;
41 std::unique_ptr<Function<void()>> m_pollFunc;
42 Timer<SensorPollingStrategy> m_timer;
43 };
44
45 } // namespace blink
46
47 #endif // SensorPollingStrategy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698