OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |