OLD | NEW |
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> | |
9 | |
10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
11 #include "base/callback.h" | 9 #include "base/callback.h" |
12 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
13 #include "device/usb/usb_descriptors.h" | 11 #include "device/usb/usb_descriptors.h" |
14 #include "device/usb/usb_device.h" | 12 #include "device/usb/usb_device.h" |
15 | 13 |
16 struct libusb_device; | 14 struct libusb_device; |
17 struct libusb_config_descriptor; | 15 struct libusb_config_descriptor; |
18 struct libusb_device_handle; | 16 struct libusb_device_handle; |
19 | 17 |
(...skipping 15 matching lines...) Expand all Loading... |
35 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; | 33 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; |
36 | 34 |
37 class UsbDeviceImpl : public UsbDevice { | 35 class UsbDeviceImpl : public UsbDevice { |
38 public: | 36 public: |
39 // UsbDevice implementation: | 37 // UsbDevice implementation: |
40 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
41 void CheckUsbAccess(const ResultCallback& callback) override; | 39 void CheckUsbAccess(const ResultCallback& callback) override; |
42 #endif // OS_CHROMEOS | 40 #endif // OS_CHROMEOS |
43 void Open(const OpenCallback& callback) override; | 41 void Open(const OpenCallback& callback) override; |
44 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; | 42 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; |
45 const UsbConfigDescriptor* GetConfiguration() override; | 43 const UsbConfigDescriptor* GetCurrentConfiguration() override; |
| 44 const std::vector<UsbConfigDescriptor>& configurations() const override; |
46 | 45 |
47 // These functions are used during enumeration only. The values must not | 46 // These functions are used during enumeration only. The values must not |
48 // change during the object's lifetime. | 47 // change during the object's lifetime. |
49 void set_manufacturer_string(const base::string16& value) { | 48 void set_manufacturer_string(const base::string16& value) { |
50 manufacturer_string_ = value; | 49 manufacturer_string_ = value; |
51 } | 50 } |
52 void set_product_string(const base::string16& value) { | 51 void set_product_string(const base::string16& value) { |
53 product_string_ = value; | 52 product_string_ = value; |
54 } | 53 } |
55 void set_serial_number(const base::string16& value) { | 54 void set_serial_number(const base::string16& value) { |
(...skipping 18 matching lines...) Expand all Loading... |
74 | 73 |
75 // Called only by UsbServiceImpl. | 74 // Called only by UsbServiceImpl. |
76 void set_visited(bool visited) { visited_ = visited; } | 75 void set_visited(bool visited) { visited_ = visited; } |
77 bool was_visited() const { return visited_; } | 76 bool was_visited() const { return visited_; } |
78 void OnDisconnect(); | 77 void OnDisconnect(); |
79 | 78 |
80 // Called by UsbDeviceHandleImpl. | 79 // Called by UsbDeviceHandleImpl. |
81 void RefreshConfiguration(); | 80 void RefreshConfiguration(); |
82 | 81 |
83 private: | 82 private: |
| 83 void GetAllConfigurations(); |
84 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
85 void OnOpenRequestComplete(const OpenCallback& callback, | 85 void OnOpenRequestComplete(const OpenCallback& callback, |
86 dbus::FileDescriptor fd); | 86 dbus::FileDescriptor fd); |
87 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, | 87 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, |
88 const OpenCallback& callback); | 88 const OpenCallback& callback); |
89 #endif | 89 #endif |
90 void OpenOnBlockingThread(const OpenCallback& callback); | 90 void OpenOnBlockingThread(const OpenCallback& callback); |
91 void Opened(PlatformUsbDeviceHandle platform_handle, | 91 void Opened(PlatformUsbDeviceHandle platform_handle, |
92 const OpenCallback& callback); | 92 const OpenCallback& callback); |
93 | 93 |
94 base::ThreadChecker thread_checker_; | 94 base::ThreadChecker thread_checker_; |
95 PlatformUsbDevice platform_device_; | 95 PlatformUsbDevice platform_device_; |
96 bool visited_ = false; | 96 bool visited_ = false; |
97 | 97 |
98 // On Chrome OS device path is necessary to request access from the permission | 98 // On Chrome OS device path is necessary to request access from the permission |
99 // broker. | 99 // broker. |
100 std::string device_path_; | 100 std::string device_path_; |
101 | 101 |
102 // The current device configuration descriptor. May be null if the device is | 102 // The current device configuration descriptor. May be null if the device is |
103 // in an unconfigured state. | 103 // in an unconfigured state. |
104 scoped_ptr<UsbConfigDescriptor> configuration_; | 104 scoped_ptr<UsbConfigDescriptor> configuration_; |
105 | 105 |
| 106 // The device's all configuration descriptors. |
| 107 std::vector<UsbConfigDescriptor> configurations_; |
| 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_ |
OLD | NEW |