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

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: 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_filter.cc
diff --git a/device/usb/usb_device_filter.cc b/device/usb/usb_device_filter.cc
index cc919e2d00e5928f7325bff730f71ff7fac173c1..3a0443e573e5ef5a034b26320f34a10fc41d8606 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 (size_t i = 0; i < config.interfaces.size() && !foundMatch; ++i) {
+ const UsbInterfaceDescriptor& iface = config.interfaces[i];
+
+ if (iface.interface_class == interface_class_ &&
+ (!interface_subclass_set_ ||
+ (iface.interface_subclass == interface_subclass_ &&
+ (!interface_protocol_set_ ||
+ iface.interface_protocol == interface_protocol_)))) {
+ foundMatch = true;
}
}

Powered by Google App Engine
This is Rietveld 408576698