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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/strings/string16.h" |
12 | 13 |
13 namespace device { | 14 namespace device { |
14 | 15 |
15 class UsbDeviceHandle; | 16 class UsbDeviceHandle; |
16 struct UsbConfigDescriptor; | 17 struct UsbConfigDescriptor; |
17 | 18 |
18 // A UsbDevice object represents a detected USB device, providing basic | 19 // A UsbDevice object represents a detected USB device, providing basic |
19 // information about it. For further manipulation of the device, a | 20 // information about it. For further manipulation of the device, a |
20 // UsbDeviceHandle must be created from Open() method. | 21 // UsbDeviceHandle must be created from Open() method. |
21 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> { | 22 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> { |
(...skipping 25 matching lines...) Expand all Loading... |
47 // Explicitly closes a device handle. This method will be automatically called | 48 // Explicitly closes a device handle. This method will be automatically called |
48 // by the destructor of a UsbDeviceHandle as well. | 49 // by the destructor of a UsbDeviceHandle as well. |
49 // Closing a closed handle is a safe | 50 // Closing a closed handle is a safe |
50 // Blocking method. Must be called on FILE thread. | 51 // Blocking method. Must be called on FILE thread. |
51 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; | 52 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; |
52 | 53 |
53 // Gets the UsbConfigDescriptor for the active device configuration. | 54 // Gets the UsbConfigDescriptor for the active device configuration. |
54 // Blocking method. Must be called on FILE thread. | 55 // Blocking method. Must be called on FILE thread. |
55 virtual const UsbConfigDescriptor& GetConfiguration() = 0; | 56 virtual const UsbConfigDescriptor& GetConfiguration() = 0; |
56 | 57 |
| 58 // Gets the manufacturer string of the device, or returns false. |
| 59 // Blocking method. Must be called on FILE thread. |
| 60 virtual bool GetManufacturer(base::string16* manufacturer) = 0; |
| 61 |
| 62 // Gets the product string of the device, or returns false. |
| 63 // Blocking method. Must be called on FILE thread. |
| 64 virtual bool GetProduct(base::string16* product) = 0; |
| 65 |
| 66 // Gets the serial number string of the device, or returns false. |
| 67 // Blocking method. Must be called on FILE thread. |
| 68 virtual bool GetSerialNumber(base::string16* serial) = 0; |
| 69 |
57 void AddObserver(Observer* obs) { observer_list_.AddObserver(obs); } | 70 void AddObserver(Observer* obs) { observer_list_.AddObserver(obs); } |
58 void RemoveObserver(Observer* obs) { observer_list_.RemoveObserver(obs); } | 71 void RemoveObserver(Observer* obs) { observer_list_.RemoveObserver(obs); } |
59 | 72 |
60 protected: | 73 protected: |
61 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id); | 74 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id); |
62 virtual ~UsbDevice(); | 75 virtual ~UsbDevice(); |
63 | 76 |
64 void NotifyDisconnect(); | 77 void NotifyDisconnect(); |
65 | 78 |
66 private: | 79 private: |
67 friend class base::RefCountedThreadSafe<UsbDevice>; | 80 friend class base::RefCountedThreadSafe<UsbDevice>; |
68 | 81 |
69 const uint16 vendor_id_; | 82 const uint16 vendor_id_; |
70 const uint16 product_id_; | 83 const uint16 product_id_; |
71 const uint32 unique_id_; | 84 const uint32 unique_id_; |
72 | 85 |
73 ObserverList<Observer> observer_list_; | 86 ObserverList<Observer> observer_list_; |
74 | 87 |
75 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 88 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
76 }; | 89 }; |
77 | 90 |
78 } // namespace device | 91 } // namespace device |
79 | 92 |
80 #endif // DEVICE_USB_USB_DEVICE_H_ | 93 #endif // DEVICE_USB_USB_DEVICE_H_ |
OLD | NEW |