| 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 <string> | 10 #include <string> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // This method is called when the UsbService that created this object | 43 // This method is called when the UsbService that created this object |
| 44 // detects that the device has been disconnected from the host. | 44 // detects that the device has been disconnected from the host. |
| 45 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); | 45 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // A unique identifier which remains stable for the lifetime of this device | 48 // A unique identifier which remains stable for the lifetime of this device |
| 49 // object (i.e., until the device is unplugged or the USB service dies.) | 49 // object (i.e., until the device is unplugged or the USB service dies.) |
| 50 const std::string& guid() const { return guid_; } | 50 const std::string& guid() const { return guid_; } |
| 51 | 51 |
| 52 // Accessors to basic information. | 52 // Accessors to basic information. |
| 53 uint16_t usb_version() const { return usb_version_; } |
| 54 uint8_t device_class() const { return device_class_; } |
| 55 uint8_t device_subclass() const { return device_subclass_; } |
| 56 uint8_t device_protocol() const { return device_protocol_; } |
| 53 uint16_t vendor_id() const { return vendor_id_; } | 57 uint16_t vendor_id() const { return vendor_id_; } |
| 54 uint16_t product_id() const { return product_id_; } | 58 uint16_t product_id() const { return product_id_; } |
| 59 uint16_t device_version() const { return device_version_; } |
| 55 const base::string16& manufacturer_string() const { | 60 const base::string16& manufacturer_string() const { |
| 56 return manufacturer_string_; | 61 return manufacturer_string_; |
| 57 } | 62 } |
| 58 const base::string16& product_string() const { return product_string_; } | 63 const base::string16& product_string() const { return product_string_; } |
| 59 const base::string16& serial_number() const { return serial_number_; } | 64 const base::string16& serial_number() const { return serial_number_; } |
| 60 const WebUsbAllowedOrigins* webusb_allowed_origins() const { | 65 const WebUsbAllowedOrigins* webusb_allowed_origins() const { |
| 61 return webusb_allowed_origins_.get(); | 66 return webusb_allowed_origins_.get(); |
| 62 } | 67 } |
| 63 const GURL& webusb_landing_page() const { return webusb_landing_page_; } | 68 const GURL& webusb_landing_page() const { return webusb_landing_page_; } |
| 64 const std::vector<UsbConfigDescriptor>& configurations() const { | 69 const std::vector<UsbConfigDescriptor>& configurations() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 // Gets the UsbConfigDescriptor for the active device configuration or nullptr | 81 // Gets the UsbConfigDescriptor for the active device configuration or nullptr |
| 77 // if the device is unconfigured. | 82 // if the device is unconfigured. |
| 78 virtual const UsbConfigDescriptor* GetActiveConfiguration() const = 0; | 83 virtual const UsbConfigDescriptor* GetActiveConfiguration() const = 0; |
| 79 | 84 |
| 80 void AddObserver(Observer* observer); | 85 void AddObserver(Observer* observer); |
| 81 void RemoveObserver(Observer* observer); | 86 void RemoveObserver(Observer* observer); |
| 82 | 87 |
| 83 protected: | 88 protected: |
| 84 friend class UsbService; | 89 friend class UsbService; |
| 85 | 90 |
| 86 UsbDevice(uint16_t vendor_id, | 91 UsbDevice(uint16_t usb_version, |
| 92 uint8_t device_class, |
| 93 uint8_t device_subclass, |
| 94 uint8_t device_protocol, |
| 95 uint16_t vendor_id, |
| 87 uint16_t product_id, | 96 uint16_t product_id, |
| 97 uint16_t device_version, |
| 88 const base::string16& manufacturer_string, | 98 const base::string16& manufacturer_string, |
| 89 const base::string16& product_string, | 99 const base::string16& product_string, |
| 90 const base::string16& serial_number); | 100 const base::string16& serial_number); |
| 91 virtual ~UsbDevice(); | 101 virtual ~UsbDevice(); |
| 92 | 102 |
| 93 void NotifyDeviceRemoved(); | 103 void NotifyDeviceRemoved(); |
| 94 | 104 |
| 95 // These members must be mutable by subclasses as necessary during device | 105 // These members must be mutable by subclasses as necessary during device |
| 96 // enumeration. To preserve the thread safety of this object they must remain | 106 // enumeration. To preserve the thread safety of this object they must remain |
| 97 // constant afterwards. | 107 // constant afterwards. |
| 98 base::string16 manufacturer_string_; | 108 base::string16 manufacturer_string_; |
| 99 base::string16 product_string_; | 109 base::string16 product_string_; |
| 100 base::string16 serial_number_; | 110 base::string16 serial_number_; |
| 101 scoped_ptr<WebUsbAllowedOrigins> webusb_allowed_origins_; | 111 scoped_ptr<WebUsbAllowedOrigins> webusb_allowed_origins_; |
| 102 GURL webusb_landing_page_; | 112 GURL webusb_landing_page_; |
| 103 | 113 |
| 104 // All of the device's configuration descriptors. | 114 // All of the device's configuration descriptors. |
| 105 std::vector<UsbConfigDescriptor> configurations_; | 115 std::vector<UsbConfigDescriptor> configurations_; |
| 106 | 116 |
| 107 private: | 117 private: |
| 108 friend class base::RefCountedThreadSafe<UsbDevice>; | 118 friend class base::RefCountedThreadSafe<UsbDevice>; |
| 109 | 119 |
| 110 const std::string guid_; | 120 const std::string guid_; |
| 121 const uint16_t usb_version_; |
| 122 const uint8_t device_class_; |
| 123 const uint8_t device_subclass_; |
| 124 const uint8_t device_protocol_; |
| 111 const uint16_t vendor_id_; | 125 const uint16_t vendor_id_; |
| 112 const uint16_t product_id_; | 126 const uint16_t product_id_; |
| 127 const uint16_t device_version_; |
| 113 | 128 |
| 114 base::ObserverList<Observer, true> observer_list_; | 129 base::ObserverList<Observer, true> observer_list_; |
| 115 | 130 |
| 116 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 131 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
| 117 }; | 132 }; |
| 118 | 133 |
| 119 } // namespace device | 134 } // namespace device |
| 120 | 135 |
| 121 #endif // DEVICE_USB_USB_DEVICE_H_ | 136 #endif // DEVICE_USB_USB_DEVICE_H_ |
| OLD | NEW |