OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/usb/usb_api.h" | 5 #include "extensions/browser/api/usb/usb_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <numeric> | 9 #include <numeric> |
10 #include <string> | 10 #include <string> |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 518 |
519 service->GetDevices( | 519 service->GetDevices( |
520 base::Bind(&UsbFindDevicesFunction::OnGetDevicesComplete, this)); | 520 base::Bind(&UsbFindDevicesFunction::OnGetDevicesComplete, this)); |
521 return RespondLater(); | 521 return RespondLater(); |
522 } | 522 } |
523 | 523 |
524 void UsbFindDevicesFunction::OnGetDevicesComplete( | 524 void UsbFindDevicesFunction::OnGetDevicesComplete( |
525 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 525 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
526 result_.reset(new base::ListValue()); | 526 result_.reset(new base::ListValue()); |
527 barrier_ = base::BarrierClosure( | 527 barrier_ = base::BarrierClosure( |
528 devices.size(), base::Bind(&UsbFindDevicesFunction::OpenComplete, this)); | 528 static_cast<int>(devices.size()), |
| 529 base::Bind(&UsbFindDevicesFunction::OpenComplete, this)); |
529 | 530 |
530 for (const scoped_refptr<UsbDevice>& device : devices) { | 531 for (const scoped_refptr<UsbDevice>& device : devices) { |
531 if (device->vendor_id() != vendor_id_ || | 532 if (device->vendor_id() != vendor_id_ || |
532 device->product_id() != product_id_) { | 533 device->product_id() != product_id_) { |
533 barrier_.Run(); | 534 barrier_.Run(); |
534 } else { | 535 } else { |
535 device->Open(base::Bind(&UsbFindDevicesFunction::OnDeviceOpened, this)); | 536 device->Open(base::Bind(&UsbFindDevicesFunction::OnDeviceOpened, this)); |
536 } | 537 } |
537 } | 538 } |
538 } | 539 } |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1272 |
1272 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); | 1273 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); |
1273 error_args->AppendBoolean(false); | 1274 error_args->AppendBoolean(false); |
1274 // Using ErrorWithArguments is discouraged but required to maintain | 1275 // Using ErrorWithArguments is discouraged but required to maintain |
1275 // compatibility with existing applications. | 1276 // compatibility with existing applications. |
1276 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); | 1277 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); |
1277 } | 1278 } |
1278 } | 1279 } |
1279 | 1280 |
1280 } // namespace extensions | 1281 } // namespace extensions |
OLD | NEW |