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

Unified Diff: device/usb/usb_device_filter.cc

Issue 562763002: Convert device::UsbConfigDescriptor and friends to structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add interface and endpoint descriptor iterator typedefs. 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
« no previous file with comments | « device/usb/usb_device.h ('k') | device/usb/usb_device_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_device_filter.cc
diff --git a/device/usb/usb_device_filter.cc b/device/usb/usb_device_filter.cc
index cc919e2d00e5928f7325bff730f71ff7fac173c1..2d3f157a1c29c61706f8e0b1136d086b5883ef4b 100644
--- a/device/usb/usb_device_filter.cc
+++ b/device/usb/usb_device_filter.cc
@@ -5,8 +5,8 @@
#include "device/usb/usb_device_filter.h"
#include "base/values.h"
+#include "device/usb/usb_descriptors.h"
#include "device/usb/usb_device.h"
-#include "device/usb/usb_interface.h"
namespace device {
@@ -69,27 +69,21 @@ bool UsbDeviceFilter::Matches(scoped_refptr<UsbDevice> device) const {
if (interface_class_set_) {
bool foundMatch = false;
- scoped_refptr<const UsbConfigDescriptor> config = device->ListInterfaces();
+ const UsbConfigDescriptor& config = device->GetConfiguration();
// TODO(reillyg): Check device configuration if the class is not defined at
// a per-interface level. This is not really important because most devices
// have per-interface classes. The only counter-examples I know of are hubs.
- for (size_t i = 0; i < config->GetNumInterfaces() && !foundMatch; ++i) {
- scoped_refptr<const UsbInterfaceDescriptor> iface =
- config->GetInterface(i);
-
- for (size_t j = 0; j < iface->GetNumAltSettings() && !foundMatch; ++j) {
- scoped_refptr<const UsbInterfaceAltSettingDescriptor> altSetting =
- iface->GetAltSetting(j);
-
- if (altSetting->GetInterfaceClass() == interface_class_ &&
- (!interface_subclass_set_ ||
- (altSetting->GetInterfaceSubclass() == interface_subclass_ &&
- (!interface_protocol_set_ ||
- altSetting->GetInterfaceProtocol() == interface_protocol_)))) {
- foundMatch = true;
- }
+ for (UsbInterfaceDescriptor::Iterator ifaceIt = config.interfaces.begin();
+ ifaceIt != config.interfaces.end() && !foundMatch;
+ ++ifaceIt) {
+ if (ifaceIt->interface_class == interface_class_ &&
+ (!interface_subclass_set_ ||
+ (ifaceIt->interface_subclass == interface_subclass_ &&
+ (!interface_protocol_set_ ||
+ ifaceIt->interface_protocol == interface_protocol_)))) {
+ foundMatch = true;
}
}
« no previous file with comments | « device/usb/usb_device.h ('k') | device/usb/usb_device_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698