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 #include "device/generic_sensor/platform_sensor_provider_linux.h" | 5 #include "device/generic_sensor/platform_sensor_provider_linux.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/task_runner_util.h" |
8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
9 #include "device/generic_sensor/linux/sensor_data_linux.h" | 10 #include "device/generic_sensor/linux/sensor_data_linux.h" |
10 #include "device/generic_sensor/platform_sensor_linux.h" | 11 #include "device/generic_sensor/platform_sensor_linux.h" |
| 12 #include "device/generic_sensor/platform_sensor_reader_linux.h" |
11 | 13 |
12 namespace device { | 14 namespace device { |
13 | 15 |
14 // static | 16 // static |
15 PlatformSensorProviderLinux* PlatformSensorProviderLinux::GetInstance() { | 17 PlatformSensorProviderLinux* PlatformSensorProviderLinux::GetInstance() { |
16 return base::Singleton< | 18 return base::Singleton< |
17 PlatformSensorProviderLinux, | 19 PlatformSensorProviderLinux, |
18 base::LeakySingletonTraits<PlatformSensorProviderLinux>>::get(); | 20 base::LeakySingletonTraits<PlatformSensorProviderLinux>>::get(); |
19 } | 21 } |
20 | 22 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 callback.Run(nullptr); | 54 callback.Run(nullptr); |
53 return; | 55 return; |
54 } | 56 } |
55 SensorDeviceFound(type, std::move(mapping), callback, sensor_device); | 57 SensorDeviceFound(type, std::move(mapping), callback, sensor_device); |
56 } | 58 } |
57 | 59 |
58 void PlatformSensorProviderLinux::SensorDeviceFound( | 60 void PlatformSensorProviderLinux::SensorDeviceFound( |
59 mojom::SensorType type, | 61 mojom::SensorType type, |
60 mojo::ScopedSharedBufferMapping mapping, | 62 mojo::ScopedSharedBufferMapping mapping, |
61 const PlatformSensorProviderBase::CreateSensorCallback& callback, | 63 const PlatformSensorProviderBase::CreateSensorCallback& callback, |
62 SensorInfoLinux* sensor_device) { | 64 const SensorInfoLinux* sensor_device) { |
63 DCHECK(CalledOnValidThread()); | 65 DCHECK(CalledOnValidThread()); |
| 66 DCHECK(sensor_device); |
64 | 67 |
65 if (!StartPollingThread()) { | 68 if (!StartPollingThread()) { |
66 callback.Run(nullptr); | 69 callback.Run(nullptr); |
67 return; | 70 return; |
68 } | 71 } |
69 | 72 |
70 scoped_refptr<PlatformSensorLinux> sensor = | 73 scoped_refptr<PlatformSensorLinux> sensor = |
71 new PlatformSensorLinux(type, std::move(mapping), this, sensor_device, | 74 new PlatformSensorLinux(type, std::move(mapping), this, sensor_device, |
72 polling_thread_->task_runner()); | 75 polling_thread_->task_runner()); |
73 callback.Run(sensor); | 76 callback.Run(sensor); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 mojom::SensorType type, | 204 mojom::SensorType type, |
202 const std::string& device_node) { | 205 const std::string& device_node) { |
203 DCHECK(CalledOnValidThread()); | 206 DCHECK(CalledOnValidThread()); |
204 auto it = sensor_devices_by_type_.find(type); | 207 auto it = sensor_devices_by_type_.find(type); |
205 if (it != sensor_devices_by_type_.end() && | 208 if (it != sensor_devices_by_type_.end() && |
206 it->second->device_node == device_node) | 209 it->second->device_node == device_node) |
207 sensor_devices_by_type_.erase(it); | 210 sensor_devices_by_type_.erase(it); |
208 } | 211 } |
209 | 212 |
210 } // namespace device | 213 } // namespace device |
OLD | NEW |