UsbDeviceHandleImpl must hold a scoped_refptr to UsbDeviceImpl.
commite1a9120d381ae6c12535ea8b2c5679700320398a
authorreillyg <reillyg@chromium.org>
Sat, 10 Jan 2015 00:13:48 +0000 (9 16:13 -0800)
committerCommit bot <commit-bot@chromium.org>
Sat, 10 Jan 2015 00:14:30 +0000 (10 00:14 +0000)
treef732ee91337b49b2d71e0ce47721c729ba94b3f9
parentd78b19e92b463241fbea32e5dd7b07fce2b5ad79
UsbDeviceHandleImpl must hold a scoped_refptr to UsbDeviceImpl.

When a USB device is disconnected the last reference to the UsbDevice
object representing it may be freed. Outstanding device handles should
retain a reference to the UsbDevice object until they themselves are
closed (which is done in UsbDeviceImpl::OnDisconnect). This call
releases the circular reference between UsbDeviceImpl and its open
UsbDeviceHandleImpl children.

Otherwise the UsbDeviceImpl will outlive the UsbDeviceHandleImpl and
UsbDeviceHandleImpl::GetDevice will attempt to call AddRef on an invalid
pointer.

BUG=447761

Review URL: https://codereview.chromium.org/835313003

Cr-Commit-Position: refs/heads/master@{#310907}
device/usb/usb_device_handle_impl.cc
device/usb/usb_device_handle_impl.h