OLD | NEW |
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 #ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_FILTER_H_ |
6 #define COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_ | 6 #define DEVICE_USB_USB_DEVICE_FILTER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "components/usb_service/usb_service_export.h" | |
12 | 11 |
13 namespace base { | 12 namespace base { |
14 class Value; | 13 class Value; |
15 } | 14 } |
16 | 15 |
17 namespace usb_service { | 16 namespace device { |
18 | 17 |
19 class UsbDevice; | 18 class UsbDevice; |
20 | 19 |
21 class USB_SERVICE_EXPORT UsbDeviceFilter { | 20 class UsbDeviceFilter { |
22 public: | 21 public: |
23 UsbDeviceFilter(); | 22 UsbDeviceFilter(); |
24 ~UsbDeviceFilter(); | 23 ~UsbDeviceFilter(); |
25 | 24 |
26 void SetVendorId(uint16 vendor_id); | 25 void SetVendorId(uint16 vendor_id); |
27 void SetProductId(uint16 product_id); | 26 void SetProductId(uint16 product_id); |
28 void SetInterfaceClass(uint8 interface_class); | 27 void SetInterfaceClass(uint8 interface_class); |
29 void SetInterfaceSubclass(uint8 interface_subclass); | 28 void SetInterfaceSubclass(uint8 interface_subclass); |
30 void SetInterfaceProtocol(uint8 interface_protocol); | 29 void SetInterfaceProtocol(uint8 interface_protocol); |
31 | 30 |
32 bool Matches(scoped_refptr<UsbDevice> device) const; | 31 bool Matches(scoped_refptr<UsbDevice> device) const; |
33 base::Value* ToValue() const; | 32 base::Value* ToValue() const; |
34 | 33 |
35 static bool MatchesAny(scoped_refptr<UsbDevice> device, | 34 static bool MatchesAny(scoped_refptr<UsbDevice> device, |
36 const std::vector<UsbDeviceFilter>& filters); | 35 const std::vector<UsbDeviceFilter>& filters); |
37 | 36 |
38 private: | 37 private: |
39 uint16 vendor_id_; | 38 uint16 vendor_id_; |
40 uint16 product_id_; | 39 uint16 product_id_; |
41 uint8 interface_class_; | 40 uint8 interface_class_; |
42 uint8 interface_subclass_; | 41 uint8 interface_subclass_; |
43 uint8 interface_protocol_; | 42 uint8 interface_protocol_; |
44 bool vendor_id_set_ : 1; | 43 bool vendor_id_set_ : 1; |
45 bool product_id_set_ : 1; | 44 bool product_id_set_ : 1; |
46 bool interface_class_set_ : 1; | 45 bool interface_class_set_ : 1; |
47 bool interface_subclass_set_ : 1; | 46 bool interface_subclass_set_ : 1; |
48 bool interface_protocol_set_ : 1; | 47 bool interface_protocol_set_ : 1; |
49 }; | 48 }; |
50 | 49 |
51 } // namespace usb_service | 50 } // namespace device |
52 | 51 |
53 #endif // COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_ | 52 #endif // DEVICE_USB_USB_DEVICE_FILTER_H_ |
OLD | NEW |