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

Unified Diff: chrome/browser/extensions/api/usb/usb_api.cc

Issue 19981004: Remove callbacks on USB manipulation methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 7 years, 5 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 | « chrome/browser/devtools/adb/android_usb_device.cc ('k') | chrome/browser/extensions/api/usb/usb_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/usb/usb_api.cc
diff --git a/chrome/browser/extensions/api/usb/usb_api.cc b/chrome/browser/extensions/api/usb/usb_api.cc
index 7dc90e624dbf4e4b15b2eb442175fef0bb904b42..5b123addacc1f48c594e7a3c9538b4534794bcf7 100644
--- a/chrome/browser/extensions/api/usb/usb_api.cc
+++ b/chrome/browser/extensions/api/usb/usb_api.cc
@@ -488,8 +488,13 @@ void UsbListInterfacesFunction::AsyncWorkStart() {
}
config_ = new UsbConfigDescriptor();
- resource->device()->ListInterfaces(
- config_.get(), base::Bind(&UsbListInterfacesFunction::OnCompleted, this));
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::ListInterfaces,
+ resource->device(),
+ config_),
+ base::Bind(&UsbListInterfacesFunction::OnCompleted, this));
}
void UsbListInterfacesFunction::OnCompleted(bool success) {
@@ -612,8 +617,11 @@ void UsbCloseDeviceFunction::AsyncWorkStart() {
return;
}
- resource->device()->Close(base::Bind(&UsbCloseDeviceFunction::OnCompleted,
- this));
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::Close, resource->device()),
+ base::Bind(&UsbCloseDeviceFunction::OnCompleted, this));
RemoveUsbDeviceResource(parameters_->device.handle);
}
@@ -639,7 +647,12 @@ void UsbClaimInterfaceFunction::AsyncWorkStart() {
return;
}
- resource->device()->ClaimInterface(parameters_->interface_number,
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::ClaimInterface,
+ resource->device(),
+ parameters_->interface_number),
base::Bind(&UsbClaimInterfaceFunction::OnCompleted, this));
}
@@ -667,7 +680,12 @@ void UsbReleaseInterfaceFunction::AsyncWorkStart() {
return;
}
- resource->device()->ReleaseInterface(parameters_->interface_number,
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::ReleaseInterface,
+ resource->device(),
+ parameters_->interface_number),
base::Bind(&UsbReleaseInterfaceFunction::OnCompleted, this));
}
@@ -697,9 +715,13 @@ void UsbSetInterfaceAlternateSettingFunction::AsyncWorkStart() {
return;
}
- resource->device()->SetInterfaceAlternateSetting(
- parameters_->interface_number,
- parameters_->alternate_setting,
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::SetInterfaceAlternateSetting,
+ resource->device(),
+ parameters_->interface_number,
+ parameters_->alternate_setting),
base::Bind(&UsbSetInterfaceAlternateSettingFunction::OnCompleted, this));
}
@@ -956,8 +978,7 @@ void UsbResetDeviceFunction::AsyncWorkStart() {
void UsbResetDeviceFunction::OnStartResest(UsbDeviceResource* resource) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- resource->device()->ResetDevice(
- base::Bind(&UsbResetDeviceFunction::OnCompletedFileThread, this));
+ OnCompletedFileThread(resource->device()->ResetDevice());
}
void UsbResetDeviceFunction::OnCompletedFileThread(bool success) {
@@ -979,8 +1000,12 @@ void UsbResetDeviceFunction::OnCompleted(bool success) {
}
// Close the device now because the handle is invalid after an
// unsuccessful reset.
- resource->device()->Close(
- base::Bind(&UsbResetDeviceFunction::OnError, this));
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UsbDeviceHandle::Close,
+ resource->device()),
+ base::Bind(&UsbResetDeviceFunction::OnError, this));
return;
}
SetResult(Value::CreateBooleanValue(true));
« no previous file with comments | « chrome/browser/devtools/adb/android_usb_device.cc ('k') | chrome/browser/extensions/api/usb/usb_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698