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(const UsbDeviceDescriptor& descriptor, | 100 UsbDevice(const UsbDeviceDescriptor& descriptor, |
100 const base::string16& manufacturer_string, | 101 const base::string16& manufacturer_string, |
101 const base::string16& product_string, | 102 const base::string16& product_string, |
102 const base::string16& serial_number); | 103 const base::string16& serial_number); |
103 UsbDevice(uint16_t usb_version, | 104 UsbDevice(uint16_t usb_version, |
104 uint8_t device_class, | 105 uint8_t device_class, |
105 uint8_t device_subclass, | 106 uint8_t device_subclass, |
106 uint8_t device_protocol, | 107 uint8_t device_protocol, |
107 uint16_t vendor_id, | 108 uint16_t vendor_id, |
108 uint16_t product_id, | 109 uint16_t product_id, |
(...skipping 18 matching lines...) Expand all Loading... |
127 std::unique_ptr<WebUsbAllowedOrigins> webusb_allowed_origins_; | 128 std::unique_ptr<WebUsbAllowedOrigins> webusb_allowed_origins_; |
128 GURL webusb_landing_page_; | 129 GURL webusb_landing_page_; |
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 | 144 |
143 // The current device configuration descriptor. May be null if the device is | 145 // The current device configuration descriptor. May be null if the device is |
144 // in an unconfigured state; if not null, it is a pointer to one of the | 146 // in an unconfigured state; if not null, it is a pointer to one of the |
145 // items in |descriptor_.configurations|. | 147 // items in |descriptor_.configurations|. |
146 const UsbConfigDescriptor* active_configuration_ = nullptr; | 148 const UsbConfigDescriptor* active_configuration_ = nullptr; |
147 | 149 |
148 // Weak pointers to open handles. HandleClosed() will be called before each | 150 // Weak pointers to open handles. HandleClosed() will be called before each |
149 // is freed. | 151 // is freed. |
150 std::list<UsbDeviceHandle*> handles_; | 152 std::list<UsbDeviceHandle*> handles_; |
151 | 153 |
152 base::ObserverList<Observer, true> observer_list_; | 154 base::ObserverList<Observer, true> observer_list_; |
153 | 155 |
154 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 156 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
155 }; | 157 }; |
156 | 158 |
157 } // namespace device | 159 } // namespace device |
158 | 160 |
159 #endif // DEVICE_USB_USB_DEVICE_H_ | 161 #endif // DEVICE_USB_USB_DEVICE_H_ |
OLD | NEW |