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

Unified Diff: device/usb/usb_device_handle.h

Issue 980023002: Move device/usb classes from the FILE thread to UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more thread assertions. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/usb_device_filter_unittest.cc ('k') | device/usb/usb_device_handle_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_device_handle.h
diff --git a/device/usb/usb_device_handle.h b/device/usb/usb_device_handle.h
index 7098d6809ee8a1eb47845b23432c7e901c9e413b..2c59f2508b4d06e297b257c019b13277e4ce81ec 100644
--- a/device/usb/usb_device_handle.h
+++ b/device/usb/usb_device_handle.h
@@ -30,13 +30,13 @@ enum UsbTransferStatus {
USB_TRANSFER_LENGTH_SHORT,
};
-typedef base::Callback<
- void(UsbTransferStatus, scoped_refptr<net::IOBuffer>, size_t)>
- UsbTransferCallback;
-
// UsbDeviceHandle class provides basic I/O related functionalities.
class UsbDeviceHandle : public base::RefCountedThreadSafe<UsbDeviceHandle> {
public:
+ using ResultCallback = base::Callback<void(bool)>;
+ using TransferCallback = base::Callback<
+ void(UsbTransferStatus, scoped_refptr<net::IOBuffer>, size_t)>;
+
enum TransferRequestType { STANDARD, CLASS, VENDOR, RESERVED };
enum TransferRecipient { DEVICE, INTERFACE, ENDPOINT, OTHER };
@@ -49,53 +49,52 @@ class UsbDeviceHandle : public base::RefCountedThreadSafe<UsbDeviceHandle> {
// The platform device handle will be closed when UsbDeviceHandle destructs.
virtual void Close() = 0;
- // Device manipulation operations. These methods are blocking and must be
- // called on FILE thread.
- virtual bool SetConfiguration(int configuration_value) = 0;
- virtual bool ClaimInterface(int interface_number) = 0;
+ // Device manipulation operations.
+ virtual void SetConfiguration(int configuration_value,
+ const ResultCallback& callback) = 0;
+ virtual void ClaimInterface(int interface_number,
+ const ResultCallback& callback) = 0;
virtual bool ReleaseInterface(int interface_number) = 0;
- virtual bool SetInterfaceAlternateSetting(int interface_number,
- int alternate_setting) = 0;
- virtual bool ResetDevice() = 0;
-
- // Gets the string descriptor with the given index from the device, or returns
- // false. This method is blocking and must be called on the FILE thread.
- virtual bool GetStringDescriptor(uint8 string_id, base::string16* string) = 0;
+ virtual void SetInterfaceAlternateSetting(int interface_number,
+ int alternate_setting,
+ const ResultCallback& callback) = 0;
+ virtual void ResetDevice(const ResultCallback& callback) = 0;
- // Async IO. Can be called on any thread.
+ // The transfer functions may be called from any thread. The provided callback
+ // will be run on the caller's thread.
virtual void ControlTransfer(UsbEndpointDirection direction,
TransferRequestType request_type,
TransferRecipient recipient,
uint8 request,
uint16 value,
uint16 index,
- net::IOBuffer* buffer,
+ scoped_refptr<net::IOBuffer> buffer,
size_t length,
unsigned int timeout,
- const UsbTransferCallback& callback) = 0;
+ const TransferCallback& callback) = 0;
virtual void BulkTransfer(UsbEndpointDirection direction,
uint8 endpoint,
- net::IOBuffer* buffer,
+ scoped_refptr<net::IOBuffer> buffer,
size_t length,
unsigned int timeout,
- const UsbTransferCallback& callback) = 0;
+ const TransferCallback& callback) = 0;
virtual void InterruptTransfer(UsbEndpointDirection direction,
uint8 endpoint,
- net::IOBuffer* buffer,
+ scoped_refptr<net::IOBuffer> buffer,
size_t length,
unsigned int timeout,
- const UsbTransferCallback& callback) = 0;
+ const TransferCallback& callback) = 0;
virtual void IsochronousTransfer(UsbEndpointDirection direction,
uint8 endpoint,
- net::IOBuffer* buffer,
+ scoped_refptr<net::IOBuffer> buffer,
size_t length,
unsigned int packets,
unsigned int packet_length,
unsigned int timeout,
- const UsbTransferCallback& callback) = 0;
+ const TransferCallback& callback) = 0;
protected:
friend class base::RefCountedThreadSafe<UsbDeviceHandle>;
« no previous file with comments | « device/usb/usb_device_filter_unittest.cc ('k') | device/usb/usb_device_handle_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698