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 DEVICE_SENSOR_SENSOR_IMPL_H_ |
| 6 #define DEVICE_SENSOR_SENSOR_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "device/sensor/sensor.mojom.h" |
| 12 #include "device/sensor/sensor_export.h" |
| 13 #include "device/sensor/sensor_service.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 |
| 16 namespace device { |
| 17 |
| 18 class SensorImpl : public AmbientLightSensor { |
| 19 public: |
| 20 DEVICE_SENSOR_EXPORT static void Create( |
| 21 mojo::InterfaceRequest<AmbientLightSensor> request); |
| 22 |
| 23 private: |
| 24 typedef mojo::Callback<void(AmbientLightSensorReadingPtr)> |
| 25 SensorReadingCallback; |
| 26 |
| 27 explicit SensorImpl(mojo::InterfaceRequest<AmbientLightSensor> request); |
| 28 ~SensorImpl() override; |
| 29 |
| 30 // AmbientLightSensor interface methods. |
| 31 void QueryNextReading(const SensorReadingCallback& callback) override; |
| 32 void StartReading() override; |
| 33 void StopReading() override; |
| 34 |
| 35 void DidChange(const AmbientLightSensorReading& als_reading); |
| 36 void ReportReading(); |
| 37 |
| 38 mojo::StrongBinding<AmbientLightSensor> binding_; |
| 39 std::unique_ptr<SensorService::SensorUpdateSubscription> subscription_; |
| 40 SensorReadingCallback callback_; |
| 41 AmbientLightSensorReading reading_; |
| 42 bool reading_to_report_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(SensorImpl); |
| 45 }; |
| 46 |
| 47 } // namespace device |
| 48 |
| 49 #endif // DEVICE_SENSOR_SENSOR_IMPL_H_ |
OLD | NEW |