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_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_H_ |
6 #define DEVICE_USB_USB_DEVICE_H_ | 6 #define DEVICE_USB_USB_DEVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 // Creates a UsbDeviceHandle for further manipulation. | 90 // Creates a UsbDeviceHandle for further manipulation. |
91 virtual void Open(const OpenCallback& callback) = 0; | 91 virtual void Open(const OpenCallback& callback) = 0; |
92 | 92 |
93 void AddObserver(Observer* observer); | 93 void AddObserver(Observer* observer); |
94 void RemoveObserver(Observer* observer); | 94 void RemoveObserver(Observer* observer); |
95 | 95 |
96 protected: | 96 protected: |
97 friend class UsbService; | 97 friend class UsbService; |
98 | 98 |
| 99 UsbDevice(); |
99 UsbDevice(uint16_t usb_version, | 100 UsbDevice(uint16_t usb_version, |
100 uint8_t device_class, | 101 uint8_t device_class, |
101 uint8_t device_subclass, | 102 uint8_t device_subclass, |
102 uint8_t device_protocol, | 103 uint8_t device_protocol, |
103 uint16_t vendor_id, | 104 uint16_t vendor_id, |
104 uint16_t product_id, | 105 uint16_t product_id, |
105 uint16_t device_version, | 106 uint16_t device_version, |
106 const base::string16& manufacturer_string, | 107 const base::string16& manufacturer_string, |
107 const base::string16& product_string, | 108 const base::string16& product_string, |
108 const base::string16& serial_number); | 109 const base::string16& serial_number); |
(...skipping 18 matching lines...) Expand all Loading... |
127 // All of the device's configuration descriptors. | 128 // All of the device's configuration descriptors. |
128 std::vector<UsbConfigDescriptor> configurations_; | 129 std::vector<UsbConfigDescriptor> configurations_; |
129 | 130 |
130 private: | 131 private: |
131 friend class base::RefCountedThreadSafe<UsbDevice>; | 132 friend class base::RefCountedThreadSafe<UsbDevice>; |
132 friend class UsbDeviceHandleImpl; | 133 friend class UsbDeviceHandleImpl; |
133 friend class UsbDeviceHandleUsbfs; | 134 friend class UsbDeviceHandleUsbfs; |
134 friend class UsbServiceAndroid; | 135 friend class UsbServiceAndroid; |
135 friend class UsbServiceImpl; | 136 friend class UsbServiceImpl; |
136 friend class UsbServiceLinux; | 137 friend class UsbServiceLinux; |
| 138 friend class UsbServiceWin; |
137 | 139 |
138 void OnDisconnect(); | 140 void OnDisconnect(); |
139 void HandleClosed(UsbDeviceHandle* handle); | 141 void HandleClosed(UsbDeviceHandle* handle); |
140 | 142 |
141 const std::string guid_; | 143 const std::string guid_; |
142 const uint8_t device_class_; | 144 const uint8_t device_class_; |
143 const uint8_t device_subclass_; | 145 const uint8_t device_subclass_; |
144 const uint8_t device_protocol_; | 146 const uint8_t device_protocol_; |
145 const uint16_t vendor_id_; | 147 const uint16_t vendor_id_; |
146 const uint16_t product_id_; | 148 const uint16_t product_id_; |
147 | 149 |
148 // The current device configuration descriptor. May be null if the device is | 150 // The current device configuration descriptor. May be null if the device is |
149 // in an unconfigured state; if not null, it is a pointer to one of the | 151 // in an unconfigured state; if not null, it is a pointer to one of the |
150 // items at UsbDevice::configurations_. | 152 // items at UsbDevice::configurations_. |
151 const UsbConfigDescriptor* active_configuration_ = nullptr; | 153 const UsbConfigDescriptor* active_configuration_ = nullptr; |
152 | 154 |
153 // Weak pointers to open handles. HandleClosed() will be called before each | 155 // Weak pointers to open handles. HandleClosed() will be called before each |
154 // is freed. | 156 // is freed. |
155 std::list<UsbDeviceHandle*> handles_; | 157 std::list<UsbDeviceHandle*> handles_; |
156 | 158 |
157 base::ObserverList<Observer, true> observer_list_; | 159 base::ObserverList<Observer, true> observer_list_; |
158 | 160 |
159 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 161 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
160 }; | 162 }; |
161 | 163 |
162 } // namespace device | 164 } // namespace device |
163 | 165 |
164 #endif // DEVICE_USB_USB_DEVICE_H_ | 166 #endif // DEVICE_USB_USB_DEVICE_H_ |
OLD | NEW |