Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: device/usb/usb_device_handle_impl.cc

Issue 1265833005: Get all the UsbConfigDescriptor for the device configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use const auto Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_device_handle_impl.h" 5 #include "device/usb/usb_device_handle_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 694 }
695 task_runner_->PostTask( 695 task_runner_->PostTask(
696 FROM_HERE, base::Bind(&UsbDeviceHandleImpl::SetConfigurationComplete, 696 FROM_HERE, base::Bind(&UsbDeviceHandleImpl::SetConfigurationComplete,
697 this, rv == LIBUSB_SUCCESS, callback)); 697 this, rv == LIBUSB_SUCCESS, callback));
698 } 698 }
699 699
700 void UsbDeviceHandleImpl::SetConfigurationComplete( 700 void UsbDeviceHandleImpl::SetConfigurationComplete(
701 bool success, 701 bool success,
702 const ResultCallback& callback) { 702 const ResultCallback& callback) {
703 if (success) { 703 if (success) {
704 device_->RefreshConfiguration(); 704 device_->RefreshActiveConfiguration();
705 RefreshEndpointMap(); 705 RefreshEndpointMap();
706 } 706 }
707 callback.Run(success); 707 callback.Run(success);
708 } 708 }
709 709
710 void UsbDeviceHandleImpl::ClaimInterfaceOnBlockingThread( 710 void UsbDeviceHandleImpl::ClaimInterfaceOnBlockingThread(
711 int interface_number, 711 int interface_number,
712 const ResultCallback& callback) { 712 const ResultCallback& callback) {
713 int rv = libusb_claim_interface(handle_, interface_number); 713 int rv = libusb_claim_interface(handle_, interface_number);
714 if (rv != LIBUSB_SUCCESS) { 714 if (rv != LIBUSB_SUCCESS) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 if (rv != LIBUSB_SUCCESS) { 769 if (rv != LIBUSB_SUCCESS) {
770 USB_LOG(EVENT) << "Failed to reset device: " 770 USB_LOG(EVENT) << "Failed to reset device: "
771 << ConvertPlatformUsbErrorToString(rv); 771 << ConvertPlatformUsbErrorToString(rv);
772 } 772 }
773 task_runner_->PostTask(FROM_HERE, base::Bind(callback, rv == LIBUSB_SUCCESS)); 773 task_runner_->PostTask(FROM_HERE, base::Bind(callback, rv == LIBUSB_SUCCESS));
774 } 774 }
775 775
776 void UsbDeviceHandleImpl::RefreshEndpointMap() { 776 void UsbDeviceHandleImpl::RefreshEndpointMap() {
777 DCHECK(thread_checker_.CalledOnValidThread()); 777 DCHECK(thread_checker_.CalledOnValidThread());
778 endpoint_map_.clear(); 778 endpoint_map_.clear();
779 const UsbConfigDescriptor* config = device_->GetConfiguration(); 779 const UsbConfigDescriptor* config = device_->GetActiveConfiguration();
780 if (config) { 780 if (config) {
781 for (const auto& map_entry : claimed_interfaces_) { 781 for (const auto& map_entry : claimed_interfaces_) {
782 int interface_number = map_entry.first; 782 int interface_number = map_entry.first;
783 const scoped_refptr<InterfaceClaimer>& claimed_iface = map_entry.second; 783 const scoped_refptr<InterfaceClaimer>& claimed_iface = map_entry.second;
784 784
785 for (const UsbInterfaceDescriptor& iface : config->interfaces) { 785 for (const UsbInterfaceDescriptor& iface : config->interfaces) {
786 if (iface.interface_number == interface_number && 786 if (iface.interface_number == interface_number &&
787 iface.alternate_setting == claimed_iface->alternate_setting()) { 787 iface.alternate_setting == claimed_iface->alternate_setting()) {
788 for (const UsbEndpointDescriptor& endpoint : iface.endpoints) { 788 for (const UsbEndpointDescriptor& endpoint : iface.endpoints) {
789 endpoint_map_[endpoint.address] = interface_number; 789 endpoint_map_[endpoint.address] = interface_number;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 // Attempt-release all the interfaces. 978 // Attempt-release all the interfaces.
979 // It will be retained until the transfer cancellation is finished. 979 // It will be retained until the transfer cancellation is finished.
980 claimed_interfaces_.clear(); 980 claimed_interfaces_.clear();
981 981
982 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to 982 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to
983 // finish. 983 // finish.
984 device_ = NULL; 984 device_ = NULL;
985 } 985 }
986 986
987 } // namespace device 987 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698