| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ | 6 #define DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "device/generic_sensor/platform_sensor.h" | 9 #include "device/generic_sensor/platform_sensor.h" |
| 10 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" | 10 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 | 12 |
| 13 namespace device { | 13 namespace device { |
| 14 | 14 |
| 15 // Implementation of Sensor mojo interface. | 15 // Implementation of Sensor mojo interface. |
| 16 // Instances of this class are created by SensorProviderImpl. | 16 // Instances of this class are created by SensorProviderImpl. |
| 17 class SensorImpl final : public mojom::Sensor, public PlatformSensor::Client { | 17 class SensorImpl final : public mojom::Sensor, public PlatformSensor::Client { |
| 18 public: | 18 public: |
| 19 SensorImpl(mojo::InterfaceRequest<mojom::Sensor> request, | 19 SensorImpl(mojo::InterfaceRequest<mojom::Sensor> request, |
| 20 scoped_refptr<PlatformSensor> sensor); | 20 scoped_refptr<PlatformSensor> sensor); |
| 21 ~SensorImpl() override; | 21 ~SensorImpl() override; |
| 22 | 22 |
| 23 mojom::SensorClientRequest GetClient(); | 23 mojom::SensorClientRequest GetClient(); |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 // Sensor implementation. | 26 // Sensor implementation. |
| 27 void AddConfiguration(const PlatformSensorConfiguration& configuration, | 27 void AddConfiguration(const PlatformSensorConfiguration& configuration, |
| 28 const AddConfigurationCallback& callback) override; | 28 const AddConfigurationCallback& callback) override; |
| 29 void GetDefaultConfiguration( |
| 30 const GetDefaultConfigurationCallback& callback) override; |
| 29 void RemoveConfiguration( | 31 void RemoveConfiguration( |
| 30 const PlatformSensorConfiguration& configuration, | 32 const PlatformSensorConfiguration& configuration, |
| 31 const RemoveConfigurationCallback& callback) override; | 33 const RemoveConfigurationCallback& callback) override; |
| 32 void Suspend() override; | 34 void Suspend() override; |
| 33 void Resume() override; | 35 void Resume() override; |
| 34 | 36 |
| 35 // device::Sensor::Client implementation. | 37 // device::Sensor::Client implementation. |
| 36 void OnSensorReadingChanged() override; | 38 void OnSensorReadingChanged() override; |
| 37 void OnSensorError() override; | 39 void OnSensorError() override; |
| 38 bool IsNotificationSuspended() override; | 40 bool IsNotificationSuspended() override; |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 scoped_refptr<PlatformSensor> sensor_; | 43 scoped_refptr<PlatformSensor> sensor_; |
| 42 mojo::StrongBinding<Sensor> binding_; | 44 mojo::StrongBinding<Sensor> binding_; |
| 43 mojom::SensorClientPtr client_; | 45 mojom::SensorClientPtr client_; |
| 44 bool suspended_; | 46 bool suspended_; |
| 45 DISALLOW_COPY_AND_ASSIGN(SensorImpl); | 47 DISALLOW_COPY_AND_ASSIGN(SensorImpl); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // namespace device | 50 } // namespace device |
| 49 | 51 |
| 50 #endif // DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ | 52 #endif // DEVICE_GENERIC_SENSOR_SENSOR_IMPL_H_ |
| OLD | NEW |