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

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

Issue 2690383002: Add device path enumeration to the new Windows USB backend. (Closed)
Patch Set: 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_device.h" 5 #include "device/usb/usb_device.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "device/usb/usb_device_handle.h" 8 #include "device/usb/usb_device_handle.h"
9 #include "device/usb/webusb_descriptors.h" 9 #include "device/usb/webusb_descriptors.h"
10 10
11 namespace device { 11 namespace device {
12 12
13 UsbDevice::Observer::~Observer() {} 13 UsbDevice::Observer::~Observer() {}
14 14
15 void UsbDevice::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {} 15 void UsbDevice::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {}
16 16
17 UsbDevice::UsbDevice()
18 : usb_version_(0),
scheib 2017/02/14 19:40:05 It's fine, but did you consider using default memb
Reilly Grant (use Gerrit) 2017/02/15 22:03:13 Fixed. I was just waiting for another patch to lan
19 device_version_(0),
20 guid_(base::GenerateGUID()),
21 device_class_(0),
22 device_subclass_(0),
23 device_protocol_(0),
24 vendor_id_(0),
25 product_id_(0) {}
26
17 UsbDevice::UsbDevice(uint16_t usb_version, 27 UsbDevice::UsbDevice(uint16_t usb_version,
18 uint8_t device_class, 28 uint8_t device_class,
19 uint8_t device_subclass, 29 uint8_t device_subclass,
20 uint8_t device_protocol, 30 uint8_t device_protocol,
21 uint16_t vendor_id, 31 uint16_t vendor_id,
22 uint16_t product_id, 32 uint16_t product_id,
23 uint16_t device_version, 33 uint16_t device_version,
24 const base::string16& manufacturer_string, 34 const base::string16& manufacturer_string,
25 const base::string16& product_string, 35 const base::string16& product_string,
26 const base::string16& serial_number) 36 const base::string16& serial_number)
27 : usb_version_(usb_version), 37 : usb_version_(usb_version),
28 device_version_(device_version), 38 device_version_(device_version),
29 manufacturer_string_(manufacturer_string), 39 manufacturer_string_(manufacturer_string),
30 product_string_(product_string), 40 product_string_(product_string),
31 serial_number_(serial_number), 41 serial_number_(serial_number),
32 guid_(base::GenerateGUID()), 42 guid_(base::GenerateGUID()),
33 device_class_(device_class), 43 device_class_(device_class),
34 device_subclass_(device_subclass), 44 device_subclass_(device_subclass),
35 device_protocol_(device_protocol), 45 device_protocol_(device_protocol),
36 vendor_id_(vendor_id), 46 vendor_id_(vendor_id),
37 product_id_(product_id) {} 47 product_id_(product_id) {}
38 48
39 UsbDevice::~UsbDevice() { 49 UsbDevice::~UsbDevice() {}
40 }
41 50
42 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) { 51 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) {
43 // By default assume that access to the device is allowed. This is implemented 52 // By default assume that access to the device is allowed. This is implemented
44 // on Chrome OS by checking with permission_broker. 53 // on Chrome OS by checking with permission_broker.
45 callback.Run(true); 54 callback.Run(true);
46 } 55 }
47 56
48 void UsbDevice::RequestPermission(const ResultCallback& callback) { 57 void UsbDevice::RequestPermission(const ResultCallback& callback) {
49 // By default assume that access to the device is allowed. This is implemented 58 // By default assume that access to the device is allowed. This is implemented
50 // on Android by calling android.hardware.usb.UsbManger.requestPermission. 59 // on Android by calling android.hardware.usb.UsbManger.requestPermission.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 handles.swap(handles_); 92 handles.swap(handles_);
84 for (auto* handle : handles_) 93 for (auto* handle : handles_)
85 handle->Close(); 94 handle->Close();
86 } 95 }
87 96
88 void UsbDevice::HandleClosed(UsbDeviceHandle* handle) { 97 void UsbDevice::HandleClosed(UsbDeviceHandle* handle) {
89 handles_.remove(handle); 98 handles_.remove(handle);
90 } 99 }
91 100
92 } // namespace device 101 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698