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

Side by Side Diff: content/browser/notification_service_impl.cc

Issue 8913009: Hide the process of instantiating NotificationServiceImpl from embedders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | content/public/browser/notification_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/notification_service_impl.h" 5 #include "content/browser/notification_service_impl.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/public/browser/notification_observer.h" 9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
11 11
12 static base::LazyInstance<base::ThreadLocalPointer<NotificationServiceImpl> > 12 static base::LazyInstance<base::ThreadLocalPointer<NotificationServiceImpl> >
13 lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER; 13 lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER;
14 14
15 // static 15 // static
16 NotificationServiceImpl* NotificationServiceImpl::current() { 16 NotificationServiceImpl* NotificationServiceImpl::current() {
17 return lazy_tls_ptr.Pointer()->Get(); 17 return lazy_tls_ptr.Pointer()->Get();
18 } 18 }
19 19
20 // static 20 // static
21 content::NotificationService* content::NotificationService::current() { 21 content::NotificationService* content::NotificationService::current() {
22 return NotificationServiceImpl::current(); 22 return NotificationServiceImpl::current();
23 } 23 }
24 24
25 // static 25 // static
26 content::NotificationService* content::NotificationService::Create() {
27 return new NotificationServiceImpl;
28 }
29
30 // static
26 bool NotificationServiceImpl::HasKey(const NotificationSourceMap& map, 31 bool NotificationServiceImpl::HasKey(const NotificationSourceMap& map,
27 const content::NotificationSource& source) { 32 const content::NotificationSource& source) {
28 return map.find(source.map_key()) != map.end(); 33 return map.find(source.map_key()) != map.end();
29 } 34 }
30 35
31 NotificationServiceImpl::NotificationServiceImpl() { 36 NotificationServiceImpl::NotificationServiceImpl() {
32 DCHECK(current() == NULL); 37 DCHECK(current() == NULL);
33 lazy_tls_ptr.Pointer()->Set(this); 38 lazy_tls_ptr.Pointer()->Set(this);
34 } 39 }
35 40
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 143 }
139 #endif 144 #endif
140 145
141 for (int i = 0; i < static_cast<int>(observers_.size()); i++) { 146 for (int i = 0; i < static_cast<int>(observers_.size()); i++) {
142 NotificationSourceMap omap = observers_[i]; 147 NotificationSourceMap omap = observers_[i];
143 for (NotificationSourceMap::iterator it = omap.begin(); 148 for (NotificationSourceMap::iterator it = omap.begin();
144 it != omap.end(); ++it) 149 it != omap.end(); ++it)
145 delete it->second; 150 delete it->second;
146 } 151 }
147 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | content/public/browser/notification_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698