Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: device/usb/usb_device.h

Issue 562763002: Convert device::UsbConfigDescriptor and friends to structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add interface and endpoint descriptor iterator typedefs. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/usb_descriptors.cc ('k') | device/usb/usb_device_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class UsbConfigDescriptor; 15 struct 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
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 // Lists the interfaces provided by the device and fills the given 47 // Gets the UsbConfigDescriptor for the active device configuration.
48 // UsbConfigDescriptor.
49 // Blocking method. Must be called on FILE thread. 48 // Blocking method. Must be called on FILE thread.
50 virtual scoped_refptr<UsbConfigDescriptor> ListInterfaces() = 0; 49 virtual const UsbConfigDescriptor& GetConfiguration() = 0;
51 50
52 protected: 51 protected:
53 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id) 52 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id)
54 : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {} 53 : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {}
55 54
56 virtual ~UsbDevice() {} 55 virtual ~UsbDevice() {}
57 56
58 private: 57 private:
59 friend class base::RefCountedThreadSafe<UsbDevice>; 58 friend class base::RefCountedThreadSafe<UsbDevice>;
60 59
61 const uint16 vendor_id_; 60 const uint16 vendor_id_;
62 const uint16 product_id_; 61 const uint16 product_id_;
63 const uint32 unique_id_; 62 const uint32 unique_id_;
64 63
65 DISALLOW_COPY_AND_ASSIGN(UsbDevice); 64 DISALLOW_COPY_AND_ASSIGN(UsbDevice);
66 }; 65 };
67 66
68 } // namespace device 67 } // namespace device
69 68
70 #endif // DEVICE_USB_USB_DEVICE_H_ 69 #endif // DEVICE_USB_USB_DEVICE_H_
OLDNEW
« no previous file with comments | « device/usb/usb_descriptors.cc ('k') | device/usb/usb_device_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698