| 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/usb/usb_service_linux.h" | 5 #include "device/usb/usb_service_linux.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 void UsbServiceLinux::DeviceReady(scoped_refptr<UsbDeviceLinux> device, | 244 void UsbServiceLinux::DeviceReady(scoped_refptr<UsbDeviceLinux> device, |
| 245 bool success) { | 245 bool success) { |
| 246 DCHECK(CalledOnValidThread()); | 246 DCHECK(CalledOnValidThread()); |
| 247 | 247 |
| 248 bool enumeration_became_ready = false; | 248 bool enumeration_became_ready = false; |
| 249 if (!enumeration_ready()) { | 249 if (!enumeration_ready()) { |
| 250 DCHECK_GT(first_enumeration_countdown_, 0u); | 250 DCHECK_GT(first_enumeration_countdown_, 0u); |
| 251 if (--first_enumeration_countdown_ == 0) | 251 first_enumeration_countdown_--; |
| 252 if (enumeration_ready()) |
| 252 enumeration_became_ready = true; | 253 enumeration_became_ready = true; |
| 253 } | 254 } |
| 254 | 255 |
| 255 // If |device| was disconnected while descriptors were being read then it | 256 // If |device| was disconnected while descriptors were being read then it |
| 256 // will have been removed from |devices_by_path_|. | 257 // will have been removed from |devices_by_path_|. |
| 257 auto it = devices_by_path_.find(device->device_path()); | 258 auto it = devices_by_path_.find(device->device_path()); |
| 258 if (it == devices_by_path_.end()) { | 259 if (it == devices_by_path_.end()) { |
| 259 success = false; | 260 success = false; |
| 260 } else if (success) { | 261 } else if (success) { |
| 261 DCHECK(!base::ContainsKey(devices(), device->guid())); | 262 DCHECK(!base::ContainsKey(devices(), device->guid())); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 result.reserve(devices().size()); | 313 result.reserve(devices().size()); |
| 313 for (const auto& map_entry : devices()) | 314 for (const auto& map_entry : devices()) |
| 314 result.push_back(map_entry.second); | 315 result.push_back(map_entry.second); |
| 315 for (const auto& callback : enumeration_callbacks_) | 316 for (const auto& callback : enumeration_callbacks_) |
| 316 callback.Run(result); | 317 callback.Run(result); |
| 317 enumeration_callbacks_.clear(); | 318 enumeration_callbacks_.clear(); |
| 318 } | 319 } |
| 319 } | 320 } |
| 320 | 321 |
| 321 } // namespace device | 322 } // namespace device |
| OLD | NEW |