diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-10 10:54:06 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-10 10:54:06 +0000 |
commit | f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4 (patch) | |
tree | 1ab6d88512e17de10c913cc163a31a7d5b2369bd /chrome/common/notification_service.cc | |
parent | 83c7264800194b0d9ffdce49c57a3fdd5cf6a1a0 (diff) | |
download | chromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.zip chromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.tar.gz chromium_src-f886b7bf801cbdd2d9e4b31a8f74bc7490922cd4.tar.bz2 |
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
Diffstat (limited to 'chrome/common/notification_service.cc')
-rw-r--r-- | chrome/common/notification_service.cc | 15 |
1 files changed, 11 insertions, 4 deletions
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<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 @@ 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++) { |