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

Unified Diff: chrome/common/notification_service.cc

Issue 1660: Move a bunch of code from the old to new TLS interface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | « chrome/common/notification_service.h ('k') | chrome/renderer/render_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/notification_service.cc
===================================================================
--- chrome/common/notification_service.cc (revision 1894)
+++ chrome/common/notification_service.cc (working copy)
@@ -4,9 +4,16 @@
#include "chrome/common/notification_service.h"
-// TODO(evanm): This shouldn't depend on static initialization.
+#include "base/lazy_instance.h"
+#include "base/thread_local.h"
+
+static base::LazyInstance<base::ThreadLocalPointer<NotificationService> >
+ lazy_tls_ptr(base::LINKER_INITIALIZED);
+
// static
-TLSSlot NotificationService::tls_index_;
+NotificationService* NotificationService::current() {
+ return lazy_tls_ptr.Pointer()->Get();
+}
// static
bool NotificationService::HasKey(const NotificationSourceMap& map,
@@ -20,7 +27,7 @@
memset(observer_counts_, 0, sizeof(observer_counts_));
#endif
- tls_index_.Set(this);
+ lazy_tls_ptr.Pointer()->Set(this);
}
void NotificationService::AddObserver(NotificationObserver* observer,
@@ -94,7 +101,7 @@
NotificationService::~NotificationService() {
- tls_index_.Set(NULL);
+ lazy_tls_ptr.Pointer()->Set(NULL);
#ifndef NDEBUG
for (int i = 0; i < NOTIFICATION_TYPE_COUNT; i++) {
« no previous file with comments | « chrome/common/notification_service.h ('k') | chrome/renderer/render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698