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 DEVICE_USB_USB_DEVICE_FILTER_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_FILTER_H_ |
6 #define DEVICE_USB_USB_DEVICE_FILTER_H_ | 6 #define DEVICE_USB_USB_DEVICE_FILTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
| 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/optional.h" | 14 #include "base/optional.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class Value; | 17 class Value; |
18 } | 18 } |
19 | 19 |
20 namespace device { | 20 namespace device { |
21 | 21 |
22 class UsbDevice; | 22 class UsbDevice; |
23 | 23 |
24 struct UsbDeviceFilter { | 24 struct UsbDeviceFilter { |
25 UsbDeviceFilter(); | 25 UsbDeviceFilter(); |
26 UsbDeviceFilter(const UsbDeviceFilter& other); | 26 UsbDeviceFilter(const UsbDeviceFilter& other); |
27 ~UsbDeviceFilter(); | 27 ~UsbDeviceFilter(); |
28 | 28 |
29 bool Matches(scoped_refptr<UsbDevice> device) const; | 29 // Returns true if |device| matches this filter. |
| 30 bool Matches(const UsbDevice& device) const; |
30 std::unique_ptr<base::Value> ToValue() const; | 31 std::unique_ptr<base::Value> ToValue() const; |
31 | 32 |
32 static bool MatchesAny(scoped_refptr<UsbDevice> device, | 33 // Returns true if device matches any filter in |filters|, or if |filters| is |
| 34 // empty. |
| 35 static bool MatchesAny(const UsbDevice& device, |
33 const std::vector<UsbDeviceFilter>& filters); | 36 const std::vector<UsbDeviceFilter>& filters); |
34 | 37 |
35 base::Optional<uint16_t> vendor_id; | 38 base::Optional<uint16_t> vendor_id; |
36 base::Optional<uint16_t> product_id; | 39 base::Optional<uint16_t> product_id; |
37 base::Optional<uint8_t> interface_class; | 40 base::Optional<uint8_t> interface_class; |
38 base::Optional<uint8_t> interface_subclass; | 41 base::Optional<uint8_t> interface_subclass; |
39 base::Optional<uint8_t> interface_protocol; | 42 base::Optional<uint8_t> interface_protocol; |
40 base::Optional<std::string> serial_number; | 43 base::Optional<std::string> serial_number; |
41 }; | 44 }; |
42 | 45 |
43 } // namespace device | 46 } // namespace device |
44 | 47 |
45 #endif // DEVICE_USB_USB_DEVICE_FILTER_H_ | 48 #endif // DEVICE_USB_USB_DEVICE_FILTER_H_ |
OLD | NEW |