From f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4 Mon Sep 17 00:00:00 2001 From: "deanm@chromium.org" Date: Wed, 10 Sep 2008 10:54:06 +0000 Subject: Move a bunch of code from the old to new TLS interface. Review URL: http://codereview.chromium.org/1660 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1982 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/notification_service.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'chrome/common/notification_service.cc') diff --git a/chrome/common/notification_service.cc b/chrome/common/notification_service.cc index 5bf54c3..dccadbe 100644 --- a/chrome/common/notification_service.cc +++ b/chrome/common/notification_service.cc @@ -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 > + 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 @@ NotificationService::NotificationService() { 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 @@ void NotificationService::Notify(NotificationType type, NotificationService::~NotificationService() { - tls_index_.Set(NULL); + lazy_tls_ptr.Pointer()->Set(NULL); #ifndef NDEBUG for (int i = 0; i < NOTIFICATION_TYPE_COUNT; i++) { -- cgit v1.1