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

Side by Side Diff: chrome/browser/policy/policy_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
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 "chrome/browser/policy/policy_service_impl.h" 5 #include "chrome/browser/policy/policy_service_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 void PolicyServiceImpl::RemoveObserver(PolicyDomain domain, 51 void PolicyServiceImpl::RemoveObserver(PolicyDomain domain,
52 PolicyService::Observer* observer) { 52 PolicyService::Observer* observer) {
53 ObserverMap::iterator it = observers_.find(domain); 53 ObserverMap::iterator it = observers_.find(domain);
54 if (it == observers_.end()) { 54 if (it == observers_.end()) {
55 NOTREACHED(); 55 NOTREACHED();
56 return; 56 return;
57 } 57 }
58 it->second->RemoveObserver(observer); 58 it->second->RemoveObserver(observer);
59 if (it->second->size() == 0) { 59 if (!it->second->might_have_observers()) {
60 delete it->second; 60 delete it->second;
61 observers_.erase(it); 61 observers_.erase(it);
62 } 62 }
63 } 63 }
64 64
65 void PolicyServiceImpl::RegisterPolicyDomain( 65 void PolicyServiceImpl::RegisterPolicyDomain(
66 scoped_refptr<const PolicyDomainDescriptor> descriptor) { 66 scoped_refptr<const PolicyDomainDescriptor> descriptor) {
67 domain_descriptors_[descriptor->domain()] = descriptor; 67 domain_descriptors_[descriptor->domain()] = descriptor;
68 for (Iterator it = providers_.begin(); it != providers_.end(); ++it) 68 for (Iterator it = providers_.begin(); it != providers_.end(); ++it)
69 (*it)->RegisterPolicyDomain(descriptor); 69 (*it)->RegisterPolicyDomain(descriptor);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) { 217 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) {
218 std::vector<base::Closure> callbacks; 218 std::vector<base::Closure> callbacks;
219 callbacks.swap(refresh_callbacks_); 219 callbacks.swap(refresh_callbacks_);
220 std::vector<base::Closure>::iterator it; 220 std::vector<base::Closure>::iterator it;
221 for (it = callbacks.begin(); it != callbacks.end(); ++it) 221 for (it = callbacks.begin(); it != callbacks.end(); ++it)
222 it->Run(); 222 it->Run();
223 } 223 }
224 } 224 }
225 225
226 } // namespace policy 226 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/net/pref_proxy_config_tracker_impl.cc ('k') | chrome/browser/status_icons/status_icon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698