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

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

Issue 1925463002: Mojo: Make device/ to not rely on connecton error notification on message loop destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « device/usb/mojo/device_manager_impl.h ('k') | no next file » | 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/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
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
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
OLDNEW
« no previous file with comments | « device/usb/mojo/device_manager_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698