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

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

Issue 2690383002: Add device path enumeration to the new Windows USB backend. (Closed)
Patch Set: Fix a comment. 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_device.h ('k') | device/usb/usb_device_win.h » ('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 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() : guid_(base::GenerateGUID()) {}
18
17 UsbDevice::UsbDevice(const UsbDeviceDescriptor& descriptor, 19 UsbDevice::UsbDevice(const UsbDeviceDescriptor& descriptor,
18 const base::string16& manufacturer_string, 20 const base::string16& manufacturer_string,
19 const base::string16& product_string, 21 const base::string16& product_string,
20 const base::string16& serial_number) 22 const base::string16& serial_number)
21 : descriptor_(descriptor), 23 : descriptor_(descriptor),
22 manufacturer_string_(manufacturer_string), 24 manufacturer_string_(manufacturer_string),
23 product_string_(product_string), 25 product_string_(product_string),
24 serial_number_(serial_number), 26 serial_number_(serial_number),
25 guid_(base::GenerateGUID()) {} 27 guid_(base::GenerateGUID()) {}
26 28
(...skipping 13 matching lines...) Expand all
40 guid_(base::GenerateGUID()) { 42 guid_(base::GenerateGUID()) {
41 descriptor_.usb_version = usb_version; 43 descriptor_.usb_version = usb_version;
42 descriptor_.device_class = device_class; 44 descriptor_.device_class = device_class;
43 descriptor_.device_subclass = device_subclass; 45 descriptor_.device_subclass = device_subclass;
44 descriptor_.device_protocol = device_protocol; 46 descriptor_.device_protocol = device_protocol;
45 descriptor_.vendor_id = vendor_id; 47 descriptor_.vendor_id = vendor_id;
46 descriptor_.product_id = product_id; 48 descriptor_.product_id = product_id;
47 descriptor_.device_version = device_version; 49 descriptor_.device_version = device_version;
48 } 50 }
49 51
50 UsbDevice::~UsbDevice() { 52 UsbDevice::~UsbDevice() {}
51 }
52 53
53 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) { 54 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) {
54 // By default assume that access to the device is allowed. This is implemented 55 // By default assume that access to the device is allowed. This is implemented
55 // on Chrome OS by checking with permission_broker. 56 // on Chrome OS by checking with permission_broker.
56 callback.Run(true); 57 callback.Run(true);
57 } 58 }
58 59
59 void UsbDevice::RequestPermission(const ResultCallback& callback) { 60 void UsbDevice::RequestPermission(const ResultCallback& callback) {
60 // By default assume that access to the device is allowed. This is implemented 61 // By default assume that access to the device is allowed. This is implemented
61 // on Android by calling android.hardware.usb.UsbManger.requestPermission. 62 // on Android by calling android.hardware.usb.UsbManger.requestPermission.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 handles.swap(handles_); 95 handles.swap(handles_);
95 for (auto* handle : handles_) 96 for (auto* handle : handles_)
96 handle->Close(); 97 handle->Close();
97 } 98 }
98 99
99 void UsbDevice::HandleClosed(UsbDeviceHandle* handle) { 100 void UsbDevice::HandleClosed(UsbDeviceHandle* handle) {
100 handles_.remove(handle); 101 handles_.remove(handle);
101 } 102 }
102 103
103 } // namespace device 104 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device.h ('k') | device/usb/usb_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698