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

Unified Diff: device/usb/mojo/device_impl.h

Issue 1695643002: Destroy DeviceImpl when the underlying UsbDevice is disconnected. (Closed) Base URL: reillyg-linux.mtv.corp.google.com:/src/chromium/src@mojo_device_autoclose
Patch Set: Revert change to web_usb_device_impl.cc. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/mock_usb_device.cc ('k') | device/usb/mojo/device_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/mojo/device_impl.h
diff --git a/device/usb/mojo/device_impl.h b/device/usb/mojo/device_impl.h
index e19feef72eebff56d40306b13adeb81c289dd9e2..487a7d46acccb50b78b6dd0cf78dc37e6a930d45 100644
--- a/device/usb/mojo/device_impl.h
+++ b/device/usb/mojo/device_impl.h
@@ -11,8 +11,10 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
#include "device/usb/public/interfaces/device.mojom.h"
#include "device/usb/public/interfaces/permission_provider.mojom.h"
+#include "device/usb/usb_device.h"
#include "device/usb/usb_device_handle.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/callback.h"
@@ -28,7 +30,7 @@ namespace usb {
// Implementation of the public Device interface. Instances of this class are
// constructed by DeviceManagerImpl and are strongly bound to their MessagePipe
// lifetime.
-class DeviceImpl : public Device {
+class DeviceImpl : public Device, public device::UsbDevice::Observer {
public:
DeviceImpl(scoped_refptr<UsbDevice> device,
PermissionProviderPtr permission_provider,
@@ -94,14 +96,18 @@ class DeviceImpl : public Device {
uint32_t timeout,
const IsochronousTransferOutCallback& callback) override;
- mojo::Binding<Device> binding_;
+ // device::UsbDevice::Observer implementation:
+ void OnDeviceRemoved(scoped_refptr<device::UsbDevice>) override;
scoped_refptr<UsbDevice> device_;
+ ScopedObserver<device::UsbDevice, device::UsbDevice::Observer> observer_;
+
// The device handle. Will be null before the device is opened and after it
// has been closed.
scoped_refptr<UsbDeviceHandle> device_handle_;
PermissionProviderPtr permission_provider_;
+ mojo::Binding<Device> binding_;
base::WeakPtrFactory<DeviceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DeviceImpl);
« no previous file with comments | « device/usb/mock_usb_device.cc ('k') | device/usb/mojo/device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698