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

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

Issue 1646783002: Update webusb_descriptors.cc to parse the new WebUSB descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@io_buffer
Patch Set: Sometimes MSVC complains about passing size_type to BarrierClosure. Created 4 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/devices_app/usb/type_converters.cc ('k') | device/usb/usb_device_impl.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 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 #ifndef DEVICE_USB_USB_DEVICE_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_H_
6 #define DEVICE_USB_USB_DEVICE_H_ 6 #define DEVICE_USB_USB_DEVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "device/usb/usb_descriptors.h" 17 #include "device/usb/usb_descriptors.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace device { 20 namespace device {
21 21
22 class UsbDeviceHandle; 22 class UsbDeviceHandle;
23 struct WebUsbDescriptorSet; 23 struct WebUsbAllowedOrigins;
24 24
25 // A UsbDevice object represents a detected USB device, providing basic 25 // A UsbDevice object represents a detected USB device, providing basic
26 // information about it. Methods other than simple property accessors must be 26 // information about it. Methods other than simple property accessors must be
27 // called from the thread on which this object was created. For further 27 // called from the thread on which this object was created. For further
28 // manipulation of the device, a UsbDeviceHandle must be created from Open() 28 // manipulation of the device, a UsbDeviceHandle must be created from Open()
29 // method. 29 // method.
30 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> { 30 class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
31 public: 31 public:
32 using OpenCallback = base::Callback<void(scoped_refptr<UsbDeviceHandle>)>; 32 using OpenCallback = base::Callback<void(scoped_refptr<UsbDeviceHandle>)>;
33 using ResultCallback = base::Callback<void(bool success)>; 33 using ResultCallback = base::Callback<void(bool success)>;
34 34
35 // A unique identifier which remains stable for the lifetime of this device 35 // A unique identifier which remains stable for the lifetime of this device
36 // object (i.e., until the device is unplugged or the USB service dies.) 36 // object (i.e., until the device is unplugged or the USB service dies.)
37 const std::string& guid() const { return guid_; } 37 const std::string& guid() const { return guid_; }
38 38
39 // Accessors to basic information. 39 // Accessors to basic information.
40 uint16_t vendor_id() const { return vendor_id_; } 40 uint16_t vendor_id() const { return vendor_id_; }
41 uint16_t product_id() const { return product_id_; } 41 uint16_t product_id() const { return product_id_; }
42 const base::string16& manufacturer_string() const { 42 const base::string16& manufacturer_string() const {
43 return manufacturer_string_; 43 return manufacturer_string_;
44 } 44 }
45 const base::string16& product_string() const { return product_string_; } 45 const base::string16& product_string() const { return product_string_; }
46 const base::string16& serial_number() const { return serial_number_; } 46 const base::string16& serial_number() const { return serial_number_; }
47 const WebUsbDescriptorSet* webusb_allowed_origins() const { 47 const WebUsbAllowedOrigins* webusb_allowed_origins() const {
48 return webusb_allowed_origins_.get(); 48 return webusb_allowed_origins_.get();
49 } 49 }
50 const GURL& webusb_landing_page() const { return webusb_landing_page_; } 50 const GURL& webusb_landing_page() const { return webusb_landing_page_; }
51 const std::vector<UsbConfigDescriptor>& configurations() const { 51 const std::vector<UsbConfigDescriptor>& configurations() const {
52 return configurations_; 52 return configurations_;
53 } 53 }
54 54
55 // On ChromeOS the permission_broker service is used to change the ownership 55 // On ChromeOS the permission_broker service is used to change the ownership
56 // of USB device nodes so that Chrome can open them. On other platforms these 56 // of USB device nodes so that Chrome can open them. On other platforms these
57 // functions are no-ops and always return true. 57 // functions are no-ops and always return true.
(...skipping 13 matching lines...) Expand all
71 const base::string16& product_string, 71 const base::string16& product_string,
72 const base::string16& serial_number); 72 const base::string16& serial_number);
73 virtual ~UsbDevice(); 73 virtual ~UsbDevice();
74 74
75 // These members must be mutable by subclasses as necessary during device 75 // These members must be mutable by subclasses as necessary during device
76 // enumeration. To preserve the thread safety of this object they must remain 76 // enumeration. To preserve the thread safety of this object they must remain
77 // constant afterwards. 77 // constant afterwards.
78 base::string16 manufacturer_string_; 78 base::string16 manufacturer_string_;
79 base::string16 product_string_; 79 base::string16 product_string_;
80 base::string16 serial_number_; 80 base::string16 serial_number_;
81 scoped_ptr<WebUsbDescriptorSet> webusb_allowed_origins_; 81 scoped_ptr<WebUsbAllowedOrigins> webusb_allowed_origins_;
82 GURL webusb_landing_page_; 82 GURL webusb_landing_page_;
83 83
84 // All of the device's configuration descriptors. 84 // All of the device's configuration descriptors.
85 std::vector<UsbConfigDescriptor> configurations_; 85 std::vector<UsbConfigDescriptor> configurations_;
86 86
87 private: 87 private:
88 friend class base::RefCountedThreadSafe<UsbDevice>; 88 friend class base::RefCountedThreadSafe<UsbDevice>;
89 89
90 const std::string guid_; 90 const std::string guid_;
91 const uint16_t vendor_id_; 91 const uint16_t vendor_id_;
92 const uint16_t product_id_; 92 const uint16_t product_id_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(UsbDevice); 94 DISALLOW_COPY_AND_ASSIGN(UsbDevice);
95 }; 95 };
96 96
97 } // namespace device 97 } // namespace device
98 98
99 #endif // DEVICE_USB_USB_DEVICE_H_ 99 #endif // DEVICE_USB_USB_DEVICE_H_
OLDNEW
« no previous file with comments | « device/devices_app/usb/type_converters.cc ('k') | device/usb/usb_device_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698