Index: device/usb/usb_device_impl.h |
diff --git a/device/usb/usb_device_impl.h b/device/usb/usb_device_impl.h |
index 897b4910fe045d33e37bdf4c3df97057ebc9d7a1..a865ea216102645216f3f1c43fe0c5899e636123 100644 |
--- a/device/usb/usb_device_impl.h |
+++ b/device/usb/usb_device_impl.h |
@@ -15,9 +15,10 @@ |
struct libusb_device; |
struct libusb_config_descriptor; |
+struct libusb_device_handle; |
namespace base { |
-class SingleThreadTaskRunner; |
+class SequencedTaskRunner; |
} |
namespace device { |
@@ -25,8 +26,9 @@ namespace device { |
class UsbDeviceHandleImpl; |
class UsbContext; |
-typedef libusb_device* PlatformUsbDevice; |
-typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; |
+typedef struct libusb_device* PlatformUsbDevice; |
+typedef struct libusb_config_descriptor* PlatformUsbConfigDescriptor; |
+typedef struct libusb_device_handle* PlatformUsbDeviceHandle; |
class UsbDeviceImpl : public UsbDevice { |
public: |
@@ -37,12 +39,9 @@ class UsbDeviceImpl : public UsbDevice { |
void RequestUsbAccess(int interface_id, |
const ResultCallback& callback) override; |
#endif // OS_CHROMEOS |
- scoped_refptr<UsbDeviceHandle> Open() override; |
+ void Open(const OpenCallback& callback) override; |
bool Close(scoped_refptr<UsbDeviceHandle> handle) override; |
const UsbConfigDescriptor* GetConfiguration() override; |
- bool GetManufacturer(base::string16* manufacturer) override; |
- bool GetProduct(base::string16* product) override; |
- bool GetSerialNumber(base::string16* serial_number) override; |
protected: |
friend class UsbServiceImpl; |
@@ -50,37 +49,35 @@ class UsbDeviceImpl : public UsbDevice { |
// Called by UsbServiceImpl only; |
UsbDeviceImpl(scoped_refptr<UsbContext> context, |
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
PlatformUsbDevice platform_device, |
uint16 vendor_id, |
uint16 product_id, |
- uint32 unique_id); |
+ uint32 unique_id, |
+ const base::string16& manufacturer_string, |
+ const base::string16& product_string, |
+ const base::string16& serial_number, |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
~UsbDeviceImpl() override; |
// Called only by UsbServiceImpl. |
+ PlatformUsbDevice platform_device() const { return platform_device_; } |
+ void set_visited(bool visited) { visited_ = visited; } |
+ bool was_visited() const { return visited_; } |
void OnDisconnect(); |
// Called by UsbDeviceHandleImpl. |
void RefreshConfiguration(); |
private: |
+ void OpenOnBlockingThread(const OpenCallback& callback); |
+ void Opened(PlatformUsbDeviceHandle platform_handle, |
+ const OpenCallback& callback); |
+ |
base::ThreadChecker thread_checker_; |
PlatformUsbDevice platform_device_; |
+ bool visited_ = false; |
- // On Linux these properties are read from sysfs when the device is enumerated |
- // to avoid hitting the permission broker on Chrome OS for a real string |
- // descriptor request. |
- base::string16 manufacturer_; |
- base::string16 product_; |
- base::string16 serial_number_; |
-#if !defined(USE_UDEV) |
- // On other platforms the device must be opened in order to cache them. This |
- // should be delayed until the strings are needed to avoid poor interactions |
- // with other applications. |
- void CacheStrings(); |
- bool strings_cached_; |
-#endif |
#if defined(OS_CHROMEOS) |
// On Chrome OS save the devnode string for requesting path access from |
// permission broker. |
@@ -98,8 +95,8 @@ class UsbDeviceImpl : public UsbDevice { |
typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; |
HandlesVector handles_; |
- // Reference to the UI thread for permission-broker calls. |
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
+ scoped_refptr<base::SequencedTaskRunner> task_runner_; |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); |
}; |