Chromium Code Reviews| Index: chrome/browser/policy/cloud_policy_cache_base.h |
| diff --git a/chrome/browser/policy/cloud_policy_cache_base.h b/chrome/browser/policy/cloud_policy_cache_base.h |
| index 0fd89fcf78ca875a2ea2c323c45891cbfe1bcb18..282dd51442c45b56850010cce129782ea522d6d3 100644 |
| --- a/chrome/browser/policy/cloud_policy_cache_base.h |
| +++ b/chrome/browser/policy/cloud_policy_cache_base.h |
| @@ -6,19 +6,15 @@ |
| #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_ |
| #pragma once |
| -#include "base/gtest_prod_util.h" |
| -#include "base/memory/scoped_ptr.h" |
| #include "base/observer_list.h" |
| #include "base/threading/non_thread_safe.h" |
| #include "base/time.h" |
| #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| -#include "chrome/browser/policy/configuration_policy_provider.h" |
| #include "chrome/browser/policy/policy_map.h" |
| #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| namespace policy { |
| -class PolicyMap; |
| class PolicyNotifier; |
| namespace em = enterprise_management; |
| @@ -36,6 +32,13 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { |
| POLICY_LEVEL_RECOMMENDED, |
| }; |
| + class Observer { |
| + public: |
| + virtual ~Observer() {} |
| + virtual void OnCacheGoingAway(CloudPolicyCacheBase*) = 0; |
| + virtual void OnCacheUpdate(CloudPolicyCacheBase*) = 0; |
| + }; |
| + |
| CloudPolicyCacheBase(); |
| virtual ~CloudPolicyCacheBase(); |
| @@ -49,9 +52,6 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { |
| // Resets the policy information. |
| virtual void SetPolicy(const em::PolicyFetchResponse& policy) = 0; |
| - ConfigurationPolicyProvider* GetManagedPolicyProvider(); |
| - ConfigurationPolicyProvider* GetRecommendedPolicyProvider(); |
| - |
| virtual void SetUnmanaged() = 0; |
| bool is_unmanaged() const { |
| return is_unmanaged_; |
| @@ -67,6 +67,22 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { |
| // in. |
| bool GetPublicKeyVersion(int* version); |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + // Accessor for underlying PolicyMaps. |
| + const PolicyMap* mandatory_policy(); |
| + const PolicyMap* recommended_policy(); |
| + |
| + // Convenience function calling either mandatory_policy() or |
| + // recommended_policy() depending on |level|. |
|
Mattias Nissler (ping if slow)
2011/06/09 14:36:26
Do we need the accessors above then? Seems we shou
sfeuz
2011/06/13 06:53:53
I agree and think we should go with the policy() o
|
| + const PolicyMap* policy(PolicyLevel level); |
| + |
| + // See comment for |initialization_complete_|. |
| + bool initialization_complete() { |
| + return initialization_complete_; |
| + } |
| + |
| protected: |
| // Wraps public key version and validity. |
| struct PublicKeyVersion { |
| @@ -103,29 +119,19 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { |
| void InformNotifier(CloudPolicySubsystem::PolicySubsystemState state, |
| CloudPolicySubsystem::ErrorDetails error_details); |
| - // See comment for |initialization_complete_|. |
| - bool initialization_complete() { |
| - return initialization_complete_; |
| - } |
| - |
| void set_last_policy_refresh_time(base::Time timestamp) { |
| last_policy_refresh_time_ = timestamp; |
| } |
| private: |
| - class CloudPolicyProvider; |
| - |
| friend class DevicePolicyCacheTest; |
| friend class UserPolicyCacheTest; |
| + friend class MockCloudPolicyCacheBase; |
| // Policy key-value information. |
| PolicyMap mandatory_policy_; |
| PolicyMap recommended_policy_; |
| - // Policy providers. |
| - scoped_ptr<ConfigurationPolicyProvider> managed_policy_provider_; |
| - scoped_ptr<ConfigurationPolicyProvider> recommended_policy_provider_; |
| - |
| PolicyNotifier* notifier_; |
| // The time at which the policy was last refreshed. Is updated both upon |
| @@ -143,8 +149,8 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { |
| // Currently used public key version, if available. |
| PublicKeyVersion public_key_version_; |
| - // Provider observers that are registered with this cache's providers. |
| - ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; |
| + // Cache observers that are registered with this cache. |
| + ObserverList<Observer, true> observer_list_; |
| DISALLOW_COPY_AND_ASSIGN(CloudPolicyCacheBase); |
| }; |