Chromium Code Reviews| Index: chrome/browser/policy/cloud_policy_provider.h |
| diff --git a/chrome/browser/policy/cloud_policy_provider.h b/chrome/browser/policy/cloud_policy_provider.h |
| index a9bc606ba4d26dc689557ae9529c1b4c398d7bfd..cba417e6c57502afc71a7f0e0eca7a461dd9ad48 100644 |
| --- a/chrome/browser/policy/cloud_policy_provider.h |
| +++ b/chrome/browser/policy/cloud_policy_provider.h |
| @@ -6,39 +6,78 @@ |
| #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ |
| #pragma once |
| +#include <set> |
| + |
| #include "base/basictypes.h" |
| +#include "chrome/browser/policy/cloud_policy_cache_base.h" |
| #include "chrome/browser/policy/configuration_policy_provider.h" |
| +#include "chrome/browser/policy/policy_map.h" |
| namespace policy { |
| -class CloudPolicyCacheBase; |
| - |
| -// A policy provider having multiple backend caches, combining their relevant |
| -// PolicyMaps and keeping the result cached. The underlying caches are kept as |
| -// weak references and can be added dynamically. Also the |
| -// |CloudPolicyProvider| instance listens to cache-notifications and removes |
| -// the caches automatically when they go away. The order in which the caches are |
| -// stored matters! The first cache is applied as is and the following caches |
| -// only contribute the not-yet applied policies. There are two functions to add |
| -// a new cache: |
| -// PrependCache(cache): adds |cache| to the front (i.e. most important cache). |
| -// AppendCache(cache): adds |cache| to the back (i.e. least important cache). |
| -class CloudPolicyProvider : public ConfigurationPolicyProvider { |
| +class BrowserPolicyConnector; |
| + |
| +// A policy provider that merges the policies contained in its policy caches. |
|
Mattias Nissler (ping if slow)
2012/03/30 08:48:46
This sentence suggests that every policy provide h
Joao da Silva
2012/03/30 10:09:23
Done.
|
| +// The caches receive their policies by fetching them from the cloud, through |
| +// the CloudPolicyController. |
| +class CloudPolicyProvider : public ConfigurationPolicyProvider, |
| + public CloudPolicyCacheBase::Observer { |
| public: |
| - explicit CloudPolicyProvider(const PolicyDefinitionList* policy_list); |
| + CloudPolicyProvider(BrowserPolicyConnector* browser_policy_connector, |
| + const PolicyDefinitionList* policy_list, |
| + PolicyLevel level); |
| virtual ~CloudPolicyProvider(); |
| - // Adds a new instance of CloudPolicyCacheBase to the end of |caches_|. |
| - // Does not take ownership of |cache| and listens to OnCacheGoingAway to |
| - // automatically remove it from |caches_|. |
| - virtual void AppendCache(CloudPolicyCacheBase* cache) = 0; |
| + void SetUserPolicyCache(CloudPolicyCacheBase* cache); |
| + |
| +#if defined(OS_CHROMEOS) |
| + void SetDevicePolicyCache(CloudPolicyCacheBase* cache); |
| +#endif |
| - // Adds a new instance of CloudPolicyCacheBase to the beginning of |caches_|. |
| - // Does not take ownership of |cache| and listens to OnCacheGoingAway to |
| - // automatically remove it from |caches_|. |
| - virtual void PrependCache(CloudPolicyCacheBase* cache) = 0; |
| + // ConfigurationPolicyProvider implementation. |
| + virtual bool ProvideInternal(PolicyMap* result) OVERRIDE; |
| + virtual bool IsInitializationComplete() const OVERRIDE; |
| + virtual void RefreshPolicies() OVERRIDE; |
| + |
| + // CloudPolicyCacheBase::Observer implementation. |
| + virtual void OnCacheUpdate(CloudPolicyCacheBase* cache) OVERRIDE; |
| + virtual void OnCacheGoingAway(CloudPolicyCacheBase* cache) OVERRIDE; |
| private: |
| + // Indices of the known caches in |caches_|. |
| + enum { |
| + CACHE_USER, |
| +#if defined(OS_CHROMEOS) |
| + CACHE_DEVICE, |
| +#endif |
| + CACHE_SIZE, |
| + }; |
| + |
| + // Merges policies from both caches, and triggers a notification if ready. |
| + void Merge(); |
| + |
| + // The device and user policy caches, whose policies are provided by |this|. |
| + // Both are initially NULL, and the provider only becomes initialized once |
| + // all the caches are available and ready. |
| + CloudPolicyCacheBase* caches_[CACHE_SIZE]; |
| + |
| + // Weak pointer to the connector. Guaranteed to outlive |this|. |
| + BrowserPolicyConnector* browser_policy_connector_; |
| + |
| + // The policy level published by this provider. |
| + PolicyLevel level_; |
| + |
| + // Whether all caches are present and fully initialized. |
| + bool initialization_complete_; |
| + |
| + // Used to determine when updates due to a RefreshPolicies() call have been |
| + // completed. |
| + std::set<const CloudPolicyCacheBase*> pending_updates_; |
| + |
| + // The currently valid combination of the caches. ProvideInternal() fills |
| + // |results| with a copy of |combined_|. |
| + PolicyMap combined_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider); |
| }; |