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

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

Issue 11667006: Create a list of policy changes before notifying observers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another ToT merge Created 7 years, 11 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_prefs_browsertest.cc ('k') | chrome/browser/policy/policy_service_impl.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.h
diff --git a/chrome/browser/policy/policy_service_impl.h b/chrome/browser/policy/policy_service_impl.h
index d5b739d66a283a26317703eae3d9faf8ecd86ac4..0c5a9299d12f21f1b27c3520d8e73c82e3b3363c 100644
--- a/chrome/browser/policy/policy_service_impl.h
+++ b/chrome/browser/policy/policy_service_impl.h
@@ -11,6 +11,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
#include "chrome/browser/policy/policy_bundle.h"
@@ -47,15 +48,32 @@ class PolicyServiceImpl : public PolicyService,
typedef ObserverList<PolicyService::Observer, true> Observers;
typedef std::map<PolicyDomain, Observers*> ObserverMap;
+ // Information about policy changes sent to observers.
+ class PolicyChangeInfo {
+ public:
+ PolicyChangeInfo(const PolicyBundle::PolicyNamespace& policy_namespace,
+ const PolicyMap& previous, const PolicyMap& current);
+ ~PolicyChangeInfo();
+
+ PolicyBundle::PolicyNamespace policy_namespace_;
+ PolicyMap previous_;
+ PolicyMap current_;
+ };
+
// ConfigurationPolicyProvider::Observer overrides:
virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE;
- // Notifies observers of |ns| that its policies have changed, passing along
- // the |previous| and the |current| policies.
+ // Posts a task to notify observers of |ns| that its policies have changed,
+ // passing along the |previous| and the |current| policies.
void NotifyNamespaceUpdated(const PolicyBundle::PolicyNamespace& ns,
const PolicyMap& previous,
const PolicyMap& current);
+ // Helper function invoked by NotifyNamespaceUpdated() to notify observers
+ // via a queued task, to deal with reentrancy issues caused by observers
+ // generating policy changes.
+ void NotifyNamespaceUpdatedTask(scoped_ptr<PolicyChangeInfo> info);
+
// Combines the policies from all the providers, and notifies the observers
// of namespaces whose policies have been modified.
void MergeAndTriggerUpdates();
@@ -87,6 +105,10 @@ class PolicyServiceImpl : public PolicyService,
// RefreshPolicies() call.
std::vector<base::Closure> refresh_callbacks_;
+ // Used to create tasks to delay new policy updates while we may be already
+ // processing previous policy updates.
+ base::WeakPtrFactory<PolicyServiceImpl> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl);
};
« no previous file with comments | « chrome/browser/policy/policy_prefs_browsertest.cc ('k') | chrome/browser/policy/policy_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698