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

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

Issue 2121313002: [sensors] Generic Sensors Framework blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sensors_mojo_interfaces
Patch Set: Comments from Tim. Removed the default sensor configuration management (to be added with a separate… Created 4 years, 3 months 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/heap/Handle.h"
10 #include "wtf/Functional.h"
11
12 namespace blink {
13
14 // This class provides different polling behaviour depending on
15 // the given 'ReportingMode':
16 // - for 'CONTINUOUS' mode the polling function is invoked periodically
17 // with the given frequency (on timer event).
18 // - for 'ONCHANGE' mode the polling function is invoked only after client
19 // calls 'onSensorReadingChanged()' however considering the given frequency:
20 // guarantied not to be called more often than expected.
timvolodine 2016/09/05 23:22:40 ->guaranteed
21 class SensorPollingStrategy : public GarbageCollectedFinalized<SensorPollingStra tegy> {
haraken 2016/09/06 05:04:28 There's no benefit in putting this class on Garbag
Mikhail 2016/09/06 07:13:58 right, I'll change that
22 public:
23 static SensorPollingStrategy* create(double frequency, std::unique_ptr<Funct ion<void()>> pollFunc, device::mojom::blink::ReportingMode);
24
25 virtual void onSensorReadingChanged() {}
26 virtual void startPolling() = 0;
27 virtual void stopPolling() = 0;
28
29 virtual ~SensorPollingStrategy() {}
30
31 DEFINE_INLINE_VIRTUAL_TRACE() {}
32
33 protected:
34 SensorPollingStrategy(double frequency, std::unique_ptr<Function<void()>>);
35 double m_frequency;
36 std::unique_ptr<Function<void()>> m_pollFunc;
37 };
38
39 } // namespace blink
40
41 #endif // SensorPollingStrategy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698