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 <vector> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
12 | 14 |
13 namespace device { | 15 namespace device { |
14 | 16 |
15 class UsbDeviceHandle; | 17 class UsbDeviceHandle; |
16 struct UsbConfigDescriptor; | 18 struct UsbConfigDescriptor; |
17 | 19 |
(...skipping 27 matching lines...) Expand all Loading... | |
45 | 47 |
46 // Creates a UsbDeviceHandle for further manipulation. | 48 // Creates a UsbDeviceHandle for further manipulation. |
47 virtual void Open(const OpenCallback& callback) = 0; | 49 virtual void Open(const OpenCallback& callback) = 0; |
48 | 50 |
49 // Explicitly closes a device handle. This method will be automatically called | 51 // Explicitly closes a device handle. This method will be automatically called |
50 // by the destructor of a UsbDeviceHandle as well. | 52 // by the destructor of a UsbDeviceHandle as well. |
51 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; | 53 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; |
52 | 54 |
53 // Gets the UsbConfigDescriptor for the active device configuration or nullptr | 55 // Gets the UsbConfigDescriptor for the active device configuration or nullptr |
54 // if the device is unconfigured. | 56 // if the device is unconfigured. |
55 virtual const UsbConfigDescriptor* GetConfiguration() = 0; | 57 virtual const UsbConfigDescriptor* GetCurrentConfiguration() = 0; |
Reilly Grant (use Gerrit)
2015/07/31 23:36:12
GetCurrentConfiguration -> GetActiveConfiguration
juncai
2015/08/03 17:46:01
Done.
| |
58 | |
59 // Gets all the UsbConfigDescriptor for the device configuration. | |
60 virtual const std::vector<UsbConfigDescriptor>& configurations() const = 0; | |
Reilly Grant (use Gerrit)
2015/07/31 23:36:12
I'd rather this was not a virtual function. You ca
juncai
2015/08/03 17:46:01
Done.
| |
56 | 61 |
57 protected: | 62 protected: |
58 UsbDevice(uint16 vendor_id, | 63 UsbDevice(uint16 vendor_id, |
59 uint16 product_id, | 64 uint16 product_id, |
60 const base::string16& manufacturer_string, | 65 const base::string16& manufacturer_string, |
61 const base::string16& product_string, | 66 const base::string16& product_string, |
62 const base::string16& serial_number); | 67 const base::string16& serial_number); |
63 virtual ~UsbDevice(); | 68 virtual ~UsbDevice(); |
64 | 69 |
65 // These members must be mutable by subclasses as necessary during device | 70 // These members must be mutable by subclasses as necessary during device |
66 // enumeration. To preserve the thread safety of this object they must remain | 71 // enumeration. To preserve the thread safety of this object they must remain |
67 // constant afterwards. | 72 // constant afterwards. |
68 base::string16 manufacturer_string_; | 73 base::string16 manufacturer_string_; |
69 base::string16 product_string_; | 74 base::string16 product_string_; |
70 base::string16 serial_number_; | 75 base::string16 serial_number_; |
71 | 76 |
72 private: | 77 private: |
73 friend class base::RefCountedThreadSafe<UsbDevice>; | 78 friend class base::RefCountedThreadSafe<UsbDevice>; |
74 | 79 |
75 const std::string guid_; | 80 const std::string guid_; |
76 const uint16 vendor_id_; | 81 const uint16 vendor_id_; |
77 const uint16 product_id_; | 82 const uint16 product_id_; |
78 | 83 |
79 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 84 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
80 }; | 85 }; |
81 | 86 |
82 } // namespace device | 87 } // namespace device |
83 | 88 |
84 #endif // DEVICE_USB_USB_DEVICE_H_ | 89 #endif // DEVICE_USB_USB_DEVICE_H_ |
OLD | NEW |