| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_impl.h" | 5 #include "device/usb/usb_service_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| 217 | 217 |
| 218 UsbServiceImpl::UsbServiceImpl() | 218 UsbServiceImpl::UsbServiceImpl() |
| 219 : UsbService(nullptr), | 219 : UsbService(nullptr), |
| 220 #if defined(OS_WIN) | 220 #if defined(OS_WIN) |
| 221 device_observer_(this), | 221 device_observer_(this), |
| 222 #endif | 222 #endif |
| 223 weak_factory_(this) { | 223 weak_factory_(this) { |
| 224 base::PostTaskWithTraits( | 224 base::PostTaskWithTraits( |
| 225 FROM_HERE, | 225 FROM_HERE, kBlockingTaskTraits, |
| 226 {base::MayBlock(), base::TaskPriority::USER_VISIBLE, | |
| 227 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, | |
| 228 base::Bind(&InitializeUsbContextOnBlockingThread, task_runner(), | 226 base::Bind(&InitializeUsbContextOnBlockingThread, task_runner(), |
| 229 base::Bind(&UsbServiceImpl::OnUsbContext, | 227 base::Bind(&UsbServiceImpl::OnUsbContext, |
| 230 weak_factory_.GetWeakPtr()))); | 228 weak_factory_.GetWeakPtr()))); |
| 231 } | 229 } |
| 232 | 230 |
| 233 UsbServiceImpl::~UsbServiceImpl() { | 231 UsbServiceImpl::~UsbServiceImpl() { |
| 234 if (hotplug_enabled_) | 232 if (hotplug_enabled_) |
| 235 libusb_hotplug_deregister_callback(context_->context(), hotplug_handle_); | 233 libusb_hotplug_deregister_callback(context_->context(), hotplug_handle_); |
| 236 for (auto* platform_device : ignored_devices_) | 234 for (auto* platform_device : ignored_devices_) |
| 237 libusb_unref_device(platform_device); | 235 libusb_unref_device(platform_device); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 315 |
| 318 enumeration_in_progress_ = true; | 316 enumeration_in_progress_ = true; |
| 319 DCHECK(devices_being_enumerated_.empty()); | 317 DCHECK(devices_being_enumerated_.empty()); |
| 320 | 318 |
| 321 std::string device_path; | 319 std::string device_path; |
| 322 if (!pending_path_enumerations_.empty()) { | 320 if (!pending_path_enumerations_.empty()) { |
| 323 device_path = pending_path_enumerations_.front(); | 321 device_path = pending_path_enumerations_.front(); |
| 324 pending_path_enumerations_.pop(); | 322 pending_path_enumerations_.pop(); |
| 325 } | 323 } |
| 326 | 324 |
| 327 base::PostTaskWithTraits(FROM_HERE, | 325 base::PostTaskWithTraits(FROM_HERE, kBlockingTaskTraits, |
| 328 {base::MayBlock(), base::TaskPriority::USER_VISIBLE, | |
| 329 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, | |
| 330 base::Bind(&GetDeviceListOnBlockingThread, | 326 base::Bind(&GetDeviceListOnBlockingThread, |
| 331 device_path, context_, task_runner(), | 327 device_path, context_, task_runner(), |
| 332 base::Bind(&UsbServiceImpl::OnDeviceList, | 328 base::Bind(&UsbServiceImpl::OnDeviceList, |
| 333 weak_factory_.GetWeakPtr()))); | 329 weak_factory_.GetWeakPtr()))); |
| 334 } | 330 } |
| 335 | 331 |
| 336 void UsbServiceImpl::OnDeviceList(libusb_device** platform_devices, | 332 void UsbServiceImpl::OnDeviceList(libusb_device** platform_devices, |
| 337 size_t device_count) { | 333 size_t device_count) { |
| 338 DCHECK(CalledOnValidThread()); | 334 DCHECK(CalledOnValidThread()); |
| 339 if (!platform_devices) { | 335 if (!platform_devices) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 549 } |
| 554 | 550 |
| 555 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device, | 551 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device, |
| 556 const base::Closure& refresh_complete) { | 552 const base::Closure& refresh_complete) { |
| 557 libusb_ref_device(platform_device); | 553 libusb_ref_device(platform_device); |
| 558 ignored_devices_.insert(platform_device); | 554 ignored_devices_.insert(platform_device); |
| 559 refresh_complete.Run(); | 555 refresh_complete.Run(); |
| 560 } | 556 } |
| 561 | 557 |
| 562 } // namespace device | 558 } // namespace device |
| OLD | NEW |