summaryrefslogtreecommitdiffstats
path: root/chrome/browser/usb
diff options
context:
space:
mode:
authorikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-24 01:35:45 +0000
committerikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-24 01:35:45 +0000
commit58c9813281bf9ca6c0387894fe29fa5974c3af6b (patch)
treebc2cb02dda260370a034562774a8efbb97554634 /chrome/browser/usb
parent849fdd56369dade47076d3ff8066b9c5bfd51144 (diff)
downloadchromium_src-58c9813281bf9ca6c0387894fe29fa5974c3af6b.zip
chromium_src-58c9813281bf9ca6c0387894fe29fa5974c3af6b.tar.gz
chromium_src-58c9813281bf9ca6c0387894fe29fa5974c3af6b.tar.bz2
They will be restricted to FILE thread. No need for callback.
Review URL: https://chromiumcodereview.appspot.com/19981004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/usb')
-rw-r--r--chrome/browser/usb/usb_device_handle.cc35
-rw-r--r--chrome/browser/usb/usb_device_handle.h28
2 files changed, 25 insertions, 38 deletions
diff --git a/chrome/browser/usb/usb_device_handle.cc b/chrome/browser/usb/usb_device_handle.cc
index bfac067..99faad1 100644
--- a/chrome/browser/usb/usb_device_handle.cc
+++ b/chrome/browser/usb/usb_device_handle.cc
@@ -113,11 +113,10 @@ UsbDeviceHandle::UsbDeviceHandle() : service_(NULL), handle_(NULL) {}
UsbDeviceHandle::~UsbDeviceHandle() {}
-void UsbDeviceHandle::Close(const base::Callback<void()>& callback) {
+void UsbDeviceHandle::Close() {
CheckDevice();
service_->CloseDevice(this);
handle_ = NULL;
- callback.Run();
}
void UsbDeviceHandle::TransferComplete(PlatformUsbTransferHandle handle) {
@@ -200,8 +199,7 @@ void UsbDeviceHandle::TransferComplete(PlatformUsbTransferHandle handle) {
libusb_free_transfer(handle);
}
-void UsbDeviceHandle::ListInterfaces(UsbConfigDescriptor* config,
- const UsbInterfaceCallback& callback) {
+bool UsbDeviceHandle::ListInterfaces(UsbConfigDescriptor* config) {
CheckDevice();
PlatformUsbDevice device = libusb_get_device(handle_);
@@ -212,36 +210,38 @@ void UsbDeviceHandle::ListInterfaces(UsbConfigDescriptor* config,
if (list_result == 0) {
config->Reset(platform_config);
}
- callback.Run(list_result == 0);
+ return list_result == 0;
}
-void UsbDeviceHandle::ClaimInterface(const int interface_number,
- const UsbInterfaceCallback& callback) {
+bool UsbDeviceHandle::ClaimInterface(const int interface_number) {
CheckDevice();
const int claim_result = libusb_claim_interface(handle_, interface_number);
- callback.Run(claim_result == 0);
+ return claim_result == 0;
}
-void UsbDeviceHandle::ReleaseInterface(const int interface_number,
- const UsbInterfaceCallback& callback) {
+bool UsbDeviceHandle::ReleaseInterface(const int interface_number) {
CheckDevice();
const int release_result = libusb_release_interface(handle_,
interface_number);
- callback.Run(release_result == 0);
+ return release_result == 0;
}
-void UsbDeviceHandle::SetInterfaceAlternateSetting(
+bool UsbDeviceHandle::SetInterfaceAlternateSetting(
const int interface_number,
- const int alternate_setting,
- const UsbInterfaceCallback& callback) {
+ const int alternate_setting) {
CheckDevice();
const int setting_result = libusb_set_interface_alt_setting(handle_,
interface_number, alternate_setting);
- callback.Run(setting_result == 0);
+ return setting_result == 0;
+}
+
+bool UsbDeviceHandle::ResetDevice() {
+ CheckDevice();
+ return libusb_reset_device(handle_) == 0;
}
void UsbDeviceHandle::ControlTransfer(const UsbEndpointDirection direction,
@@ -317,11 +317,6 @@ void UsbDeviceHandle::IsochronousTransfer(const UsbEndpointDirection direction,
SubmitTransfer(transfer, USB_TRANSFER_ISOCHRONOUS, buffer, length, callback);
}
-void UsbDeviceHandle::ResetDevice(const base::Callback<void(bool)>& callback) {
- CheckDevice();
- callback.Run(libusb_reset_device(handle_) == 0);
-}
-
void UsbDeviceHandle::CheckDevice() {
DCHECK(handle_) << "Device is already closed.";
}
diff --git a/chrome/browser/usb/usb_device_handle.h b/chrome/browser/usb/usb_device_handle.h
index 54ed216..e46ab19 100644
--- a/chrome/browser/usb/usb_device_handle.h
+++ b/chrome/browser/usb/usb_device_handle.h
@@ -43,7 +43,6 @@ enum UsbTransferStatus {
typedef base::Callback<void(UsbTransferStatus, scoped_refptr<net::IOBuffer>,
size_t)> UsbTransferCallback;
-typedef base::Callback<void(bool success)> UsbInterfaceCallback;
// A UsbDevice wraps the platform's underlying representation of what a USB
// device actually is, and provides accessors for performing many of the
@@ -60,24 +59,19 @@ class UsbDeviceHandle : public base::RefCounted<UsbDeviceHandle> {
PlatformUsbDeviceHandle handle() { return handle_; }
- // Close the USB device and release the underlying platform device. |callback|
- // is invoked after the device has been closed.
- virtual void Close(const base::Callback<void()>& callback);
+ // Close the USB device and release the underlying platform device.
+ virtual void Close();
- virtual void ListInterfaces(UsbConfigDescriptor* config,
- const UsbInterfaceCallback& callback);
-
- virtual void ClaimInterface(const int interface_number,
- const UsbInterfaceCallback& callback);
-
- virtual void ReleaseInterface(const int interface_number,
- const UsbInterfaceCallback& callback);
-
- virtual void SetInterfaceAlternateSetting(
+ // Device manipulation operations. These methods are blocking.
+ virtual bool ListInterfaces(UsbConfigDescriptor* config);
+ virtual bool ClaimInterface(const int interface_number);
+ virtual bool ReleaseInterface(const int interface_number);
+ virtual bool SetInterfaceAlternateSetting(
const int interface_number,
- const int alternate_setting,
- const UsbInterfaceCallback& callback);
+ const int alternate_setting);
+ virtual bool ResetDevice();
+ // Async IO.
virtual void ControlTransfer(const UsbEndpointDirection direction,
const TransferRequestType request_type,
const TransferRecipient recipient,
@@ -112,8 +106,6 @@ class UsbDeviceHandle : public base::RefCounted<UsbDeviceHandle> {
const unsigned int timeout,
const UsbTransferCallback& callback);
- virtual void ResetDevice(const base::Callback<void(bool success)>& callback);
-
// Normal code should not call this function. It is called by the platform's
// callback mechanism in such a way that it cannot be made private. Invokes
// the callbacks associated with a given transfer, and removes it from the