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

Unified Diff: device/usb/usb_device_handle_impl.cc

Issue 1369643002: Add configuration and interface permission checks to DeviceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new method ot Android USB mocks. Created 5 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 1ae6816983ad9c7586cc308d7f77ec189ffbdf65..ffe5e0f3353d2a4f832ed5390077c80d225689a7 100644
--- a/device/usb/usb_device_handle_impl.cc
+++ b/device/usb/usb_device_handle_impl.cc
@@ -683,6 +683,17 @@ void UsbDeviceHandleImpl::GenericTransfer(UsbEndpointDirection direction,
}
}
+bool UsbDeviceHandleImpl::FindInterfaceByEndpoint(uint8_t endpoint_address,
+ uint8_t* interface_number) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ const auto endpoint_it = endpoint_map_.find(endpoint_address);
+ if (endpoint_it != endpoint_map_.end()) {
+ *interface_number = endpoint_it->second.interface_number;
+ return true;
+ }
+ return false;
+}
+
UsbDeviceHandleImpl::UsbDeviceHandleImpl(
scoped_refptr<UsbContext> context,
scoped_refptr<UsbDeviceImpl> device,
@@ -827,9 +838,10 @@ void UsbDeviceHandleImpl::RefreshEndpointMap() {
scoped_refptr<UsbDeviceHandleImpl::InterfaceClaimer>
UsbDeviceHandleImpl::GetClaimedInterfaceForEndpoint(uint8_t endpoint) {
- if (ContainsKey(endpoint_map_, endpoint))
- return claimed_interfaces_[endpoint_map_[endpoint].interface_number];
- return NULL;
+ const auto endpoint_it = endpoint_map_.find(endpoint);
+ if (endpoint_it != endpoint_map_.end())
+ return claimed_interfaces_[endpoint_it->second.interface_number];
+ return nullptr;
}
void UsbDeviceHandleImpl::ControlTransferInternal(
« chrome/browser/usb/web_usb_permission_provider.cc ('K') | « device/usb/usb_device_handle_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698