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

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

Issue 12226137: Fix missing callback chaining in UsbService. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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/extensions/api/usb/usb_api.h ('k') | chrome/browser/usb/usb_service.h » ('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 aaf735448e152bf92a9256844088c61a8b5f7507..72fbead11d73f0c39e79177731c232f306f18edb 100644
--- a/chrome/browser/extensions/api/usb/usb_api.cc
+++ b/chrome/browser/extensions/api/usb/usb_api.cc
@@ -302,7 +302,7 @@ bool UsbFindDevicesFunction::Prepare() {
}
void UsbFindDevicesFunction::AsyncWorkStart() {
- scoped_ptr<base::ListValue> result(new base::ListValue());
+ result_.reset(new base::ListValue());
if (device_for_test_) {
UsbDeviceResource* const resource = new UsbDeviceResource(
@@ -310,8 +310,8 @@ void UsbFindDevicesFunction::AsyncWorkStart() {
device_for_test_);
Device device;
- result->Append(PopulateDevice(manager_->Add(resource), 0, 0));
- SetResult(result.release());
+ result_->Append(PopulateDevice(manager_->Add(resource), 0, 0));
+ SetResult(result_.release());
AsyncWorkCompleted();
return;
}
@@ -334,20 +334,23 @@ void UsbFindDevicesFunction::AsyncWorkStart() {
return;
}
- vector<scoped_refptr<UsbDevice> > devices;
- service->FindDevices(vendor_id, product_id, &devices);
- for (size_t i = 0; i < devices.size(); ++i) {
- UsbDevice* const device = devices[i];
+ service->FindDevices(vendor_id, product_id, &devices_, base::Bind(
+ &UsbFindDevicesFunction::OnCompleted, this));
+}
+
+void UsbFindDevicesFunction::OnCompleted() {
+ for (size_t i = 0; i < devices_.size(); ++i) {
+ UsbDevice* const device = devices_[i];
UsbDeviceResource* const resource = new UsbDeviceResource(
extension_->id(), device);
Device js_device;
- result->Append(PopulateDevice(manager_->Add(resource),
- vendor_id,
- product_id));
+ result_->Append(PopulateDevice(manager_->Add(resource),
+ parameters_->options.vendor_id,
+ parameters_->options.product_id));
}
- SetResult(result.release());
+ SetResult(result_.release());
AsyncWorkCompleted();
}
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_api.h ('k') | chrome/browser/usb/usb_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698