| 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_PLATFORM_SENSOR_LINUX_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ | 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ |
| 7 | 7 |
| 8 #include "device/generic_sensor/platform_sensor.h" | 8 #include "device/generic_sensor/platform_sensor.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 class SingleThreadTaskRunner; | 11 class SingleThreadTaskRunner; |
| 12 } | 12 } |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 class SensorReader; | 16 class SensorReader; |
| 17 struct SensorInfoLinux; | 17 struct SensorInfoLinux; |
| 18 | 18 |
| 19 class PlatformSensorLinux : public PlatformSensor { | 19 class PlatformSensorLinux : public PlatformSensor { |
| 20 public: | 20 public: |
| 21 PlatformSensorLinux( | 21 PlatformSensorLinux( |
| 22 mojom::SensorType type, | 22 mojom::SensorType type, |
| 23 mojo::ScopedSharedBufferMapping mapping, | 23 mojo::ScopedSharedBufferMapping mapping, |
| 24 PlatformSensorProvider* provider, | 24 PlatformSensorProvider* provider, |
| 25 const SensorInfoLinux* sensor_device, | 25 const SensorInfoLinux* sensor_device, |
| 26 std::unique_ptr<SensorReader> sensor_reader, |
| 26 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); | 27 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); |
| 27 | 28 |
| 28 mojom::ReportingMode GetReportingMode() override; | 29 mojom::ReportingMode GetReportingMode() override; |
| 29 | 30 |
| 30 // Called by a sensor reader. Takes new readings. | 31 // Called by a sensor reader. Takes new readings. |
| 31 void UpdatePlatformSensorReading(SensorReading reading); | 32 void UpdatePlatformSensorReading(SensorReading reading); |
| 32 | 33 |
| 33 // Called by a sensor reader if an error occurs. | 34 // Called by a sensor reader if an error occurs. |
| 34 void NotifyPlatformSensorError(); | 35 void NotifyPlatformSensorError(); |
| 35 | 36 |
| 36 protected: | 37 protected: |
| 37 ~PlatformSensorLinux() override; | 38 ~PlatformSensorLinux() override; |
| 38 bool StartSensor(const PlatformSensorConfiguration& configuration) override; | 39 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 39 void StopSensor() override; | 40 void StopSensor() override; |
| 40 bool CheckSensorConfiguration( | 41 bool CheckSensorConfiguration( |
| 41 const PlatformSensorConfiguration& configuration) override; | 42 const PlatformSensorConfiguration& configuration) override; |
| 42 PlatformSensorConfiguration GetDefaultConfiguration() override; | 43 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 const PlatformSensorConfiguration default_configuration_; | 46 const PlatformSensorConfiguration default_configuration_; |
| 46 const mojom::ReportingMode reporting_mode_; | 47 const mojom::ReportingMode reporting_mode_; |
| 47 | 48 |
| 49 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_; |
| 50 |
| 48 // A sensor reader that reads values from sensor files | 51 // A sensor reader that reads values from sensor files |
| 49 // and stores them to a SensorReading structure. | 52 // and stores them to a SensorReading structure. |
| 50 std::unique_ptr<SensorReader> sensor_reader_; | 53 std::unique_ptr<SensorReader> sensor_reader_; |
| 51 | 54 |
| 52 // Stores previously read values that are used to | 55 // Stores previously read values that are used to |
| 53 // determine whether the recent values are changed | 56 // determine whether the recent values are changed |
| 54 // and IPC can be notified that updates are available. | 57 // and IPC can be notified that updates are available. |
| 55 SensorReading old_values_; | 58 SensorReading old_values_; |
| 56 | 59 |
| 57 base::WeakPtrFactory<PlatformSensorLinux> weak_factory_; | 60 base::WeakPtrFactory<PlatformSensorLinux> weak_factory_; |
| 58 | 61 |
| 59 DISALLOW_COPY_AND_ASSIGN(PlatformSensorLinux); | 62 DISALLOW_COPY_AND_ASSIGN(PlatformSensorLinux); |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace device | 65 } // namespace device |
| 63 | 66 |
| 64 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ | 67 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ |
| OLD | NEW |