| OLD | NEW |
| 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/usb/mojo/device_manager_impl.h" | 5 #include "device/usb/mojo/device_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void DeviceManagerImpl::SetClient(DeviceManagerClientPtr client) { | 81 void DeviceManagerImpl::SetClient(DeviceManagerClientPtr client) { |
| 82 client_ = std::move(client); | 82 client_ = std::move(client); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void DeviceManagerImpl::OnGetDevices( | 85 void DeviceManagerImpl::OnGetDevices( |
| 86 EnumerationOptionsPtr options, | 86 EnumerationOptionsPtr options, |
| 87 const GetDevicesCallback& callback, | 87 const GetDevicesCallback& callback, |
| 88 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 88 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
| 89 std::vector<UsbDeviceFilter> filters; | 89 std::vector<UsbDeviceFilter> filters; |
| 90 if (options && options->filters) | 90 if (options && options->filters) |
| 91 filters = mojo::ConvertTo<std::vector<UsbDeviceFilter>>(*options->filters); | 91 filters.swap(*options->filters); |
| 92 | 92 |
| 93 std::vector<DeviceInfoPtr> device_infos; | 93 std::vector<DeviceInfoPtr> device_infos; |
| 94 for (const auto& device : devices) { | 94 for (const auto& device : devices) { |
| 95 if (UsbDeviceFilter::MatchesAny(device, filters)) { | 95 if (UsbDeviceFilter::MatchesAny(device, filters)) { |
| 96 if (permission_provider_ && | 96 if (permission_provider_ && |
| 97 permission_provider_->HasDevicePermission(device)) { | 97 permission_provider_->HasDevicePermission(device)) { |
| 98 device_infos.push_back(DeviceInfo::From(*device)); | 98 device_infos.push_back(DeviceInfo::From(*device)); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } | 101 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 114 permission_provider_->HasDevicePermission(device)) | 114 permission_provider_->HasDevicePermission(device)) |
| 115 client_->OnDeviceRemoved(DeviceInfo::From(*device)); | 115 client_->OnDeviceRemoved(DeviceInfo::From(*device)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void DeviceManagerImpl::WillDestroyUsbService() { | 118 void DeviceManagerImpl::WillDestroyUsbService() { |
| 119 delete this; | 119 delete this; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace usb | 122 } // namespace usb |
| 123 } // namespace device | 123 } // namespace device |
| OLD | NEW |