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 #include "device/usb/usb_service_impl.h" | 5 #include "device/usb/usb_service_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | |
9 #include <list> | 8 #include <list> |
10 #include <set> | 9 #include <set> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/barrier_closure.h" | 12 #include "base/barrier_closure.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 if (status != USB_TRANSFER_COMPLETED) { | 190 if (status != USB_TRANSFER_COMPLETED) { |
191 USB_LOG(EVENT) << "Failed to read WebUSB allowed origins."; | 191 USB_LOG(EVENT) << "Failed to read WebUSB allowed origins."; |
192 callback.Run(); | 192 callback.Run(); |
193 return; | 193 return; |
194 } | 194 } |
195 | 195 |
196 scoped_ptr<WebUsbDescriptorSet> descriptors(new WebUsbDescriptorSet()); | 196 scoped_ptr<WebUsbDescriptorSet> descriptors(new WebUsbDescriptorSet()); |
197 if (descriptors->Parse( | 197 if (descriptors->Parse( |
198 std::vector<uint8_t>(buffer->data(), buffer->data() + length))) { | 198 std::vector<uint8_t>(buffer->data(), buffer->data() + length))) { |
199 UsbDeviceImpl* device_impl = static_cast<UsbDeviceImpl*>(device.get()); | 199 UsbDeviceImpl* device_impl = static_cast<UsbDeviceImpl*>(device.get()); |
200 device_impl->set_webusb_allowed_origins(descriptors.Pass()); | 200 device_impl->set_webusb_allowed_origins(std::move(descriptors)); |
201 } | 201 } |
202 callback.Run(); | 202 callback.Run(); |
203 } | 203 } |
204 | 204 |
205 void OnReadWebUsbAllowedOriginsHeader( | 205 void OnReadWebUsbAllowedOriginsHeader( |
206 scoped_refptr<UsbDeviceHandle> device_handle, | 206 scoped_refptr<UsbDeviceHandle> device_handle, |
207 const base::Closure& callback, | 207 const base::Closure& callback, |
208 uint8_t vendor_code, | 208 uint8_t vendor_code, |
209 UsbTransferStatus status, | 209 UsbTransferStatus status, |
210 scoped_refptr<net::IOBuffer> buffer, | 210 scoped_refptr<net::IOBuffer> buffer, |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); | 794 PlatformDeviceMap::iterator it = platform_devices_.find(platform_device); |
795 if (it != platform_devices_.end()) { | 795 if (it != platform_devices_.end()) { |
796 RemoveDevice(it->second); | 796 RemoveDevice(it->second); |
797 } else { | 797 } else { |
798 devices_being_enumerated_.erase(platform_device); | 798 devices_being_enumerated_.erase(platform_device); |
799 } | 799 } |
800 libusb_unref_device(platform_device); | 800 libusb_unref_device(platform_device); |
801 } | 801 } |
802 | 802 |
803 } // namespace device | 803 } // namespace device |
OLD | NEW |