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

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

Issue 1265833005: Get all the UsbConfigDescriptor for the device configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use const auto Created 5 years, 4 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 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_IMPL_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_IMPL_H_
6 #define DEVICE_USB_USB_DEVICE_IMPL_H_ 6 #define DEVICE_USB_USB_DEVICE_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 24 matching lines...) Expand all
35 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; 35 typedef struct libusb_device_handle* PlatformUsbDeviceHandle;
36 36
37 class UsbDeviceImpl : public UsbDevice { 37 class UsbDeviceImpl : public UsbDevice {
38 public: 38 public:
39 // UsbDevice implementation: 39 // UsbDevice implementation:
40 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
41 void CheckUsbAccess(const ResultCallback& callback) override; 41 void CheckUsbAccess(const ResultCallback& callback) override;
42 #endif // OS_CHROMEOS 42 #endif // OS_CHROMEOS
43 void Open(const OpenCallback& callback) override; 43 void Open(const OpenCallback& callback) override;
44 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; 44 bool Close(scoped_refptr<UsbDeviceHandle> handle) override;
45 const UsbConfigDescriptor* GetConfiguration() override; 45 const UsbConfigDescriptor* GetActiveConfiguration() override;
46 46
47 // These functions are used during enumeration only. The values must not 47 // These functions are used during enumeration only. The values must not
48 // change during the object's lifetime. 48 // change during the object's lifetime.
49 void set_manufacturer_string(const base::string16& value) { 49 void set_manufacturer_string(const base::string16& value) {
50 manufacturer_string_ = value; 50 manufacturer_string_ = value;
51 } 51 }
52 void set_product_string(const base::string16& value) { 52 void set_product_string(const base::string16& value) {
53 product_string_ = value; 53 product_string_ = value;
54 } 54 }
55 void set_serial_number(const base::string16& value) { 55 void set_serial_number(const base::string16& value) {
(...skipping 13 matching lines...) Expand all
69 uint16 vendor_id, 69 uint16 vendor_id,
70 uint16 product_id, 70 uint16 product_id,
71 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); 71 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
72 72
73 ~UsbDeviceImpl() override; 73 ~UsbDeviceImpl() override;
74 74
75 // Called only by UsbServiceImpl. 75 // Called only by UsbServiceImpl.
76 void set_visited(bool visited) { visited_ = visited; } 76 void set_visited(bool visited) { visited_ = visited; }
77 bool was_visited() const { return visited_; } 77 bool was_visited() const { return visited_; }
78 void OnDisconnect(); 78 void OnDisconnect();
79 void ReadAllConfigurations();
79 80
80 // Called by UsbDeviceHandleImpl. 81 // Called by UsbDeviceHandleImpl.
81 void RefreshConfiguration(); 82 void RefreshActiveConfiguration();
82 83
83 private: 84 private:
85 void GetAllConfigurations();
84 #if defined(OS_CHROMEOS) 86 #if defined(OS_CHROMEOS)
85 void OnOpenRequestComplete(const OpenCallback& callback, 87 void OnOpenRequestComplete(const OpenCallback& callback,
86 dbus::FileDescriptor fd); 88 dbus::FileDescriptor fd);
87 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, 89 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd,
88 const OpenCallback& callback); 90 const OpenCallback& callback);
89 #endif 91 #endif
90 void OpenOnBlockingThread(const OpenCallback& callback); 92 void OpenOnBlockingThread(const OpenCallback& callback);
91 void Opened(PlatformUsbDeviceHandle platform_handle, 93 void Opened(PlatformUsbDeviceHandle platform_handle,
92 const OpenCallback& callback); 94 const OpenCallback& callback);
93 95
94 base::ThreadChecker thread_checker_; 96 base::ThreadChecker thread_checker_;
95 PlatformUsbDevice platform_device_; 97 PlatformUsbDevice platform_device_;
96 bool visited_ = false; 98 bool visited_ = false;
97 99
98 // On Chrome OS device path is necessary to request access from the permission 100 // On Chrome OS device path is necessary to request access from the permission
99 // broker. 101 // broker.
100 std::string device_path_; 102 std::string device_path_;
101 103
102 // The current device configuration descriptor. May be null if the device is 104 // The current device configuration descriptor. May be null if the device is
103 // in an unconfigured state. 105 // in an unconfigured state; if not null, it is a pointer to one of the
104 scoped_ptr<UsbConfigDescriptor> configuration_; 106 // items at UsbDevice::configurations_.
107 const UsbConfigDescriptor* active_configuration_;
105 108
106 // Retain the context so that it will not be released before UsbDevice. 109 // Retain the context so that it will not be released before UsbDevice.
107 scoped_refptr<UsbContext> context_; 110 scoped_refptr<UsbContext> context_;
108 111
109 // Opened handles. 112 // Opened handles.
110 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; 113 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector;
111 HandlesVector handles_; 114 HandlesVector handles_;
112 115
113 scoped_refptr<base::SequencedTaskRunner> task_runner_; 116 scoped_refptr<base::SequencedTaskRunner> task_runner_;
114 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 117 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
115 118
116 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); 119 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
117 }; 120 };
118 121
119 } // namespace device 122 } // namespace device
120 123
121 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ 124 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698