| 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 29 matching lines...) Expand all Loading... |
| 40 DeviceManagerImpl::DeviceManagerImpl( | 40 DeviceManagerImpl::DeviceManagerImpl( |
| 41 base::WeakPtr<PermissionProvider> permission_provider, | 41 base::WeakPtr<PermissionProvider> permission_provider, |
| 42 UsbService* usb_service, | 42 UsbService* usb_service, |
| 43 mojo::InterfaceRequest<DeviceManager> request) | 43 mojo::InterfaceRequest<DeviceManager> request) |
| 44 : permission_provider_(permission_provider), | 44 : permission_provider_(permission_provider), |
| 45 usb_service_(usb_service), | 45 usb_service_(usb_service), |
| 46 observer_(this), | 46 observer_(this), |
| 47 binding_(this, std::move(request)), | 47 binding_(this, std::move(request)), |
| 48 weak_factory_(this) { | 48 weak_factory_(this) { |
| 49 // This object owns itself and will be destroyed if the message pipe it is | 49 // This object owns itself and will be destroyed if the message pipe it is |
| 50 // bound to is closed or the UsbService is shut down. | 50 // bound to is closed, the message loop is destructed, or the UsbService is |
| 51 binding_.set_connection_error_handler([this]() { delete this; }); | 51 // shut down. |
| 52 observer_.Add(usb_service_); | 52 observer_.Add(usb_service_); |
| 53 } | 53 } |
| 54 | 54 |
| 55 DeviceManagerImpl::~DeviceManagerImpl() { | 55 DeviceManagerImpl::~DeviceManagerImpl() { |
| 56 connection_error_handler_.Run(); | 56 connection_error_handler_.Run(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void DeviceManagerImpl::GetDevices(EnumerationOptionsPtr options, | 59 void DeviceManagerImpl::GetDevices(EnumerationOptionsPtr options, |
| 60 const GetDevicesCallback& callback) { | 60 const GetDevicesCallback& callback) { |
| 61 usb_service_->GetDevices(base::Bind(&DeviceManagerImpl::OnGetDevices, | 61 usb_service_->GetDevices(base::Bind(&DeviceManagerImpl::OnGetDevices, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 devices_added_.clear(); | 137 devices_added_.clear(); |
| 138 notification->devices_removed.Swap(&devices_removed_); | 138 notification->devices_removed.Swap(&devices_removed_); |
| 139 | 139 |
| 140 device_change_callbacks_.front().Run(std::move(notification)); | 140 device_change_callbacks_.front().Run(std::move(notification)); |
| 141 device_change_callbacks_.pop(); | 141 device_change_callbacks_.pop(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace usb | 145 } // namespace usb |
| 146 } // namespace device | 146 } // namespace device |
| OLD | NEW |