Index: device/usb/usb_device_handle_impl.h |
diff --git a/device/usb/usb_device_handle_impl.h b/device/usb/usb_device_handle_impl.h |
index 688f8b9cf8db090b15be22aae83bfb32d293bb6c..0d30374e4cfe9a06ffcc3d3ea68443050a47d4ed 100644 |
--- a/device/usb/usb_device_handle_impl.h |
+++ b/device/usb/usb_device_handle_impl.h |
@@ -11,15 +11,16 @@ |
#include "base/callback.h" |
#include "base/memory/ref_counted.h" |
-#include "base/memory/weak_ptr.h" |
-#include "base/strings/string16.h" |
#include "base/threading/thread_checker.h" |
#include "device/usb/usb_device_handle.h" |
-#include "net/base/io_buffer.h" |
#include "third_party/libusb/src/libusb/libusb.h" |
namespace base { |
-class SingleThreadTaskRunner; |
+class SequencedTaskRunner; |
+} |
+ |
+namespace net { |
+class IOBuffer; |
} |
namespace device { |
@@ -37,13 +38,16 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
public: |
scoped_refptr<UsbDevice> GetDevice() const override; |
void Close() override; |
- bool SetConfiguration(int configuration_value) override; |
- bool ClaimInterface(int interface_number) override; |
+ void SetConfiguration(int configuration_value, |
+ const UsbSuccessCallback& callback) override; |
+ void ClaimInterface(int interface_number, |
+ const UsbSuccessCallback& callback) override; |
bool ReleaseInterface(int interface_number) override; |
- bool SetInterfaceAlternateSetting(int interface_number, |
- int alternate_setting) override; |
- bool ResetDevice() override; |
- bool GetStringDescriptor(uint8 string_id, base::string16* string) override; |
+ void SetInterfaceAlternateSetting( |
+ int interface_number, |
+ int alternate_setting, |
+ const UsbSuccessCallback& callback) override; |
+ void ResetDevice(const UsbSuccessCallback& callback) override; |
void ControlTransfer(UsbEndpointDirection direction, |
TransferRequestType request_type, |
@@ -84,10 +88,12 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
protected: |
friend class UsbDeviceImpl; |
- // This constructor is called by UsbDevice. |
- UsbDeviceHandleImpl(scoped_refptr<UsbContext> context, |
- scoped_refptr<UsbDeviceImpl> device, |
- PlatformUsbDeviceHandle handle); |
+ // This constructor is called by UsbDeviceImpl. |
+ UsbDeviceHandleImpl( |
+ scoped_refptr<UsbContext> context, |
+ scoped_refptr<UsbDeviceImpl> device, |
+ PlatformUsbDeviceHandle handle, |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
~UsbDeviceHandleImpl() override; |
@@ -97,6 +103,30 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
class InterfaceClaimer; |
class Transfer; |
+ void SetConfigurationOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ int configuration_value, |
+ const UsbSuccessCallback& callback); |
+ void SetConfigurationComplete(bool success, |
+ const UsbSuccessCallback& callback); |
+ void ClaimInterfaceOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ int interface_number, |
+ const UsbSuccessCallback& callback); |
+ void ClaimInterfaceComplete(int interface_number, |
+ bool success, |
+ const UsbSuccessCallback& callback); |
+ void SetInterfaceAlternateSettingOnBlockingThread( |
+ PlatformUsbDeviceHandle handle, |
+ int interface_number, |
+ int alternate_setting, |
+ const UsbSuccessCallback& callback); |
+ void SetInterfaceAlternateSettingComplete(int interface_number, |
+ int alternate_setting, |
+ bool success, |
+ const UsbSuccessCallback& callback); |
+ void ResetDeviceOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ const UsbSuccessCallback& callback); |
+ void ResetDeviceComplete(bool success, const UsbSuccessCallback& callback); |
+ |
// Refresh endpoint_map_ after ClaimInterface, ReleaseInterface and |
// SetInterfaceAlternateSetting. |
void RefreshEndpointMap(); |
@@ -106,22 +136,14 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
scoped_refptr<InterfaceClaimer> GetClaimedInterfaceForEndpoint( |
unsigned char endpoint); |
- // If the device's task runner is on the current thread then the transfer will |
- // be submitted directly, otherwise a task to do so it posted. The callback |
- // will be called on the current message loop of the thread where this |
- // function was called. |
- void PostOrSubmitTransfer(scoped_ptr<Transfer> transfer); |
- |
// Submits a transfer and starts tracking it. Retains the buffer and copies |
// the completion callback until the transfer finishes, whereupon it invokes |
// the callback then releases the buffer. |
void SubmitTransfer(scoped_ptr<Transfer> transfer); |
- // Invokes the callbacks associated with a given transfer, and removes it from |
- // the in-flight transfer set. |
- void CompleteTransfer(scoped_ptr<Transfer> transfer); |
- |
- bool GetSupportedLanguages(); |
+ // Removes the transfer from the in-flight transfer set and invokes the |
+ // completion callback. |
+ void TransferComplete(Transfer* transfer, const base::Closure& callback); |
// Informs the object to drop internal references. |
void InternalClose(); |
@@ -130,9 +152,6 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
PlatformUsbDeviceHandle handle_; |
- std::vector<uint16> languages_; |
- std::map<uint8, base::string16> strings_; |
- |
typedef std::map<int, scoped_refptr<InterfaceClaimer>> ClaimedInterfaceMap; |
ClaimedInterfaceMap claimed_interfaces_; |
@@ -147,10 +166,10 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
// before this handle. |
scoped_refptr<UsbContext> context_; |
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ scoped_refptr<base::SequencedTaskRunner> task_runner_; |
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
base::ThreadChecker thread_checker_; |
- base::WeakPtrFactory<UsbDeviceHandleImpl> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl); |
}; |