summaryrefslogtreecommitdiffstats
path: root/device/usb/usb_device_handle_impl.cc
diff options
context:
space:
mode:
authorreillyg <reillyg@chromium.org>2014-09-12 08:31:05 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-12 15:41:03 +0000
commitbe9e363a3af57bd313fbb96ec3b5fa02cef769b5 (patch)
tree83f6531852ccfa02ce54f1b0efb26508312588cf /device/usb/usb_device_handle_impl.cc
parent14755294fdb15b90dfc0b3653277a0a65b8250de (diff)
downloadchromium_src-be9e363a3af57bd313fbb96ec3b5fa02cef769b5.zip
chromium_src-be9e363a3af57bd313fbb96ec3b5fa02cef769b5.tar.gz
chromium_src-be9e363a3af57bd313fbb96ec3b5fa02cef769b5.tar.bz2
Convert device::UsbConfigDescriptor and friends to structs.
These classes do not need to be classes and expecially don't need to be abstract classes as this leads to a complicated implementation and complicated tests. All USB devices no matter the platform will have the same descriptor data. This change follows the model of device::HidDeviceInfo. BUG= Review URL: https://codereview.chromium.org/562763002 Cr-Commit-Position: refs/heads/master@{#294594}
Diffstat (limited to 'device/usb/usb_device_handle_impl.cc')
-rw-r--r--device/usb/usb_device_handle_impl.cc41
1 files changed, 23 insertions, 18 deletions
diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc
index c88fb9b..2d8c690 100644
--- a/device/usb/usb_device_handle_impl.cc
+++ b/device/usb/usb_device_handle_impl.cc
@@ -15,9 +15,9 @@
#include "base/synchronization/lock.h"
#include "base/thread_task_runner_handle.h"
#include "device/usb/usb_context.h"
+#include "device/usb/usb_descriptors.h"
#include "device/usb/usb_device_impl.h"
#include "device/usb/usb_error.h"
-#include "device/usb/usb_interface.h"
#include "device/usb/usb_service.h"
#include "third_party/libusb/src/libusb/libusb.h"
@@ -182,18 +182,16 @@ void UsbDeviceHandleImpl::Transfer::Complete(UsbTransferStatus status,
}
}
-UsbDeviceHandleImpl::UsbDeviceHandleImpl(
- scoped_refptr<UsbContext> context,
- UsbDeviceImpl* device,
- PlatformUsbDeviceHandle handle,
- scoped_refptr<UsbConfigDescriptor> interfaces)
+UsbDeviceHandleImpl::UsbDeviceHandleImpl(scoped_refptr<UsbContext> context,
+ UsbDeviceImpl* device,
+ PlatformUsbDeviceHandle handle,
+ const UsbConfigDescriptor& config)
: device_(device),
handle_(handle),
- interfaces_(interfaces),
+ config_(config),
context_(context),
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
DCHECK(handle) << "Cannot create device with NULL handle.";
- DCHECK(interfaces_.get()) << "Unable to list interfaces";
}
UsbDeviceHandleImpl::~UsbDeviceHandleImpl() {
@@ -661,16 +659,23 @@ void UsbDeviceHandleImpl::IsochronousTransfer(
void UsbDeviceHandleImpl::RefreshEndpointMap() {
DCHECK(thread_checker_.CalledOnValidThread());
endpoint_map_.clear();
- for (ClaimedInterfaceMap::iterator it = claimed_interfaces_.begin();
- it != claimed_interfaces_.end();
- ++it) {
- scoped_refptr<const UsbInterfaceAltSettingDescriptor> interface_desc =
- interfaces_->GetInterface(it->first)
- ->GetAltSetting(it->second->alternate_setting());
- for (size_t i = 0; i < interface_desc->GetNumEndpoints(); i++) {
- scoped_refptr<const UsbEndpointDescriptor> endpoint =
- interface_desc->GetEndpoint(i);
- endpoint_map_[endpoint->GetAddress()] = it->first;
+ for (ClaimedInterfaceMap::iterator claimedIt = claimed_interfaces_.begin();
+ claimedIt != claimed_interfaces_.end();
+ ++claimedIt) {
+ for (UsbInterfaceDescriptor::Iterator ifaceIt = config_.interfaces.begin();
+ ifaceIt != config_.interfaces.end();
+ ++ifaceIt) {
+ if (ifaceIt->interface_number == claimedIt->first &&
+ ifaceIt->alternate_setting ==
+ claimedIt->second->alternate_setting()) {
+ for (UsbEndpointDescriptor::Iterator endpointIt =
+ ifaceIt->endpoints.begin();
+ endpointIt != ifaceIt->endpoints.end();
+ ++endpointIt) {
+ endpoint_map_[endpointIt->address] = claimedIt->first;
+ }
+ break;
+ }
}
}
}