diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 18:44:52 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 18:44:52 +0000 |
commit | 7a91c555f3e057f8be9010a4e5385678ce822c28 (patch) | |
tree | edb8a4384b09b3ce70b6b58a17afe5470eb5e039 /content/browser/notification_service_impl.cc | |
parent | e2e22a7ab44c2f49d856a9f840893c5462f52679 (diff) | |
download | chromium_src-7a91c555f3e057f8be9010a4e5385678ce822c28.zip chromium_src-7a91c555f3e057f8be9010a4e5385678ce822c28.tar.gz chromium_src-7a91c555f3e057f8be9010a4e5385678ce822c28.tar.bz2 |
content/browser: Move more files into the content namespace.
Fixed most of the files found with the following command line:
$ git grep --files-without-match --name-only "namespace content {" -- content/browser/{*.cc,*.h.*.mm}
R=jam@chromium.org
Review URL: https://codereview.chromium.org/11274038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/notification_service_impl.cc')
-rw-r--r-- | content/browser/notification_service_impl.cc | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/content/browser/notification_service_impl.cc b/content/browser/notification_service_impl.cc index 2c6fa06..01e4211 100644 --- a/content/browser/notification_service_impl.cc +++ b/content/browser/notification_service_impl.cc @@ -9,6 +9,8 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_types.h" +namespace content { + static base::LazyInstance<base::ThreadLocalPointer<NotificationServiceImpl> > lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER; @@ -18,18 +20,18 @@ NotificationServiceImpl* NotificationServiceImpl::current() { } // static -content::NotificationService* content::NotificationService::current() { +NotificationService* NotificationService::current() { return NotificationServiceImpl::current(); } // static -content::NotificationService* content::NotificationService::Create() { +NotificationService* NotificationService::Create() { return new NotificationServiceImpl; } // static bool NotificationServiceImpl::HasKey(const NotificationSourceMap& map, - const content::NotificationSource& source) { + const NotificationSource& source) { return map.find(source.map_key()) != map.end(); } @@ -38,10 +40,9 @@ NotificationServiceImpl::NotificationServiceImpl() { lazy_tls_ptr.Pointer()->Set(this); } -void NotificationServiceImpl::AddObserver( - content::NotificationObserver* observer, - int type, - const content::NotificationSource& source) { +void NotificationServiceImpl::AddObserver(NotificationObserver* observer, + int type, + const NotificationSource& source) { // We have gotten some crashes where the observer pointer is NULL. The problem // is that this happens when we actually execute a notification, so have no // way of knowing who the bad observer was. We want to know when this happens @@ -63,10 +64,9 @@ void NotificationServiceImpl::AddObserver( #endif } -void NotificationServiceImpl::RemoveObserver( - content::NotificationObserver* observer, - int type, - const content::NotificationSource& source) { +void NotificationServiceImpl::RemoveObserver(NotificationObserver* observer, + int type, + const NotificationSource& source) { // This is a very serious bug. An object is most likely being deleted on // the wrong thread, and as a result another thread's NotificationServiceImpl // has its deleted pointer in its map. A garbge object will be called in the @@ -89,42 +89,41 @@ void NotificationServiceImpl::RemoveObserver( } } -void NotificationServiceImpl::Notify( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(type > content::NOTIFICATION_ALL) << +void NotificationServiceImpl::Notify(int type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(type > NOTIFICATION_ALL) << "Allowed for observing, but not posting."; // There's no particular reason for the order in which the different // classes of observers get notified here. // Notify observers of all types and all sources - if (HasKey(observers_[content::NOTIFICATION_ALL], AllSources()) && + if (HasKey(observers_[NOTIFICATION_ALL], AllSources()) && source != AllSources()) { - FOR_EACH_OBSERVER(content::NotificationObserver, - *observers_[content::NOTIFICATION_ALL][AllSources().map_key()], + FOR_EACH_OBSERVER(NotificationObserver, + *observers_[NOTIFICATION_ALL][AllSources().map_key()], Observe(type, source, details)); } // Notify observers of all types and the given source - if (HasKey(observers_[content::NOTIFICATION_ALL], source)) { - FOR_EACH_OBSERVER(content::NotificationObserver, - *observers_[content::NOTIFICATION_ALL][source.map_key()], + if (HasKey(observers_[NOTIFICATION_ALL], source)) { + FOR_EACH_OBSERVER(NotificationObserver, + *observers_[NOTIFICATION_ALL][source.map_key()], Observe(type, source, details)); } // Notify observers of the given type and all sources if (HasKey(observers_[type], AllSources()) && source != AllSources()) { - FOR_EACH_OBSERVER(content::NotificationObserver, + FOR_EACH_OBSERVER(NotificationObserver, *observers_[type][AllSources().map_key()], Observe(type, source, details)); } // Notify observers of the given type and the given source if (HasKey(observers_[type], source)) { - FOR_EACH_OBSERVER(content::NotificationObserver, + FOR_EACH_OBSERVER(NotificationObserver, *observers_[type][source.map_key()], Observe(type, source, details)); } @@ -152,3 +151,5 @@ NotificationServiceImpl::~NotificationServiceImpl() { delete it->second; } } + +} // namespace content |