| 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 | 11 |
| 12 namespace device { | 12 namespace device { |
| 13 | 13 |
| 14 class UsbDeviceHandle; | 14 class UsbDeviceHandle; |
| 15 struct UsbConfigDescriptor; | 15 class UsbConfigDescriptor; |
| 16 | 16 |
| 17 // A UsbDevice object represents a detected USB device, providing basic | 17 // A UsbDevice object represents a detected USB device, providing basic |
| 18 // information about it. For further manipulation of the device, a | 18 // information about it. For further manipulation of the device, a |
| 19 // UsbDeviceHandle must be created from Open() method. | 19 // UsbDeviceHandle must be created from Open() method. |
| 20 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> { | 20 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> { |
| 21 public: | 21 public: |
| 22 // Accessors to basic information. | 22 // Accessors to basic information. |
| 23 uint16 vendor_id() const { return vendor_id_; } | 23 uint16 vendor_id() const { return vendor_id_; } |
| 24 uint16 product_id() const { return product_id_; } | 24 uint16 product_id() const { return product_id_; } |
| 25 uint32 unique_id() const { return unique_id_; } | 25 uint32 unique_id() const { return unique_id_; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 // Creates a UsbDeviceHandle for further manipulation. | 37 // Creates a UsbDeviceHandle for further manipulation. |
| 38 // Blocking method. Must be called on FILE thread. | 38 // Blocking method. Must be called on FILE thread. |
| 39 virtual scoped_refptr<UsbDeviceHandle> Open() = 0; | 39 virtual scoped_refptr<UsbDeviceHandle> Open() = 0; |
| 40 | 40 |
| 41 // Explicitly closes a device handle. This method will be automatically called | 41 // Explicitly closes a device handle. This method will be automatically called |
| 42 // by the destructor of a UsbDeviceHandle as well. | 42 // by the destructor of a UsbDeviceHandle as well. |
| 43 // Closing a closed handle is a safe | 43 // Closing a closed handle is a safe |
| 44 // Blocking method. Must be called on FILE thread. | 44 // Blocking method. Must be called on FILE thread. |
| 45 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; | 45 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0; |
| 46 | 46 |
| 47 // Gets the UsbConfigDescriptor for the active device configuration. | 47 // Lists the interfaces provided by the device and fills the given |
| 48 // UsbConfigDescriptor. |
| 48 // Blocking method. Must be called on FILE thread. | 49 // Blocking method. Must be called on FILE thread. |
| 49 virtual const UsbConfigDescriptor& GetConfiguration() = 0; | 50 virtual scoped_refptr<UsbConfigDescriptor> ListInterfaces() = 0; |
| 50 | 51 |
| 51 protected: | 52 protected: |
| 52 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id) | 53 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id) |
| 53 : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {} | 54 : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {} |
| 54 | 55 |
| 55 virtual ~UsbDevice() {} | 56 virtual ~UsbDevice() {} |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 friend class base::RefCountedThreadSafe<UsbDevice>; | 59 friend class base::RefCountedThreadSafe<UsbDevice>; |
| 59 | 60 |
| 60 const uint16 vendor_id_; | 61 const uint16 vendor_id_; |
| 61 const uint16 product_id_; | 62 const uint16 product_id_; |
| 62 const uint32 unique_id_; | 63 const uint32 unique_id_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(UsbDevice); | 65 DISALLOW_COPY_AND_ASSIGN(UsbDevice); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace device | 68 } // namespace device |
| 68 | 69 |
| 69 #endif // DEVICE_USB_USB_DEVICE_H_ | 70 #endif // DEVICE_USB_USB_DEVICE_H_ |
| OLD | NEW |