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

Side by Side Diff: device/devices_app/usb/device_manager_impl.cc

Issue 1293253002: Connect WebUSB client interface to the devices app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak in WeakBindingSet Created 5 years, 4 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
« no previous file with comments | « device/devices_app/devices_app.gyp ('k') | mojo/common/weak_binding_set.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "device/devices_app/usb/device_manager_impl.h" 5 #include "device/devices_app/usb/device_manager_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace { 26 namespace {
27 27
28 void OnGetDevicesOnServiceThread( 28 void OnGetDevicesOnServiceThread(
29 const std::vector<UsbDeviceFilter>& filters, 29 const std::vector<UsbDeviceFilter>& filters,
30 const base::Callback<void(mojo::Array<DeviceInfoPtr>)>& callback, 30 const base::Callback<void(mojo::Array<DeviceInfoPtr>)>& callback,
31 scoped_refptr<base::TaskRunner> callback_task_runner, 31 scoped_refptr<base::TaskRunner> callback_task_runner,
32 const std::vector<scoped_refptr<UsbDevice>>& devices) { 32 const std::vector<scoped_refptr<UsbDevice>>& devices) {
33 mojo::Array<DeviceInfoPtr> mojo_devices(0); 33 mojo::Array<DeviceInfoPtr> mojo_devices(0);
34 for (size_t i = 0; i < devices.size(); ++i) { 34 for (size_t i = 0; i < devices.size(); ++i) {
35 if (UsbDeviceFilter::MatchesAny(devices[i], filters)) 35 if (UsbDeviceFilter::MatchesAny(devices[i], filters) || filters.empty())
36 mojo_devices.push_back(DeviceInfo::From(*devices[i])); 36 mojo_devices.push_back(DeviceInfo::From(*devices[i]));
37 } 37 }
38 callback_task_runner->PostTask( 38 callback_task_runner->PostTask(
39 FROM_HERE, base::Bind(callback, base::Passed(&mojo_devices))); 39 FROM_HERE, base::Bind(callback, base::Passed(&mojo_devices)));
40 } 40 }
41 41
42 void GetDevicesOnServiceThread( 42 void GetDevicesOnServiceThread(
43 const std::vector<UsbDeviceFilter>& filters, 43 const std::vector<UsbDeviceFilter>& filters,
44 const base::Callback<void(mojo::Array<DeviceInfoPtr>)>& callback, 44 const base::Callback<void(mojo::Array<DeviceInfoPtr>)>& callback,
45 scoped_refptr<base::TaskRunner> callback_task_runner) { 45 scoped_refptr<base::TaskRunner> callback_task_runner) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 mojo::Array<DeviceInfoPtr> allowed_devices(0); 151 mojo::Array<DeviceInfoPtr> allowed_devices(0);
152 for (size_t i = 0; i < devices.size(); ++i) { 152 for (size_t i = 0; i < devices.size(); ++i) {
153 if (delegate_->IsDeviceAllowed(*devices[i])) 153 if (delegate_->IsDeviceAllowed(*devices[i]))
154 allowed_devices.push_back(devices[i].Pass()); 154 allowed_devices.push_back(devices[i].Pass());
155 } 155 }
156 callback.Run(allowed_devices.Pass()); 156 callback.Run(allowed_devices.Pass());
157 } 157 }
158 158
159 } // namespace usb 159 } // namespace usb
160 } // namespace device 160 } // namespace device
OLDNEW
« no previous file with comments | « device/devices_app/devices_app.gyp ('k') | mojo/common/weak_binding_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698