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

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

Issue 1897483003: Revert of Replace libusb in the Linux/Chrome OS USB I/O path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_handle_usbfs.cc ('k') | device/usb/usb_device_impl.cc » ('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_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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/files/scoped_file.h"
17 #include "base/macros.h" 16 #include "base/macros.h"
18 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
20 #include "device/usb/usb_descriptors.h" 19 #include "device/usb/usb_descriptors.h"
21 #include "device/usb/usb_device.h" 20 #include "device/usb/usb_device.h"
22 #include "device/usb/webusb_descriptors.h" 21 #include "device/usb/webusb_descriptors.h"
23 22
24 struct libusb_device; 23 struct libusb_device;
25 struct libusb_device_descriptor; 24 struct libusb_device_descriptor;
26 struct libusb_device_handle; 25 struct libusb_device_handle;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::unique_ptr<WebUsbAllowedOrigins> allowed_origins) { 67 std::unique_ptr<WebUsbAllowedOrigins> allowed_origins) {
69 webusb_allowed_origins_ = std::move(allowed_origins); 68 webusb_allowed_origins_ = std::move(allowed_origins);
70 } 69 }
71 void set_webusb_landing_page(const GURL& url) { webusb_landing_page_ = url; } 70 void set_webusb_landing_page(const GURL& url) { webusb_landing_page_ = url; }
72 71
73 PlatformUsbDevice platform_device() const { return platform_device_; } 72 PlatformUsbDevice platform_device() const { return platform_device_; }
74 73
75 protected: 74 protected:
76 friend class UsbServiceImpl; 75 friend class UsbServiceImpl;
77 friend class UsbDeviceHandleImpl; 76 friend class UsbDeviceHandleImpl;
78 friend class UsbDeviceHandleUsbfs;
79 77
80 // Called by UsbServiceImpl only; 78 // Called by UsbServiceImpl only;
81 UsbDeviceImpl(scoped_refptr<UsbContext> context, 79 UsbDeviceImpl(scoped_refptr<UsbContext> context,
82 PlatformUsbDevice platform_device, 80 PlatformUsbDevice platform_device,
83 const libusb_device_descriptor& descriptor, 81 const libusb_device_descriptor& descriptor,
84 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); 82 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
85 83
86 ~UsbDeviceImpl() override; 84 ~UsbDeviceImpl() override;
87 85
88 // Called only by UsbServiceImpl. 86 // Called only by UsbServiceImpl.
89 void set_visited(bool visited) { visited_ = visited; } 87 void set_visited(bool visited) { visited_ = visited; }
90 bool was_visited() const { return visited_; } 88 bool was_visited() const { return visited_; }
91 void OnDisconnect(); 89 void OnDisconnect();
92 void ReadAllConfigurations(); 90 void ReadAllConfigurations();
93 91
94 // Called by UsbDeviceHandleImpl. 92 // Called by UsbDeviceHandleImpl.
95 void HandleClosed(UsbDeviceHandle* handle); 93 void HandleClosed(scoped_refptr<UsbDeviceHandle> handle);
96 void ActiveConfigurationChanged(int configuration_value);
97 void RefreshActiveConfiguration(); 94 void RefreshActiveConfiguration();
98 95
99 private: 96 private:
100 void GetAllConfigurations(); 97 void GetAllConfigurations();
101 #if defined(OS_CHROMEOS) 98 #if defined(OS_CHROMEOS)
102 void OnOpenRequestComplete(const OpenCallback& callback, 99 void OnOpenRequestComplete(const OpenCallback& callback,
103 dbus::FileDescriptor fd); 100 dbus::FileDescriptor fd);
104 void OnOpenRequestError(const OpenCallback& callback, 101 void OnOpenRequestError(const OpenCallback& callback,
105 const std::string& error_name, 102 const std::string& error_name,
106 const std::string& error_message); 103 const std::string& error_message);
107 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, 104 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd,
108 const OpenCallback& callback); 105 const OpenCallback& callback);
109 #else 106 #endif
110 void OpenOnBlockingThread(const OpenCallback& callback); 107 void OpenOnBlockingThread(const OpenCallback& callback);
111 #endif // defined(OS_CHROMEOS)
112 #if defined(OS_LINUX)
113 void Opened(base::ScopedFD fd, const OpenCallback& callback);
114 #else
115 void Opened(PlatformUsbDeviceHandle platform_handle, 108 void Opened(PlatformUsbDeviceHandle platform_handle,
116 const OpenCallback& callback); 109 const OpenCallback& callback);
117 #endif // defined(OS_LINUX)
118 110
119 base::ThreadChecker thread_checker_; 111 base::ThreadChecker thread_checker_;
120 PlatformUsbDevice platform_device_; 112 PlatformUsbDevice platform_device_;
121 bool visited_ = false; 113 bool visited_ = false;
122 114
123 // On Chrome OS device path is necessary to request access from the permission 115 // On Chrome OS device path is necessary to request access from the permission
124 // broker. 116 // broker.
125 std::string device_path_; 117 std::string device_path_;
126 118
127 // The current device configuration descriptor. May be null if the device is 119 // The current device configuration descriptor. May be null if the device is
128 // in an unconfigured state; if not null, it is a pointer to one of the 120 // in an unconfigured state; if not null, it is a pointer to one of the
129 // items at UsbDevice::configurations_. 121 // items at UsbDevice::configurations_.
130 const UsbConfigDescriptor* active_configuration_ = nullptr; 122 const UsbConfigDescriptor* active_configuration_ = nullptr;
131 123
132 // Retain the context so that it will not be released before UsbDevice. 124 // Retain the context so that it will not be released before UsbDevice.
133 scoped_refptr<UsbContext> context_; 125 scoped_refptr<UsbContext> context_;
134 126
135 // Opened handles. 127 // Opened handles.
136 std::list<UsbDeviceHandle*> handles_; 128 std::list<UsbDeviceHandle*> handles_;
137 129
138 scoped_refptr<base::SequencedTaskRunner> task_runner_; 130 scoped_refptr<base::SequencedTaskRunner> task_runner_;
139 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 131 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
140 132
141 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); 133 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
142 }; 134 };
143 135
144 } // namespace device 136 } // namespace device
145 137
146 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ 138 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « device/usb/usb_device_handle_usbfs.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698