| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/extensions/api/api_resource_controller.h" | 10 #include "chrome/browser/extensions/api/api_resource_controller.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 void UsbFindDeviceFunction::Work() { | 41 void UsbFindDeviceFunction::Work() { |
| 42 UsbService* const service = | 42 UsbService* const service = |
| 43 UsbServiceFactory::GetInstance()->GetForProfile(profile()); | 43 UsbServiceFactory::GetInstance()->GetForProfile(profile()); |
| 44 DCHECK(service) << "No UsbService associated with profile."; | 44 DCHECK(service) << "No UsbService associated with profile."; |
| 45 | 45 |
| 46 UsbDevice* const device = service->FindDevice(parameters_->vendor_id, | 46 UsbDevice* const device = service->FindDevice(parameters_->vendor_id, |
| 47 parameters_->product_id); | 47 parameters_->product_id); |
| 48 if (!device) { | 48 if (!device) { |
| 49 result_.reset(base::Value::CreateNullValue()); | 49 SetResult(base::Value::CreateNullValue()); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 UsbDeviceResource* const resource = new UsbDeviceResource(event_notifier_, | 53 UsbDeviceResource* const resource = new UsbDeviceResource(event_notifier_, |
| 54 device); | 54 device); |
| 55 | 55 |
| 56 Device result; | 56 Device result; |
| 57 result.handle = controller()->AddAPIResource(resource); | 57 result.handle = controller()->AddAPIResource(resource); |
| 58 result.vendor_id = parameters_->vendor_id; | 58 result.vendor_id = parameters_->vendor_id; |
| 59 result.product_id = parameters_->product_id; | 59 result.product_id = parameters_->product_id; |
| 60 result_ = result.ToValue(); | 60 SetResult(FindDevice::Result::Create(result)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool UsbFindDeviceFunction::Respond() { | 63 bool UsbFindDeviceFunction::Respond() { |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 | 66 |
| 67 UsbCloseDeviceFunction::UsbCloseDeviceFunction() {} | 67 UsbCloseDeviceFunction::UsbCloseDeviceFunction() {} |
| 68 | 68 |
| 69 UsbCloseDeviceFunction::~UsbCloseDeviceFunction() {} | 69 UsbCloseDeviceFunction::~UsbCloseDeviceFunction() {} |
| 70 | 70 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 if (device) { | 164 if (device) { |
| 165 device->IsochronousTransfer(parameters_->transfer_info); | 165 device->IsochronousTransfer(parameters_->transfer_info); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool UsbIsochronousTransferFunction::Respond() { | 169 bool UsbIsochronousTransferFunction::Respond() { |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |