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_HID_HID_DEVICE_INFO_H_ | 5 #ifndef DEVICE_HID_HID_DEVICE_INFO_H_ |
6 #define DEVICE_HID_HID_DEVICE_INFO_H_ | 6 #define DEVICE_HID_HID_DEVICE_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/memory/ref_counted.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 #include "device/hid/hid_collection_info.h" | 13 #include "device/hid/hid_collection_info.h" |
13 | 14 |
14 namespace device { | 15 namespace device { |
15 | 16 |
16 enum HidBusType { | 17 enum HidBusType { |
17 kHIDBusTypeUSB = 0, | 18 kHIDBusTypeUSB = 0, |
18 kHIDBusTypeBluetooth = 1, | 19 kHIDBusTypeBluetooth = 1, |
19 }; | 20 }; |
20 | 21 |
21 typedef std::string HidDeviceId; | 22 typedef std::string HidDeviceId; |
22 extern const char kInvalidHidDeviceId[]; | 23 extern const char kInvalidHidDeviceId[]; |
23 | 24 |
24 struct HidDeviceInfo { | 25 class HidDeviceInfo : public base::RefCountedThreadSafe<HidDeviceInfo> { |
| 26 public: |
25 HidDeviceInfo(); | 27 HidDeviceInfo(); |
| 28 |
| 29 // Device identification. |
| 30 const HidDeviceId& device_id() const { return device_id_; } |
| 31 uint16_t vendor_id() const { return vendor_id_; } |
| 32 uint16_t product_id() const { return product_id_; } |
| 33 const std::string& product_name() const { return product_name_; } |
| 34 const std::string& serial_number() const { return serial_number_; } |
| 35 HidBusType bus_type() const { return bus_type_; } |
| 36 |
| 37 // Top-Level Collections information. |
| 38 const std::vector<HidCollectionInfo>& collections() const { |
| 39 return collections_; |
| 40 } |
| 41 bool has_report_id() const { return has_report_id_; }; |
| 42 size_t max_input_report_size() const { return max_input_report_size_; } |
| 43 size_t max_output_report_size() const { return max_output_report_size_; } |
| 44 size_t max_feature_report_size() const { return max_feature_report_size_; } |
| 45 |
| 46 #if defined(OS_LINUX) |
| 47 const std::string& device_node() const { return device_node_; } |
| 48 #endif |
| 49 |
| 50 private: |
| 51 friend class base::RefCountedThreadSafe<HidDeviceInfo>; |
| 52 |
| 53 // TODO(reillyg): Define public constructors that make some of these |
| 54 // declarations unnecessary. |
| 55 friend class HidServiceLinux; |
| 56 friend class HidServiceMac; |
| 57 friend class HidServiceWin; |
| 58 friend class MockHidService; |
| 59 friend class HidFilterTest; |
| 60 |
26 ~HidDeviceInfo(); | 61 ~HidDeviceInfo(); |
27 | 62 |
28 // Device identification. | 63 // Device identification. |
29 HidDeviceId device_id; | 64 HidDeviceId device_id_; |
30 uint16_t vendor_id; | 65 uint16_t vendor_id_; |
31 uint16_t product_id; | 66 uint16_t product_id_; |
32 std::string product_name; | 67 std::string product_name_; |
33 std::string serial_number; | 68 std::string serial_number_; |
34 HidBusType bus_type; | 69 HidBusType bus_type_; |
35 | 70 |
36 // Top-Level Collections information. | 71 // Top-Level Collections information. |
37 std::vector<HidCollectionInfo> collections; | 72 std::vector<HidCollectionInfo> collections_; |
38 bool has_report_id; | 73 bool has_report_id_; |
39 size_t max_input_report_size; | 74 size_t max_input_report_size_; |
40 size_t max_output_report_size; | 75 size_t max_output_report_size_; |
41 size_t max_feature_report_size; | 76 size_t max_feature_report_size_; |
42 | 77 |
43 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
44 std::string device_node; | 79 std::string device_node_; |
45 #endif | 80 #endif |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo); |
46 }; | 83 }; |
47 | 84 |
48 } // namespace device | 85 } // namespace device |
49 | 86 |
50 #endif // DEVICE_HID_HID_DEVICE_INFO_H_ | 87 #endif // DEVICE_HID_HID_DEVICE_INFO_H_ |
OLD | NEW |