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

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

Issue 2688303002: Add a feature flag for the new Windows USB backend. (Closed)
Patch Set: Update histograms. Created 3 years, 10 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_service_android.cc ('k') | device/usb/usb_service_linux.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> 7 #include <stdint.h>
8 8
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/barrier_closure.h" 14 #include "base/barrier_closure.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 22 #include "build/build_config.h"
24 #include "components/device_event_log/device_event_log.h" 23 #include "components/device_event_log/device_event_log.h"
25 #include "device/usb/usb_device_handle.h" 24 #include "device/usb/usb_device_handle.h"
26 #include "device/usb/usb_error.h" 25 #include "device/usb/usb_error.h"
27 #include "device/usb/webusb_descriptors.h" 26 #include "device/usb/webusb_descriptors.h"
28 #include "net/base/io_buffer.h" 27 #include "net/base/io_buffer.h"
29 #include "third_party/libusb/src/libusb/libusb.h" 28 #include "third_party/libusb/src/libusb/libusb.h"
30 29
31 #if defined(OS_WIN) 30 #if defined(OS_WIN)
32 #include <setupapi.h> 31 #include <setupapi.h>
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 device_handle, barrier)); 207 device_handle, barrier));
209 } 208 }
210 } else { 209 } else {
211 failure_closure.Run(); 210 failure_closure.Run();
212 } 211 }
213 } 212 }
214 213
215 } // namespace 214 } // namespace
216 215
217 UsbServiceImpl::UsbServiceImpl( 216 UsbServiceImpl::UsbServiceImpl(
218 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 217 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_in)
219 : UsbService(base::ThreadTaskRunnerHandle::Get(), blocking_task_runner), 218 : UsbService(std::move(blocking_task_runner_in)),
220 #if defined(OS_WIN) 219 #if defined(OS_WIN)
221 device_observer_(this), 220 device_observer_(this),
222 #endif 221 #endif
223 weak_factory_(this) { 222 weak_factory_(this) {
224 blocking_task_runner->PostTask( 223 blocking_task_runner()->PostTask(
225 FROM_HERE, base::Bind(&InitializeUsbContextOnBlockingThread, 224 FROM_HERE,
226 base::ThreadTaskRunnerHandle::Get(), 225 base::Bind(&InitializeUsbContextOnBlockingThread, task_runner(),
227 base::Bind(&UsbServiceImpl::OnUsbContext, 226 base::Bind(&UsbServiceImpl::OnUsbContext,
228 weak_factory_.GetWeakPtr()))); 227 weak_factory_.GetWeakPtr())));
229 } 228 }
230 229
231 UsbServiceImpl::~UsbServiceImpl() { 230 UsbServiceImpl::~UsbServiceImpl() {
232 if (hotplug_enabled_) 231 if (hotplug_enabled_)
233 libusb_hotplug_deregister_callback(context_->context(), hotplug_handle_); 232 libusb_hotplug_deregister_callback(context_->context(), hotplug_handle_);
234 for (auto* platform_device : ignored_devices_) 233 for (auto* platform_device : ignored_devices_)
235 libusb_unref_device(platform_device); 234 libusb_unref_device(platform_device);
236 } 235 }
237 236
238 void UsbServiceImpl::GetDevices(const GetDevicesCallback& callback) { 237 void UsbServiceImpl::GetDevices(const GetDevicesCallback& callback) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 548 }
550 549
551 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device, 550 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device,
552 const base::Closure& refresh_complete) { 551 const base::Closure& refresh_complete) {
553 libusb_ref_device(platform_device); 552 libusb_ref_device(platform_device);
554 ignored_devices_.insert(platform_device); 553 ignored_devices_.insert(platform_device);
555 refresh_complete.Run(); 554 refresh_complete.Run();
556 } 555 }
557 556
558 } // namespace device 557 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_service_android.cc ('k') | device/usb/usb_service_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698