| OLD | NEW |
| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 base::Unretained(service), | 467 base::Unretained(service), |
| 468 vendor_id, | 468 vendor_id, |
| 469 product_id, | 469 product_id, |
| 470 interface_id, | 470 interface_id, |
| 471 base::Bind(&UsbFindDevicesFunction::OnEnumerationCompleted, | 471 base::Bind(&UsbFindDevicesFunction::OnEnumerationCompleted, |
| 472 this))); | 472 this))); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void UsbFindDevicesFunction::OnEnumerationCompleted( | 475 void UsbFindDevicesFunction::OnEnumerationCompleted( |
| 476 ScopedDeviceVector devices) { | 476 ScopedDeviceVector devices) { |
| 477 for (size_t i = 0; i < devices->size(); ++i) | 477 for (size_t i = 0; i < devices->size(); ++i) { |
| 478 device_handles_.push_back(devices->at(i)->Open()); | 478 scoped_refptr<UsbDeviceHandle> device_handle = |
| 479 devices->at(i)->Open(); |
| 480 if (device_handle) |
| 481 device_handles_.push_back(device_handle); |
| 482 } |
| 479 | 483 |
| 480 BrowserThread::PostTask( | 484 BrowserThread::PostTask( |
| 481 BrowserThread::IO, | 485 BrowserThread::IO, |
| 482 FROM_HERE, | 486 FROM_HERE, |
| 483 base::Bind(&UsbFindDevicesFunction::OnCompleted, this)); | 487 base::Bind(&UsbFindDevicesFunction::OnCompleted, this)); |
| 484 } | 488 } |
| 485 | 489 |
| 486 void UsbFindDevicesFunction::OnCompleted() { | 490 void UsbFindDevicesFunction::OnCompleted() { |
| 487 for (size_t i = 0; i < device_handles_.size(); ++i) { | 491 for (size_t i = 0; i < device_handles_.size(); ++i) { |
| 488 UsbDeviceHandle* const device_handle = device_handles_[i].get(); | 492 UsbDeviceHandle* const device_handle = device_handles_[i].get(); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 } | 1046 } |
| 1043 | 1047 |
| 1044 void UsbResetDeviceFunction::OnError() { | 1048 void UsbResetDeviceFunction::OnError() { |
| 1045 RemoveUsbDeviceResource(parameters_->device.handle); | 1049 RemoveUsbDeviceResource(parameters_->device.handle); |
| 1046 SetError(kErrorResetDevice); | 1050 SetError(kErrorResetDevice); |
| 1047 SetResult(Value::CreateBooleanValue(false)); | 1051 SetResult(Value::CreateBooleanValue(false)); |
| 1048 AsyncWorkCompleted(); | 1052 AsyncWorkCompleted(); |
| 1049 } | 1053 } |
| 1050 | 1054 |
| 1051 } // namespace extensions | 1055 } // namespace extensions |
| OLD | NEW |