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

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: 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
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.

Powered by Google App Engine
This is Rietveld 408576698