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

Side by Side Diff: device/hid/hid_device_info.h

Issue 825523003: Convert HidDeviceInfo from a struct to a refcounted class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « device/hid/hid_device_filter_unittest.cc ('k') | device/hid/hid_device_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 friend class HidServiceLinux;
53 friend class HidServiceMac;
Ken Rockot(use gerrit already) 2015/01/08 20:26:16 Could you please add a TODO which documents the in
54 friend class HidServiceWin;
55 friend class MockHidService;
56 friend class HidFilterTest;
26 ~HidDeviceInfo(); 57 ~HidDeviceInfo();
27 58
28 // Device identification. 59 // Device identification.
29 HidDeviceId device_id; 60 HidDeviceId device_id_;
30 uint16_t vendor_id; 61 uint16_t vendor_id_;
31 uint16_t product_id; 62 uint16_t product_id_;
32 std::string product_name; 63 std::string product_name_;
33 std::string serial_number; 64 std::string serial_number_;
34 HidBusType bus_type; 65 HidBusType bus_type_;
35 66
36 // Top-Level Collections information. 67 // Top-Level Collections information.
37 std::vector<HidCollectionInfo> collections; 68 std::vector<HidCollectionInfo> collections_;
38 bool has_report_id; 69 bool has_report_id_;
39 size_t max_input_report_size; 70 size_t max_input_report_size_;
40 size_t max_output_report_size; 71 size_t max_output_report_size_;
41 size_t max_feature_report_size; 72 size_t max_feature_report_size_;
42 73
43 #if defined(OS_LINUX) 74 #if defined(OS_LINUX)
44 std::string device_node; 75 std::string device_node_;
45 #endif 76 #endif
77
78 DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo);
46 }; 79 };
47 80
48 } // namespace device 81 } // namespace device
49 82
50 #endif // DEVICE_HID_HID_DEVICE_INFO_H_ 83 #endif // DEVICE_HID_HID_DEVICE_INFO_H_
OLDNEW
« no previous file with comments | « device/hid/hid_device_filter_unittest.cc ('k') | device/hid/hid_device_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698