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

Side by Side Diff: device/usb/usb_device_handle_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.h ('k') | device/usb/usb_device_handle_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_HANDLE_IMPL_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
6 #define DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_ 6 #define DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "device/usb/usb_device_handle.h" 15 #include "device/usb/usb_device_handle.h"
16 #include "device/usb/usb_interface.h"
16 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
17 #include "third_party/libusb/src/libusb/libusb.h" 18 #include "third_party/libusb/src/libusb/libusb.h"
18 19
19 namespace base { 20 namespace base {
20 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
21 } 22 }
22 23
23 namespace device { 24 namespace device {
24 25
25 class UsbContext; 26 class UsbContext;
26 struct UsbConfigDescriptor; 27 class UsbConfigDescriptor;
27 class UsbDeviceImpl; 28 class UsbDeviceImpl;
28 29
29 typedef libusb_device_handle* PlatformUsbDeviceHandle; 30 typedef libusb_device_handle* PlatformUsbDeviceHandle;
30 typedef libusb_iso_packet_descriptor* PlatformUsbIsoPacketDescriptor; 31 typedef libusb_iso_packet_descriptor* PlatformUsbIsoPacketDescriptor;
31 typedef libusb_transfer* PlatformUsbTransferHandle; 32 typedef libusb_transfer* PlatformUsbTransferHandle;
32 33
33 // UsbDeviceHandle class provides basic I/O related functionalities. 34 // UsbDeviceHandle class provides basic I/O related functionalities.
34 class UsbDeviceHandleImpl : public UsbDeviceHandle { 35 class UsbDeviceHandleImpl : public UsbDeviceHandle {
35 public: 36 public:
36 virtual scoped_refptr<UsbDevice> GetDevice() const OVERRIDE; 37 virtual scoped_refptr<UsbDevice> GetDevice() const OVERRIDE;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 PlatformUsbDeviceHandle handle() const { return handle_; } 83 PlatformUsbDeviceHandle handle() const { return handle_; }
83 84
84 protected: 85 protected:
85 friend class UsbDeviceImpl; 86 friend class UsbDeviceImpl;
86 87
87 // This constructor is called by UsbDevice. 88 // This constructor is called by UsbDevice.
88 UsbDeviceHandleImpl(scoped_refptr<UsbContext> context, 89 UsbDeviceHandleImpl(scoped_refptr<UsbContext> context,
89 UsbDeviceImpl* device, 90 UsbDeviceImpl* device,
90 PlatformUsbDeviceHandle handle, 91 PlatformUsbDeviceHandle handle,
91 const UsbConfigDescriptor& config); 92 scoped_refptr<UsbConfigDescriptor> interfaces);
92 93
93 virtual ~UsbDeviceHandleImpl(); 94 virtual ~UsbDeviceHandleImpl();
94 95
95 private: 96 private:
96 class InterfaceClaimer; 97 class InterfaceClaimer;
97 struct Transfer; 98 struct Transfer;
98 99
99 // Refresh endpoint_map_ after ClaimInterface, ReleaseInterface and 100 // Refresh endpoint_map_ after ClaimInterface, ReleaseInterface and
100 // SetInterfaceAlternateSetting. 101 // SetInterfaceAlternateSetting.
101 void RefreshEndpointMap(); 102 void RefreshEndpointMap();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool GetSupportedLanguages(); 136 bool GetSupportedLanguages();
136 bool GetStringDescriptor(uint8 string_id, base::string16* string); 137 bool GetStringDescriptor(uint8 string_id, base::string16* string);
137 138
138 // Informs the object to drop internal references. 139 // Informs the object to drop internal references.
139 void InternalClose(); 140 void InternalClose();
140 141
141 UsbDeviceImpl* device_; 142 UsbDeviceImpl* device_;
142 143
143 PlatformUsbDeviceHandle handle_; 144 PlatformUsbDeviceHandle handle_;
144 145
145 const UsbConfigDescriptor& config_; 146 scoped_refptr<UsbConfigDescriptor> interfaces_;
146 147
147 std::vector<uint16> languages_; 148 std::vector<uint16> languages_;
148 std::map<uint8, base::string16> strings_; 149 std::map<uint8, base::string16> strings_;
149 150
150 typedef std::map<int, scoped_refptr<InterfaceClaimer> > ClaimedInterfaceMap; 151 typedef std::map<int, scoped_refptr<InterfaceClaimer> > ClaimedInterfaceMap;
151 ClaimedInterfaceMap claimed_interfaces_; 152 ClaimedInterfaceMap claimed_interfaces_;
152 153
153 typedef std::map<PlatformUsbTransferHandle, Transfer> TransferMap; 154 typedef std::map<PlatformUsbTransferHandle, Transfer> TransferMap;
154 TransferMap transfers_; 155 TransferMap transfers_;
155 156
156 // A map from endpoints to interfaces 157 // A map from endpoints to interfaces
157 typedef std::map<int, int> EndpointMap; 158 typedef std::map<int, int> EndpointMap;
158 EndpointMap endpoint_map_; 159 EndpointMap endpoint_map_;
159 160
160 // Retain the UsbContext so that the platform context will not be destroyed 161 // Retain the UsbContext so that the platform context will not be destroyed
161 // before this handle. 162 // before this handle.
162 scoped_refptr<UsbContext> context_; 163 scoped_refptr<UsbContext> context_;
163 164
164 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 165 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
165 166
166 base::ThreadChecker thread_checker_; 167 base::ThreadChecker thread_checker_;
167 168
168 DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl); 169 DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl);
169 }; 170 };
170 171
171 } // namespace device 172 } // namespace device
172 173
173 #endif // DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_ 174 #endif // DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
OLDNEW
« no previous file with comments | « device/usb/usb_device_handle.h ('k') | device/usb/usb_device_handle_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698