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

Unified Diff: components/usb_service/usb_device_filter.cc

Issue 517923002: Add more generic filters to the chrome.usb.getDevices API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Function comments are descriptive. 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 | « components/usb_service/usb_device_filter.h ('k') | components/usb_service/usb_device_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/usb_service/usb_device_filter.cc
diff --git a/components/usb_service/usb_device_filter.cc b/components/usb_service/usb_device_filter.cc
index 45f8d12d1f9d48d81a9d3ab9d0c6a3e82d015e13..d026fa054d30fbb016653e87e8749eb071c5a301 100644
--- a/components/usb_service/usb_device_filter.cc
+++ b/components/usb_service/usb_device_filter.cc
@@ -6,7 +6,6 @@
#include "base/values.h"
#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_handle.h"
#include "components/usb_service/usb_interface.h"
namespace usb_service {
@@ -57,7 +56,7 @@ void UsbDeviceFilter::SetInterfaceProtocol(uint8 interface_protocol) {
interface_protocol_ = interface_protocol;
}
-bool UsbDeviceFilter::Matches(scoped_refptr<UsbDevice> device) {
+bool UsbDeviceFilter::Matches(scoped_refptr<UsbDevice> device) const {
if (vendor_id_set_) {
if (device->vendor_id() != vendor_id_) {
return false;
@@ -125,4 +124,17 @@ base::Value* UsbDeviceFilter::ToValue() const {
return obj.release();
}
+// static
+bool UsbDeviceFilter::MatchesAny(scoped_refptr<UsbDevice> device,
+ const std::vector<UsbDeviceFilter>& filters) {
+ for (std::vector<UsbDeviceFilter>::const_iterator i = filters.begin();
+ i != filters.end();
+ ++i) {
+ if (i->Matches(device)) {
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace usb_service
« no previous file with comments | « components/usb_service/usb_device_filter.h ('k') | components/usb_service/usb_device_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698