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

Unified Diff: device/usb/usb_device_handle_impl.cc

Issue 562763002: Convert device::UsbConfigDescriptor and friends to structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: device/usb/usb_device_handle_impl.cc
diff --git a/device/usb/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc
index c88fb9bc5f5bc6499a33e7e312938610ff067a5f..d5f5e3af5d5c5899e4b8fa7cbe0d8e77f171c2ae 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() {
@@ -664,13 +662,16 @@ void UsbDeviceHandleImpl::RefreshEndpointMap() {
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 (size_t i = 0; i < config_.interfaces.size(); ++i) {
+ const UsbInterfaceDescriptor& interface_desc = config_.interfaces[i];
+ if (interface_desc.interface_number == it->first &&
+ interface_desc.alternate_setting == it->second->alternate_setting()) {
+ for (size_t j = 0; j < interface_desc.endpoints.size(); ++j) {
+ const UsbEndpointDescriptor& endpoint = interface_desc.endpoints[j];
+ endpoint_map_[endpoint.address] = it->first;
+ }
+ break;
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698