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

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

Issue 23190045: Switch ObserverList::size() to ObserverList::might_have_observers() Pt.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/media/webrtc_internals.cc ('k') | media/base/user_input_monitor.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // has its deleted pointer in its map. A garbge object will be called in the 76 // has its deleted pointer in its map. A garbge object will be called in the
77 // future. 77 // future.
78 // NOTE: when this check shows crashes, use BrowserThread::DeleteOnIOThread or 78 // NOTE: when this check shows crashes, use BrowserThread::DeleteOnIOThread or
79 // other variants as the trait on the object. 79 // other variants as the trait on the object.
80 CHECK(HasKey(observers_[type], source)); 80 CHECK(HasKey(observers_[type], source));
81 81
82 NotificationObserverList* observer_list = 82 NotificationObserverList* observer_list =
83 observers_[type][source.map_key()]; 83 observers_[type][source.map_key()];
84 if (observer_list) { 84 if (observer_list) {
85 observer_list->RemoveObserver(observer); 85 observer_list->RemoveObserver(observer);
86 if (!observer_list->size()) { 86 if (!observer_list->might_have_observers()) {
87 observers_[type].erase(source.map_key()); 87 observers_[type].erase(source.map_key());
88 delete observer_list; 88 delete observer_list;
89 } 89 }
90 #ifndef NDEBUG 90 #ifndef NDEBUG
91 --observer_counts_[type]; 91 --observer_counts_[type];
92 #endif 92 #endif
93 } 93 }
94 } 94 }
95 95
96 void NotificationServiceImpl::Notify(int type, 96 void NotificationServiceImpl::Notify(int type,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 for (int i = 0; i < static_cast<int>(observers_.size()); i++) { 151 for (int i = 0; i < static_cast<int>(observers_.size()); i++) {
152 NotificationSourceMap omap = observers_[i]; 152 NotificationSourceMap omap = observers_[i];
153 for (NotificationSourceMap::iterator it = omap.begin(); 153 for (NotificationSourceMap::iterator it = omap.begin();
154 it != omap.end(); ++it) 154 it != omap.end(); ++it)
155 delete it->second; 155 delete it->second;
156 } 156 }
157 } 157 }
158 158
159 } // namespace content 159 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/webrtc_internals.cc ('k') | media/base/user_input_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698