diff options
Diffstat (limited to 'device')
-rw-r--r-- | device/devices_app/usb/device_manager_impl.cc | 2 | ||||
-rw-r--r-- | device/usb/usb_service.cc | 6 | ||||
-rw-r--r-- | device/usb/usb_service.h | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/device/devices_app/usb/device_manager_impl.cc b/device/devices_app/usb/device_manager_impl.cc index f438460..559edf6 100644 --- a/device/devices_app/usb/device_manager_impl.cc +++ b/device/devices_app/usb/device_manager_impl.cc @@ -153,6 +153,8 @@ class DeviceManagerImpl::ServiceThreadHelper device->guid())); } + void WillDestroyUsbService() override { observer_.RemoveAll(); } + // base::MessageLoop::DestructionObserver void WillDestroyCurrentMessageLoop() override { delete this; } diff --git a/device/usb/usb_service.cc b/device/usb/usb_service.cc index ef6763a..de9716f 100644 --- a/device/usb/usb_service.cc +++ b/device/usb/usb_service.cc @@ -24,13 +24,17 @@ void UsbService::Observer::OnDeviceRemovedCleanup( scoped_refptr<UsbDevice> device) { } +void UsbService::Observer::WillDestroyUsbService() {} + // static scoped_ptr<UsbService> UsbService::Create( scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { return make_scoped_ptr(new UsbServiceImpl(blocking_task_runner)); } -UsbService::~UsbService() {} +UsbService::~UsbService() { + FOR_EACH_OBSERVER(Observer, observer_list_, WillDestroyUsbService()); +} UsbService::UsbService() {} diff --git a/device/usb/usb_service.h b/device/usb/usb_service.h index dbb837f..519feb6 100644 --- a/device/usb/usb_service.h +++ b/device/usb/usb_service.h @@ -42,6 +42,9 @@ class UsbService : public base::NonThreadSafe { // For observers that need to process device removal after others have run. // Should not depend on any other service's knowledge of connected devices. virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); + + // Notifies the observer that the UsbService it depends on is shutting down. + virtual void WillDestroyUsbService(); }; // The file task runner reference is used for blocking I/O operations. |