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_LINUX_SENSOR_DEVICE_MANAGER_H_ | 5 #ifndef SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DEVICE_MANAGER_H_ |
6 #define DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DEVICE_MANAGER_H_ | 6 #define SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DEVICE_MANAGER_H_ |
7 | 7 |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 | 9 |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "device/base/device_monitor_linux.h" | 11 #include "device/base/device_monitor_linux.h" |
12 #include "device/generic_sensor/generic_sensor_export.h" | 12 #include "services/device/public/interfaces/sensor.mojom.h" |
13 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" | |
14 | 13 |
15 namespace device { | 14 namespace device { |
16 | 15 |
17 struct SensorInfoLinux; | 16 struct SensorInfoLinux; |
18 | 17 |
19 // This SensorDeviceManager uses LinuxDeviceMonitor to enumerate devices | 18 // This SensorDeviceManager uses LinuxDeviceMonitor to enumerate devices |
20 // and listen to "add/removed" events to notify |provider_| about | 19 // and listen to "add/removed" events to notify |provider_| about |
21 // added or removed iio devices. It has own cache to speed up an identification | 20 // added or removed iio devices. It has own cache to speed up an identification |
22 // process of removed devices. | 21 // process of removed devices. |
23 class DEVICE_GENERIC_SENSOR_EXPORT SensorDeviceManager | 22 class SensorDeviceManager : public DeviceMonitorLinux::Observer { |
24 : public DeviceMonitorLinux::Observer { | |
25 public: | 23 public: |
26 class Delegate { | 24 class Delegate { |
27 public: | 25 public: |
28 // Called when SensorDeviceManager has enumerated through all possible | 26 // Called when SensorDeviceManager has enumerated through all possible |
29 // iio udev devices. | 27 // iio udev devices. |
30 virtual void OnSensorNodesEnumerated() = 0; | 28 virtual void OnSensorNodesEnumerated() = 0; |
31 | 29 |
32 // Called after SensorDeviceManager has identified a udev device, which | 30 // Called after SensorDeviceManager has identified a udev device, which |
33 // belongs to "iio" subsystem. | 31 // belongs to "iio" subsystem. |
34 virtual void OnDeviceAdded(mojom::SensorType type, | 32 virtual void OnDeviceAdded(mojom::SensorType type, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 Delegate* delegate_; | 74 Delegate* delegate_; |
77 | 75 |
78 // A task runner, which |delegate_| lives on. | 76 // A task runner, which |delegate_| lives on. |
79 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
80 | 78 |
81 DISALLOW_COPY_AND_ASSIGN(SensorDeviceManager); | 79 DISALLOW_COPY_AND_ASSIGN(SensorDeviceManager); |
82 }; | 80 }; |
83 | 81 |
84 } // namespace device | 82 } // namespace device |
85 | 83 |
86 #endif // DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DEVICE_MANAGER_H_ | 84 #endif // SERVICES_DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DEVICE_MANAGER_H_ |
OLD | NEW |