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

Side by Side Diff: device/usb/usb_service_impl.cc

Issue 1542163002: Switch to standard integer types in device/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 5 years 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_service_impl.h ('k') | device/usb/webusb_descriptors.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 #include "device/usb/usb_service_impl.h" 5 #include "device/usb/usb_service_impl.h"
6 6
7 #include <stdint.h>
8
7 #include <list> 9 #include <list>
8 #include <set> 10 #include <set>
9 11
10 #include "base/barrier_closure.h" 12 #include "base/barrier_closure.h"
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 17 #include "base/stl_util.h"
16 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "build/build_config.h"
19 #include "components/device_event_log/device_event_log.h" 22 #include "components/device_event_log/device_event_log.h"
20 #include "device/usb/usb_device_handle.h" 23 #include "device/usb/usb_device_handle.h"
21 #include "device/usb/usb_error.h" 24 #include "device/usb/usb_error.h"
22 #include "device/usb/webusb_descriptors.h" 25 #include "device/usb/webusb_descriptors.h"
23 #include "third_party/libusb/src/libusb/libusb.h" 26 #include "third_party/libusb/src/libusb/libusb.h"
24 27
25 #if defined(OS_WIN) 28 #if defined(OS_WIN)
26 #include <setupapi.h> 29 #include <setupapi.h>
27 #include <usbiodef.h> 30 #include <usbiodef.h>
28 31
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 121 }
119 122
120 void OnReadStringDescriptor( 123 void OnReadStringDescriptor(
121 const base::Callback<void(const base::string16&)>& callback, 124 const base::Callback<void(const base::string16&)>& callback,
122 UsbTransferStatus status, 125 UsbTransferStatus status,
123 scoped_refptr<net::IOBuffer> buffer, 126 scoped_refptr<net::IOBuffer> buffer,
124 size_t length) { 127 size_t length) {
125 base::string16 string; 128 base::string16 string;
126 if (status == USB_TRANSFER_COMPLETED && 129 if (status == USB_TRANSFER_COMPLETED &&
127 ParseUsbStringDescriptor( 130 ParseUsbStringDescriptor(
128 std::vector<uint8>(buffer->data(), buffer->data() + length), 131 std::vector<uint8_t>(buffer->data(), buffer->data() + length),
129 &string)) { 132 &string)) {
130 callback.Run(string); 133 callback.Run(string);
131 } else { 134 } else {
132 callback.Run(base::string16()); 135 callback.Run(base::string16());
133 } 136 }
134 } 137 }
135 138
136 void ReadStringDescriptor( 139 void ReadStringDescriptor(
137 scoped_refptr<UsbDeviceHandle> device_handle, 140 scoped_refptr<UsbDeviceHandle> device_handle,
138 uint8_t index, 141 uint8_t index,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 scoped_refptr<net::IOBuffer> buffer, 188 scoped_refptr<net::IOBuffer> buffer,
186 size_t length) { 189 size_t length) {
187 if (status != USB_TRANSFER_COMPLETED) { 190 if (status != USB_TRANSFER_COMPLETED) {
188 USB_LOG(EVENT) << "Failed to read WebUSB allowed origins."; 191 USB_LOG(EVENT) << "Failed to read WebUSB allowed origins.";
189 callback.Run(); 192 callback.Run();
190 return; 193 return;
191 } 194 }
192 195
193 scoped_ptr<WebUsbDescriptorSet> descriptors(new WebUsbDescriptorSet()); 196 scoped_ptr<WebUsbDescriptorSet> descriptors(new WebUsbDescriptorSet());
194 if (descriptors->Parse( 197 if (descriptors->Parse(
195 std::vector<uint8>(buffer->data(), buffer->data() + length))) { 198 std::vector<uint8_t>(buffer->data(), buffer->data() + length))) {
196 UsbDeviceImpl* device_impl = static_cast<UsbDeviceImpl*>(device.get()); 199 UsbDeviceImpl* device_impl = static_cast<UsbDeviceImpl*>(device.get());
197 device_impl->set_webusb_allowed_origins(descriptors.Pass()); 200 device_impl->set_webusb_allowed_origins(descriptors.Pass());
198 } 201 }
199 callback.Run(); 202 callback.Run();
200 } 203 }
201 204
202 void OnReadWebUsbAllowedOriginsHeader( 205 void OnReadWebUsbAllowedOriginsHeader(
203 scoped_refptr<UsbDeviceHandle> device_handle, 206 scoped_refptr<UsbDeviceHandle> device_handle,
204 const base::Closure& callback, 207 const base::Closure& callback,
205 uint8_t vendor_code, 208 uint8_t vendor_code,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 scoped_refptr<net::IOBuffer> buffer, 243 scoped_refptr<net::IOBuffer> buffer,
241 size_t length) { 244 size_t length) {
242 if (status != USB_TRANSFER_COMPLETED) { 245 if (status != USB_TRANSFER_COMPLETED) {
243 USB_LOG(EVENT) << "Failed to read BOS descriptor."; 246 USB_LOG(EVENT) << "Failed to read BOS descriptor.";
244 callback.Run(); 247 callback.Run();
245 return; 248 return;
246 } 249 }
247 250
248 WebUsbPlatformCapabilityDescriptor descriptor; 251 WebUsbPlatformCapabilityDescriptor descriptor;
249 if (!descriptor.ParseFromBosDescriptor( 252 if (!descriptor.ParseFromBosDescriptor(
250 std::vector<uint8>(buffer->data(), buffer->data() + length))) { 253 std::vector<uint8_t>(buffer->data(), buffer->data() + length))) {
251 callback.Run(); 254 callback.Run();
252 return; 255 return;
253 } 256 }
254 257
255 base::Closure barrier = base::BarrierClosure(2, callback); 258 base::Closure barrier = base::BarrierClosure(2, callback);
256 ReadWebUsbLandingPage(device_handle, barrier, descriptor.vendor_code); 259 ReadWebUsbLandingPage(device_handle, barrier, descriptor.vendor_code);
257 ReadWebUsbAllowedOrigins(device_handle, barrier, descriptor.vendor_code); 260 ReadWebUsbAllowedOrigins(device_handle, barrier, descriptor.vendor_code);
258 } 261 }
259 262
260 void OnReadBosDescriptorHeader(scoped_refptr<UsbDeviceHandle> device_handle, 263 void OnReadBosDescriptorHeader(scoped_refptr<UsbDeviceHandle> device_handle,
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); 794 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device);
792 if (it != platform_devices_.end()) { 795 if (it != platform_devices_.end()) {
793 RemoveDevice(it->second); 796 RemoveDevice(it->second);
794 } else { 797 } else {
795 devices_being_enumerated_.erase(platform_device); 798 devices_being_enumerated_.erase(platform_device);
796 } 799 }
797 libusb_unref_device(platform_device); 800 libusb_unref_device(platform_device);
798 } 801 }
799 802
800 } // namespace device 803 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_service_impl.h ('k') | device/usb/webusb_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698