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..5f5764a848206dc5ef5b5aa1d2ec6a38ae3aaac3 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,15 @@ 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 ResultCallback& callback) override; |
+ void ClaimInterface(int interface_number, |
+ const ResultCallback& 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 ResultCallback& callback) override; |
+ void ResetDevice(const ResultCallback& callback) override; |
void ControlTransfer(UsbEndpointDirection direction, |
TransferRequestType request_type, |
@@ -54,21 +57,21 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
net::IOBuffer* buffer, |
size_t length, |
unsigned int timeout, |
- const UsbTransferCallback& callback) override; |
+ const TransferCallback& callback) override; |
void BulkTransfer(UsbEndpointDirection direction, |
uint8 endpoint, |
net::IOBuffer* buffer, |
size_t length, |
unsigned int timeout, |
- const UsbTransferCallback& callback) override; |
+ const TransferCallback& callback) override; |
void InterruptTransfer(UsbEndpointDirection direction, |
uint8 endpoint, |
net::IOBuffer* buffer, |
size_t length, |
unsigned int timeout, |
- const UsbTransferCallback& callback) override; |
+ const TransferCallback& callback) override; |
void IsochronousTransfer(UsbEndpointDirection direction, |
uint8 endpoint, |
@@ -77,17 +80,19 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
unsigned int packets, |
unsigned int packet_length, |
unsigned int timeout, |
- const UsbTransferCallback& callback) override; |
+ const TransferCallback& callback) override; |
PlatformUsbDeviceHandle handle() const { return handle_; } |
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 +102,29 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle { |
class InterfaceClaimer; |
class Transfer; |
+ void SetConfigurationOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ int configuration_value, |
+ const ResultCallback& callback); |
+ void SetConfigurationComplete(bool success, const ResultCallback& callback); |
+ void ClaimInterfaceOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ int interface_number, |
+ const ResultCallback& callback); |
+ void ClaimInterfaceComplete(int interface_number, |
+ bool success, |
+ const ResultCallback& callback); |
+ void SetInterfaceAlternateSettingOnBlockingThread( |
+ PlatformUsbDeviceHandle handle, |
+ int interface_number, |
+ int alternate_setting, |
+ const ResultCallback& callback); |
+ void SetInterfaceAlternateSettingComplete(int interface_number, |
+ int alternate_setting, |
+ bool success, |
+ const ResultCallback& callback); |
+ void ResetDeviceOnBlockingThread(PlatformUsbDeviceHandle handle, |
+ const ResultCallback& callback); |
+ void ResetDeviceComplete(bool success, const ResultCallback& callback); |
+ |
// Refresh endpoint_map_ after ClaimInterface, ReleaseInterface and |
// SetInterfaceAlternateSetting. |
void RefreshEndpointMap(); |
@@ -106,22 +134,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 +150,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 +164,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); |
}; |