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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 observer_(this), | 44 observer_(this), |
45 binding_(this, std::move(request)), | 45 binding_(this, std::move(request)), |
46 weak_factory_(this) { | 46 weak_factory_(this) { |
47 // This object owns itself and will be destroyed if the message pipe it is | 47 // This object owns itself and will be destroyed if the message pipe it is |
48 // bound to is closed, the message loop is destructed, or the UsbService is | 48 // bound to is closed, the message loop is destructed, or the UsbService is |
49 // shut down. | 49 // shut down. |
50 observer_.Add(usb_service_); | 50 observer_.Add(usb_service_); |
51 } | 51 } |
52 | 52 |
53 DeviceManagerImpl::~DeviceManagerImpl() { | 53 DeviceManagerImpl::~DeviceManagerImpl() { |
54 connection_error_handler_.Run(); | 54 if (!connection_error_handler_.is_null()) |
| 55 connection_error_handler_.Run(); |
55 } | 56 } |
56 | 57 |
57 void DeviceManagerImpl::GetDevices(EnumerationOptionsPtr options, | 58 void DeviceManagerImpl::GetDevices(EnumerationOptionsPtr options, |
58 const GetDevicesCallback& callback) { | 59 const GetDevicesCallback& callback) { |
59 usb_service_->GetDevices(base::Bind(&DeviceManagerImpl::OnGetDevices, | 60 usb_service_->GetDevices(base::Bind(&DeviceManagerImpl::OnGetDevices, |
60 weak_factory_.GetWeakPtr(), | 61 weak_factory_.GetWeakPtr(), |
61 base::Passed(&options), callback)); | 62 base::Passed(&options), callback)); |
62 } | 63 } |
63 | 64 |
64 void DeviceManagerImpl::GetDevice( | 65 void DeviceManagerImpl::GetDevice( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 permission_provider_->HasDevicePermission(device)) | 112 permission_provider_->HasDevicePermission(device)) |
112 client_->OnDeviceRemoved(DeviceInfo::From(*device)); | 113 client_->OnDeviceRemoved(DeviceInfo::From(*device)); |
113 } | 114 } |
114 | 115 |
115 void DeviceManagerImpl::WillDestroyUsbService() { | 116 void DeviceManagerImpl::WillDestroyUsbService() { |
116 delete this; | 117 delete this; |
117 } | 118 } |
118 | 119 |
119 } // namespace usb | 120 } // namespace usb |
120 } // namespace device | 121 } // namespace device |
OLD | NEW |