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..14710c4aa18ac347598b8e67383c6a86dac7f38e 100644 |
--- a/chrome/browser/policy/policy_service_impl.cc |
+++ b/chrome/browser/policy/policy_service_impl.cc |
@@ -125,18 +125,23 @@ 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); |
+ // |policies| now contains the previous values, and |entry->policies| |
+ // contains the current values. |
Mattias Nissler (ping if slow)
2012/04/23 14:20:44
I think this comment is redundant and can be remov
Joao da Silva
2012/04/23 14:53:19
Done.
|
+ 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. |