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

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

Issue 2727633004: Change UsbDeviceFilter to use const references instead of (Closed)
Patch Set: Fix callsite missed earlier due to not building for CrOS Created 3 years, 8 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
OLDNEW
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 <set> 10 #include <set>
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 service->GetDevices( 606 service->GetDevices(
607 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this)); 607 base::Bind(&UsbGetDevicesFunction::OnGetDevicesComplete, this));
608 return RespondLater(); 608 return RespondLater();
609 } 609 }
610 610
611 void UsbGetDevicesFunction::OnGetDevicesComplete( 611 void UsbGetDevicesFunction::OnGetDevicesComplete(
612 const std::vector<scoped_refptr<UsbDevice>>& devices) { 612 const std::vector<scoped_refptr<UsbDevice>>& devices) {
613 std::unique_ptr<base::ListValue> result(new base::ListValue()); 613 std::unique_ptr<base::ListValue> result(new base::ListValue());
614 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context()); 614 UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context());
615 for (const scoped_refptr<UsbDevice>& device : devices) { 615 for (const scoped_refptr<UsbDevice>& device : devices) {
616 if (UsbDeviceFilter::MatchesAny(device, filters_) && 616 if (UsbDeviceFilter::MatchesAny(*device, filters_) &&
617 HasDevicePermission(device)) { 617 HasDevicePermission(device)) {
618 Device api_device; 618 Device api_device;
619 guid_map->GetApiDevice(device, &api_device); 619 guid_map->GetApiDevice(device, &api_device);
620 result->Append(api_device.ToValue()); 620 result->Append(api_device.ToValue());
621 } 621 }
622 } 622 }
623 623
624 Respond(OneArgument(std::move(result))); 624 Respond(OneArgument(std::move(result)));
625 } 625 }
626 626
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1288
1289 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); 1289 std::unique_ptr<base::ListValue> error_args(new base::ListValue());
1290 error_args->AppendBoolean(false); 1290 error_args->AppendBoolean(false);
1291 // Using ErrorWithArguments is discouraged but required to maintain 1291 // Using ErrorWithArguments is discouraged but required to maintain
1292 // compatibility with existing applications. 1292 // compatibility with existing applications.
1293 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); 1293 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice));
1294 } 1294 }
1295 } 1295 }
1296 1296
1297 } // namespace extensions 1297 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698