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

Side by Side Diff: device/usb/usb_device_filter.cc

Issue 1265833005: Get all the UsbConfigDescriptor for the device configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated code to continue instead of return if error happens when getting config descriptor Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/usb/usb_device_filter.h" 5 #include "device/usb/usb_device_filter.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "device/usb/usb_descriptors.h"
9 #include "device/usb/usb_device.h" 8 #include "device/usb/usb_device.h"
10 9
11 namespace device { 10 namespace device {
12 11
13 namespace { 12 namespace {
14 13
15 const char kProductIdKey[] = "productId"; 14 const char kProductIdKey[] = "productId";
16 const char kVendorIdKey[] = "vendorId"; 15 const char kVendorIdKey[] = "vendorId";
17 const char kInterfaceClassKey[] = "interfaceClass"; 16 const char kInterfaceClassKey[] = "interfaceClass";
18 const char kInterfaceSubclassKey[] = "interfaceSubclass"; 17 const char kInterfaceSubclassKey[] = "interfaceSubclass";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (device->vendor_id() != vendor_id_) { 60 if (device->vendor_id() != vendor_id_) {
62 return false; 61 return false;
63 } 62 }
64 63
65 if (product_id_set_ && device->product_id() != product_id_) { 64 if (product_id_set_ && device->product_id() != product_id_) {
66 return false; 65 return false;
67 } 66 }
68 } 67 }
69 68
70 if (interface_class_set_) { 69 if (interface_class_set_) {
71 const UsbConfigDescriptor* config = device->GetConfiguration(); 70 const UsbConfigDescriptor* config = device->GetActiveConfiguration();
72 if (!config) { 71 if (!config) {
73 return false; 72 return false;
74 } 73 }
75 74
76 // TODO(reillyg): Check device configuration if the class is not defined at 75 // TODO(reillyg): Check device configuration if the class is not defined at
77 // a per-interface level. This is not really important because most devices 76 // a per-interface level. This is not really important because most devices
78 // have per-interface classes. The only counter-examples I know of are hubs. 77 // have per-interface classes. The only counter-examples I know of are hubs.
79 78
80 bool foundMatch = false; 79 bool foundMatch = false;
81 for (const UsbInterfaceDescriptor& iface : config->interfaces) { 80 for (const UsbInterfaceDescriptor& iface : config->interfaces) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 i != filters.end(); 125 i != filters.end();
127 ++i) { 126 ++i) {
128 if (i->Matches(device)) { 127 if (i->Matches(device)) {
129 return true; 128 return true;
130 } 129 }
131 } 130 }
132 return false; 131 return false;
133 } 132 }
134 133
135 } // namespace device 134 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698