| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (descriptor.bDeviceClass == LIBUSB_CLASS_HUB) { | 487 if (descriptor.bDeviceClass == LIBUSB_CLASS_HUB) { |
| 488 // Don't try to enumerate hubs. We never want to connect to a hub. | 488 // Don't try to enumerate hubs. We never want to connect to a hub. |
| 489 refresh_complete.Run(); | 489 refresh_complete.Run(); |
| 490 return; | 490 return; |
| 491 } | 491 } |
| 492 | 492 |
| 493 scoped_refptr<UsbDeviceImpl> device( | 493 scoped_refptr<UsbDeviceImpl> device(new UsbDeviceImpl( |
| 494 new UsbDeviceImpl(context_, platform_device, descriptor.idVendor, | 494 context_, platform_device, descriptor, blocking_task_runner_)); |
| 495 descriptor.idProduct, blocking_task_runner_)); | |
| 496 base::Closure add_device = | 495 base::Closure add_device = |
| 497 base::Bind(&UsbServiceImpl::AddDevice, weak_factory_.GetWeakPtr(), | 496 base::Bind(&UsbServiceImpl::AddDevice, weak_factory_.GetWeakPtr(), |
| 498 refresh_complete, device); | 497 refresh_complete, device); |
| 499 bool read_bos_descriptors = descriptor.bcdUSB >= kUsbVersion2_1; | 498 bool read_bos_descriptors = descriptor.bcdUSB >= kUsbVersion2_1; |
| 500 | 499 |
| 501 #if defined(USE_UDEV) | 500 #if defined(USE_UDEV) |
| 502 blocking_task_runner_->PostTask( | 501 blocking_task_runner_->PostTask( |
| 503 FROM_HERE, | 502 FROM_HERE, |
| 504 base::Bind(&EnumerateUdevDevice, device, read_bos_descriptors, | 503 base::Bind(&EnumerateUdevDevice, device, read_bos_descriptors, |
| 505 task_runner_, add_device, refresh_complete)); | 504 task_runner_, add_device, refresh_complete)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); | 608 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); |
| 610 if (it != platform_devices_.end()) { | 609 if (it != platform_devices_.end()) { |
| 611 RemoveDevice(it->second); | 610 RemoveDevice(it->second); |
| 612 } else { | 611 } else { |
| 613 devices_being_enumerated_.erase(platform_device); | 612 devices_being_enumerated_.erase(platform_device); |
| 614 } | 613 } |
| 615 libusb_unref_device(platform_device); | 614 libusb_unref_device(platform_device); |
| 616 } | 615 } |
| 617 | 616 |
| 618 } // namespace device | 617 } // namespace device |
| OLD | NEW |