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

Unified Diff: device/usb/usb_service.cc

Issue 1314273002: Manage UsbService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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_service.h ('k') | device/usb/usb_service_impl.h » ('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 9f9f02c20b7f242ef9b58927ff800c2bf350bf3b..ef6763a74d2530d7f743e8aa8ecef49463750cd4 100644
--- a/device/usb/usb_service.cc
+++ b/device/usb/usb_service.cc
@@ -12,12 +12,6 @@
namespace device {
-namespace {
-
-UsbService* g_service;
-
-} // namespace
-
UsbService::Observer::~Observer() {}
void UsbService::Observer::OnDeviceAdded(scoped_refptr<UsbDevice> device) {
@@ -31,28 +25,14 @@ void UsbService::Observer::OnDeviceRemovedCleanup(
}
// static
-UsbService* UsbService::GetInstance(
+scoped_ptr<UsbService> UsbService::Create(
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) {
- if (!g_service) {
- // |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;
+ return make_scoped_ptr(new UsbServiceImpl(blocking_task_runner));
}
-UsbService::UsbService() {
- DCHECK(!g_service);
- g_service = this;
-}
+UsbService::~UsbService() {}
-UsbService::~UsbService() {
- DCHECK(g_service);
- g_service = nullptr;
-}
+UsbService::UsbService() {}
void UsbService::AddObserver(Observer* observer) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « device/usb/usb_service.h ('k') | device/usb/usb_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698