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

Unified Diff: device/usb/usb_service.cc

Issue 2797433005: Remove MessageLoop destruction observer from //device/usb (Closed)
Patch Set: Further clarify cross-thread ownership Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/usb_device_handle_usbfs.cc ('k') | device/usb/usb_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service.cc
diff --git a/device/usb/usb_service.cc b/device/usb/usb_service.cc
index 80873c0e6e94b3160f968a987510e36e6b238370..b560cd0c36441dae85e6dd3bfd4cc814037009fa 100644
--- a/device/usb/usb_service.cc
+++ b/device/usb/usb_service.cc
@@ -13,6 +13,7 @@
#include "components/device_event_log/device_event_log.h"
#include "device/base/features.h"
#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_handle.h"
#if defined(OS_ANDROID)
#include "device/usb/usb_service_android.h"
@@ -86,6 +87,13 @@ scoped_refptr<UsbDevice> UsbService::GetDevice(const std::string& guid) {
}
void UsbService::Shutdown() {
+ for (const auto& map_entry : devices_) {
+ // Swap out this list as UsbDevice::HandleClosed() will try to modify it.
+ std::list<UsbDeviceHandle*> handles;
+ handles.swap(map_entry.second->handles());
+ for (auto* handle : handles)
+ handle->Close();
+ }
#if DCHECK_IS_ON()
DCHECK(!did_shutdown_);
did_shutdown_ = true;
« no previous file with comments | « device/usb/usb_device_handle_usbfs.cc ('k') | device/usb/usb_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698