summaryrefslogtreecommitdiffstats
path: root/device/usb/usb_service.cc
diff options
context:
space:
mode:
authorjuncai <juncai@chromium.org>2015-08-19 14:31:02 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-19 21:31:32 +0000
commit91ba0d2a066d212beaa3f735d4002450d3bc62a8 (patch)
tree8e21486f753478b339ce98f4e870430b71cb4d3a /device/usb/usb_service.cc
parentc4574bb40a1be63a38284a81c8e2ef335d7a788c (diff)
downloadchromium_src-91ba0d2a066d212beaa3f735d4002450d3bc62a8.zip
chromium_src-91ba0d2a066d212beaa3f735d4002450d3bc62a8.tar.gz
chromium_src-91ba0d2a066d212beaa3f735d4002450d3bc62a8.tar.bz2
Update UsbService to be destroyed by a task registered with AtExitManager.
This patch updated code for UsbService to be destroyed by a task registered with the AtExitManager instead of using the MessageLoop::DestructionObserver. Review URL: https://codereview.chromium.org/1299123002 Cr-Commit-Position: refs/heads/master@{#344326}
Diffstat (limited to 'device/usb/usb_service.cc')
-rw-r--r--device/usb/usb_service.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/device/usb/usb_service.cc b/device/usb/usb_service.cc
index a47cd37..99ad59b 100644
--- a/device/usb/usb_service.cc
+++ b/device/usb/usb_service.cc
@@ -4,7 +4,8 @@
#include "device/usb/usb_service.h"
-#include "base/message_loop/message_loop.h"
+#include "base/at_exit.h"
+#include "base/bind.h"
#include "components/device_event_log/device_event_log.h"
#include "device/usb/usb_device.h"
#include "device/usb/usb_service_impl.h"
@@ -31,9 +32,12 @@ void UsbService::Observer::OnDeviceRemovedCleanup(
UsbService* UsbService::GetInstance(
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) {
if (!g_service) {
- // The UsbService constructor saves this object and UsbServiceImpl will
- // destroy itself when the current message loop exits.
+ // |g_service| is set by the UsbService constructor.
new UsbServiceImpl(blocking_task_runner);
+ if (!g_service) {
+ base::AtExitManager::RegisterTask(base::Bind(
+ &base::DeletePointer<UsbService>, base::Unretained(g_service)));
+ }
}
return g_service;
}