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

Unified Diff: chrome/browser/policy/policy_service_impl.cc

Issue 10174003: Pass the previous and the current PolicyMap to Observers of the PolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/policy_service.h ('k') | chrome/browser/policy/policy_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_service_impl.cc
diff --git a/chrome/browser/policy/policy_service_impl.cc b/chrome/browser/policy/policy_service_impl.cc
index 5083a0cf490d2961c10927126d347943d1d902aa..a9111665457d6d43b39e561f87ff43af4b71de63 100644
--- a/chrome/browser/policy/policy_service_impl.cc
+++ b/chrome/browser/policy/policy_service_impl.cc
@@ -125,18 +125,21 @@ void PolicyServiceImpl::MaybeCleanup(const PolicyNamespace& ns) {
void PolicyServiceImpl::MergeAndTriggerUpdates() {
// TODO(joaodasilva): do this for each namespace once the providers also
// provide policy for more namespaces.
- PolicyMap new_policies;
+ PolicyMap policies;
for (ProviderList::iterator it = providers_.begin();
it != providers_.end(); ++it) {
- new_policies.MergeFrom((*it)->policies);
+ policies.MergeFrom((*it)->policies);
}
Entry* entry = GetOrCreate(std::make_pair(POLICY_DOMAIN_CHROME, ""));
- if (!new_policies.Equals(entry->policies)) {
- entry->policies.Swap(&new_policies);
- FOR_EACH_OBSERVER(PolicyService::Observer,
- entry->observers,
- OnPolicyUpdated(POLICY_DOMAIN_CHROME, ""));
+ if (!policies.Equals(entry->policies)) {
+ // Swap first, so that observers that call GetPolicies() see the current
+ // values.
+ entry->policies.Swap(&policies);
+ FOR_EACH_OBSERVER(
+ PolicyService::Observer,
+ entry->observers,
+ OnPolicyUpdated(POLICY_DOMAIN_CHROME, "", policies, entry->policies));
}
// Check if all providers became initialized just now, if they weren't before.
« no previous file with comments | « chrome/browser/policy/policy_service.h ('k') | chrome/browser/policy/policy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698