OLD | NEW |
(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 |
OLD | NEW |