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

Side by Side Diff: chrome/browser/extensions/api/usb/usb_api.cc

Issue 11636050: Eliminate ApiResourceEventNotifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/usb/usb_api.h" 5 #include "chrome/browser/extensions/api/usb/usb_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 parameters_ = FindDevices::Params::Create(*args_); 288 parameters_ = FindDevices::Params::Create(*args_);
289 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); 289 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
290 return true; 290 return true;
291 } 291 }
292 292
293 void UsbFindDevicesFunction::AsyncWorkStart() { 293 void UsbFindDevicesFunction::AsyncWorkStart() {
294 scoped_ptr<base::ListValue> result(new base::ListValue()); 294 scoped_ptr<base::ListValue> result(new base::ListValue());
295 295
296 if (device_for_test_) { 296 if (device_for_test_) {
297 UsbDeviceResource* const resource = new UsbDeviceResource( 297 UsbDeviceResource* const resource = new UsbDeviceResource(
298 extension_->id(), NULL, device_for_test_); 298 extension_->id(),
299 device_for_test_);
299 300
300 Device device; 301 Device device;
301 result->Append(PopulateDevice(manager_->Add(resource), 0, 0)); 302 result->Append(PopulateDevice(manager_->Add(resource), 0, 0));
302 SetResult(result.release()); 303 SetResult(result.release());
303 AsyncWorkCompleted(); 304 AsyncWorkCompleted();
304 return; 305 return;
305 } 306 }
306 307
307 const uint16_t vendor_id = parameters_->options.vendor_id; 308 const uint16_t vendor_id = parameters_->options.vendor_id;
308 const uint16_t product_id = parameters_->options.product_id; 309 const uint16_t product_id = parameters_->options.product_id;
(...skipping 11 matching lines...) Expand all
320 LOG(WARNING) << "Could not get UsbService for active profile."; 321 LOG(WARNING) << "Could not get UsbService for active profile.";
321 CompleteWithError(kErrorNoDevice); 322 CompleteWithError(kErrorNoDevice);
322 return; 323 return;
323 } 324 }
324 325
325 vector<scoped_refptr<UsbDevice> > devices; 326 vector<scoped_refptr<UsbDevice> > devices;
326 service->FindDevices(vendor_id, product_id, &devices); 327 service->FindDevices(vendor_id, product_id, &devices);
327 for (size_t i = 0; i < devices.size(); ++i) { 328 for (size_t i = 0; i < devices.size(); ++i) {
328 UsbDevice* const device = devices[i]; 329 UsbDevice* const device = devices[i];
329 UsbDeviceResource* const resource = new UsbDeviceResource( 330 UsbDeviceResource* const resource = new UsbDeviceResource(
330 extension_->id(), NULL, device); 331 extension_->id(), device);
331 332
332 Device js_device; 333 Device js_device;
333 result->Append(PopulateDevice(manager_->Add(resource), 334 result->Append(PopulateDevice(manager_->Add(resource),
334 vendor_id, 335 vendor_id,
335 product_id)); 336 product_id));
336 } 337 }
337 338
338 SetResult(result.release()); 339 SetResult(result.release());
339 AsyncWorkCompleted(); 340 AsyncWorkCompleted();
340 } 341 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 CompleteWithError(kErrorNoDevice); 606 CompleteWithError(kErrorNoDevice);
606 return; 607 return;
607 } 608 }
608 609
609 device->device()->IsochronousTransfer(direction, generic_transfer.endpoint, 610 device->device()->IsochronousTransfer(direction, generic_transfer.endpoint,
610 buffer, size, transfer.packets, transfer.packet_length, 0, base::Bind( 611 buffer, size, transfer.packets, transfer.packet_length, 0, base::Bind(
611 &UsbIsochronousTransferFunction::OnCompleted, this)); 612 &UsbIsochronousTransferFunction::OnCompleted, this));
612 } 613 }
613 614
614 } // namespace extensions 615 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_api.h ('k') | chrome/browser/extensions/api/usb/usb_device_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698