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

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

Issue 2551223003: [Sensors] Align sensor reading updates and 'onchange' notification with rAF. (Closed)
Patch Set: Created 4 years 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 SensorUpdateNotifier_h
6 #define SensorUpdateNotifier_h
7
8 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h"
9 #include "wtf/Functional.h"
10
11 namespace blink {
12
13 // This class encapsulates sensor reading update notification logic:
14 // the callback is invoked after client calls 'onSensorReadingChanged()'
15 // however considering the given sample frequency.
16 class SensorUpdateNotifier {
17 public:
18 static std::unique_ptr<SensorUpdateNotifier> create(
19 double frequency,
20 std::unique_ptr<Function<void()>>,
21 device::mojom::blink::ReportingMode);
22
23 // Please see SensorProxy::Observer comments explaining
24 // the |timestamp| argument.
25 virtual void onSensorReadingChanged(double timestamp) = 0;
26 virtual void cancelPendingNotifications() = 0;
27 virtual ~SensorUpdateNotifier() {}
28
29 protected:
30 SensorUpdateNotifier(double period, std::unique_ptr<Function<void()>>);
31
32 double m_period;
33 std::unique_ptr<Function<void()>> m_func;
34 double m_lastTimestamp;
35 };
36
37 } // namespace blink
38
39 #endif // SensorUpdateNotifier_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698