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

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

Issue 567003002: Revert of Convert device::UsbConfigDescriptor and friends to structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_device_handle_impl.cc ('k') | device/usb/usb_device_impl.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_IMPL_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_IMPL_H_
6 #define DEVICE_USB_USB_DEVICE_IMPL_H_ 6 #define DEVICE_USB_USB_DEVICE_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "device/usb/usb_descriptors.h"
14 #include "device/usb/usb_device.h" 13 #include "device/usb/usb_device.h"
15 14
16 struct libusb_device; 15 struct libusb_device;
17 struct libusb_config_descriptor; 16 struct libusb_config_descriptor;
18 17
19 namespace base { 18 namespace base {
20 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
21 } 20 }
22 21
23 namespace device { 22 namespace device {
24 23
25 class UsbDeviceHandleImpl; 24 class UsbDeviceHandleImpl;
26 class UsbContext; 25 class UsbContext;
27 26
28 typedef libusb_device* PlatformUsbDevice; 27 typedef libusb_device* PlatformUsbDevice;
29 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; 28 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
30 29
31 class UsbDeviceImpl : public UsbDevice { 30 class UsbDeviceImpl : public UsbDevice {
32 public: 31 public:
33 // UsbDevice implementation: 32 // UsbDevice implementation:
34 #if defined(OS_CHROMEOS) 33 #if defined(OS_CHROMEOS)
35 virtual void RequestUsbAccess( 34 virtual void RequestUsbAccess(
36 int interface_id, 35 int interface_id,
37 const base::Callback<void(bool success)>& callback) OVERRIDE; 36 const base::Callback<void(bool success)>& callback) OVERRIDE;
38 #endif // OS_CHROMEOS 37 #endif // OS_CHROMEOS
39 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE; 38 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE;
40 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE; 39 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE;
41 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE; 40 virtual scoped_refptr<UsbConfigDescriptor> ListInterfaces() OVERRIDE;
42 41
43 protected: 42 protected:
44 friend class UsbServiceImpl; 43 friend class UsbServiceImpl;
45 44
46 // Called by UsbServiceImpl only; 45 // Called by UsbServiceImpl only;
47 UsbDeviceImpl(scoped_refptr<UsbContext> context, 46 UsbDeviceImpl(scoped_refptr<UsbContext> context,
48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
49 PlatformUsbDevice platform_device, 48 PlatformUsbDevice platform_device,
50 uint16 vendor_id, 49 uint16 vendor_id,
51 uint16 product_id, 50 uint16 product_id,
52 uint32 unique_id); 51 uint32 unique_id);
53 52
54 virtual ~UsbDeviceImpl(); 53 virtual ~UsbDeviceImpl();
55 54
56 // Called only be UsbService. 55 // Called only be UsbService.
57 void OnDisconnect(); 56 void OnDisconnect();
58 57
59 private: 58 private:
60 base::ThreadChecker thread_checker_; 59 base::ThreadChecker thread_checker_;
61 PlatformUsbDevice platform_device_; 60 PlatformUsbDevice platform_device_;
62 61
63 // The active configuration descriptor is not read immediately but cached for
64 // later use.
65 bool current_configuration_cached_;
66 UsbConfigDescriptor current_configuration_;
67
68 // Retain the context so that it will not be released before UsbDevice. 62 // Retain the context so that it will not be released before UsbDevice.
69 scoped_refptr<UsbContext> context_; 63 scoped_refptr<UsbContext> context_;
70 64
71 // Opened handles. 65 // Opened handles.
72 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; 66 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector;
73 HandlesVector handles_; 67 HandlesVector handles_;
74 68
75 // Reference to the UI thread for permission-broker calls. 69 // Reference to the UI thread for permission-broker calls.
76 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 70 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
77 71
78 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); 72 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
79 }; 73 };
80 74
81 } // namespace device 75 } // namespace device
82 76
83 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ 77 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « device/usb/usb_device_handle_impl.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698