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

Unified Diff: mojo/common/handle_watcher.cc

Issue 281353005: Mojo: nuke EnvironmentData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gn Created 6 years, 6 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 | « mojo/common/environment_data.cc ('k') | mojo/common/handle_watcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/handle_watcher.cc
diff --git a/mojo/common/handle_watcher.cc b/mojo/common/handle_watcher.cc
index 1affa9041be060f14ee455934c7ee616457b7254..4ae86dbd196adea26e4b091a8a39d36ca41d475e 100644
--- a/mojo/common/handle_watcher.cc
+++ b/mojo/common/handle_watcher.cc
@@ -9,13 +9,13 @@
#include "base/atomic_sequence_num.h"
#include "base/bind.h"
#include "base/lazy_instance.h"
+#include "base/memory/singleton.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
-#include "mojo/common/environment_data.h"
#include "mojo/common/message_pump_mojo.h"
#include "mojo/common/message_pump_mojo_handler.h"
#include "mojo/common/time_helper.h"
@@ -29,8 +29,6 @@ namespace {
const char kWatcherThreadName[] = "handle-watcher-thread";
-const char kWatcherThreadManagerKey[] = "watcher-thread-manager";
-
// TODO(sky): this should be unnecessary once MessageLoop has been refactored.
MessagePumpMojo* message_pump_mojo = NULL;
@@ -176,6 +174,7 @@ class WatcherThreadManager {
void StopWatching(WatcherID watcher_id);
private:
+ friend struct DefaultSingletonTraits<WatcherThreadManager>;
WatcherThreadManager();
base::Thread thread_;
@@ -187,29 +186,12 @@ class WatcherThreadManager {
DISALLOW_COPY_AND_ASSIGN(WatcherThreadManager);
};
-struct WatcherThreadManagerData : EnvironmentData::Data {
- scoped_ptr<WatcherThreadManager> thread_manager;
-};
-
WatcherThreadManager::~WatcherThreadManager() {
thread_.Stop();
}
-static base::LazyInstance<base::Lock> thread_lookup_lock =
- LAZY_INSTANCE_INITIALIZER;
-
WatcherThreadManager* WatcherThreadManager::GetInstance() {
- base::AutoLock auto_lock(thread_lookup_lock.Get());
- WatcherThreadManagerData* data = static_cast<WatcherThreadManagerData*>(
- EnvironmentData::GetInstance()->GetData(kWatcherThreadManagerKey));
- if (!data) {
- data = new WatcherThreadManagerData;
- data->thread_manager.reset(new WatcherThreadManager);
- EnvironmentData::GetInstance()->SetData(
- kWatcherThreadManagerKey,
- scoped_ptr<EnvironmentData::Data>(data));
- }
- return data->thread_manager.get();
+ return Singleton<WatcherThreadManager>::get();
}
WatcherID WatcherThreadManager::StartWatching(
« no previous file with comments | « mojo/common/environment_data.cc ('k') | mojo/common/handle_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698