| 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 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 | 478 |
| 479 void UsbServiceImpl::EnumerateDevice(PlatformUsbDevice platform_device, | 479 void UsbServiceImpl::EnumerateDevice(PlatformUsbDevice platform_device, |
| 480 const base::Closure& refresh_complete) { | 480 const base::Closure& refresh_complete) { |
| 481 DCHECK(context_); | 481 DCHECK(context_); |
| 482 devices_being_enumerated_.insert(platform_device); | 482 devices_being_enumerated_.insert(platform_device); |
| 483 | 483 |
| 484 libusb_device_descriptor descriptor; | 484 libusb_device_descriptor descriptor; |
| 485 int rv = libusb_get_device_descriptor(platform_device, &descriptor); | 485 int rv = libusb_get_device_descriptor(platform_device, &descriptor); |
| 486 if (rv == LIBUSB_SUCCESS) { | 486 if (rv == LIBUSB_SUCCESS) { |
| 487 scoped_refptr<UsbDeviceImpl> device( | 487 scoped_refptr<UsbDeviceImpl> device(new UsbDeviceImpl( |
| 488 new UsbDeviceImpl(context_, platform_device, descriptor.idVendor, | 488 context_, platform_device, descriptor, blocking_task_runner_)); |
| 489 descriptor.idProduct, blocking_task_runner_)); | |
| 490 | 489 |
| 491 base::Closure add_device = | 490 base::Closure add_device = |
| 492 base::Bind(&UsbServiceImpl::AddDevice, weak_factory_.GetWeakPtr(), | 491 base::Bind(&UsbServiceImpl::AddDevice, weak_factory_.GetWeakPtr(), |
| 493 refresh_complete, device); | 492 refresh_complete, device); |
| 494 bool read_bos_descriptors = descriptor.bcdUSB >= kUsbVersion2_1; | 493 bool read_bos_descriptors = descriptor.bcdUSB >= kUsbVersion2_1; |
| 495 | 494 |
| 496 #if defined(USE_UDEV) | 495 #if defined(USE_UDEV) |
| 497 blocking_task_runner_->PostTask( | 496 blocking_task_runner_->PostTask( |
| 498 FROM_HERE, | 497 FROM_HERE, |
| 499 base::Bind(&EnumerateUdevDevice, device, read_bos_descriptors, | 498 base::Bind(&EnumerateUdevDevice, device, read_bos_descriptors, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); | 603 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); |
| 605 if (it != platform_devices_.end()) { | 604 if (it != platform_devices_.end()) { |
| 606 RemoveDevice(it->second); | 605 RemoveDevice(it->second); |
| 607 } else { | 606 } else { |
| 608 devices_being_enumerated_.erase(platform_device); | 607 devices_being_enumerated_.erase(platform_device); |
| 609 } | 608 } |
| 610 libusb_unref_device(platform_device); | 609 libusb_unref_device(platform_device); |
| 611 } | 610 } |
| 612 | 611 |
| 613 } // namespace device | 612 } // namespace device |
| OLD | NEW |