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

Side by Side Diff: device/usb/mojo/device_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, 7 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_impl.h ('k') | device/usb/mojo/device_manager_impl.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/usb/mojo/device_impl.h" 5 #include "device/usb/mojo/device_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 mojo::InterfaceRequest<Device> request) 131 mojo::InterfaceRequest<Device> request)
132 : device_(device), 132 : device_(device),
133 device_info_(std::move(device_info)), 133 device_info_(std::move(device_info)),
134 permission_provider_(permission_provider), 134 permission_provider_(permission_provider),
135 observer_(this), 135 observer_(this),
136 binding_(this, std::move(request)), 136 binding_(this, std::move(request)),
137 weak_factory_(this) { 137 weak_factory_(this) {
138 DCHECK(device_); 138 DCHECK(device_);
139 // This object owns itself and will be destroyed if, 139 // This object owns itself and will be destroyed if,
140 // * the device is disconnected or 140 // * the device is disconnected or
141 // * the message pipe it is bound to is closed 141 // * the message pipe it is bound to is closed or the message loop is
142 // * destructed.
142 observer_.Add(device_.get()); 143 observer_.Add(device_.get());
143 binding_.set_connection_error_handler([this]() { delete this; });
144 } 144 }
145 145
146 DeviceImpl::~DeviceImpl() { 146 DeviceImpl::~DeviceImpl() {
147 CloseHandle(); 147 CloseHandle();
148 } 148 }
149 149
150 void DeviceImpl::CloseHandle() { 150 void DeviceImpl::CloseHandle() {
151 if (device_handle_) { 151 if (device_handle_) {
152 device_handle_->Close(); 152 device_handle_->Close();
153 if (permission_provider_) 153 if (permission_provider_)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 base::Bind(&OnIsochronousTransferOut, base::Passed(&callback_ptr))); 450 base::Bind(&OnIsochronousTransferOut, base::Passed(&callback_ptr)));
451 } 451 }
452 452
453 void DeviceImpl::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 453 void DeviceImpl::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
454 DCHECK_EQ(device_, device); 454 DCHECK_EQ(device_, device);
455 delete this; 455 delete this;
456 } 456 }
457 457
458 } // namespace usb 458 } // namespace usb
459 } // namespace device 459 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mojo/device_impl.h ('k') | device/usb/mojo/device_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698