| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace policy { | 22 namespace policy { |
| 23 | 23 |
| 24 class PolicyMap; | 24 class PolicyMap; |
| 25 | 25 |
| 26 class POLICY_EXPORT PolicyServiceImpl | 26 class POLICY_EXPORT PolicyServiceImpl |
| 27 : public PolicyService, | 27 : public PolicyService, |
| 28 public ConfigurationPolicyProvider::Observer { | 28 public ConfigurationPolicyProvider::Observer { |
| 29 public: | 29 public: |
| 30 typedef std::vector<ConfigurationPolicyProvider*> Providers; | 30 typedef std::vector<ConfigurationPolicyProvider*> Providers; |
| 31 typedef base::Callback<void(PolicyBundle*)> PreprocessCallback; | |
| 32 | 31 |
| 33 // The PolicyServiceImpl will merge policies from |providers|. |providers| | 32 // The PolicyServiceImpl will merge policies from |providers|. |providers| |
| 34 // must be sorted in decreasing order of priority; the first provider will | 33 // must be sorted in decreasing order of priority; the first provider will |
| 35 // have the highest priority. The PolicyServiceImpl does not take ownership of | 34 // have the highest priority. The PolicyServiceImpl does not take ownership of |
| 36 // the providers, and they must outlive the PolicyServiceImpl. | 35 // the providers, and they must outlive the PolicyServiceImpl. |
| 37 // |preprocess_callback| will be applied every PolicyBundle before merginng. | 36 explicit PolicyServiceImpl(const Providers& providers); |
| 38 PolicyServiceImpl(const Providers& providers, | |
| 39 const PreprocessCallback& preprocess_callback); | |
| 40 | 37 |
| 41 virtual ~PolicyServiceImpl(); | 38 virtual ~PolicyServiceImpl(); |
| 42 | 39 |
| 43 // PolicyService overrides: | 40 // PolicyService overrides: |
| 44 virtual void AddObserver(PolicyDomain domain, | 41 virtual void AddObserver(PolicyDomain domain, |
| 45 PolicyService::Observer* observer) OVERRIDE; | 42 PolicyService::Observer* observer) OVERRIDE; |
| 46 virtual void RemoveObserver(PolicyDomain domain, | 43 virtual void RemoveObserver(PolicyDomain domain, |
| 47 PolicyService::Observer* observer) OVERRIDE; | 44 PolicyService::Observer* observer) OVERRIDE; |
| 48 virtual const PolicyMap& GetPolicies( | 45 virtual const PolicyMap& GetPolicies( |
| 49 const PolicyNamespace& ns) const OVERRIDE; | 46 const PolicyNamespace& ns) const OVERRIDE; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Maps each policy domain to its observer list. | 80 // Maps each policy domain to its observer list. |
| 84 ObserverMap observers_; | 81 ObserverMap observers_; |
| 85 | 82 |
| 86 // True if all the providers are initialized for the indexed policy domain. | 83 // True if all the providers are initialized for the indexed policy domain. |
| 87 bool initialization_complete_[POLICY_DOMAIN_SIZE]; | 84 bool initialization_complete_[POLICY_DOMAIN_SIZE]; |
| 88 | 85 |
| 89 // Set of providers that have a pending update that was triggered by a | 86 // Set of providers that have a pending update that was triggered by a |
| 90 // call to RefreshPolicies(). | 87 // call to RefreshPolicies(). |
| 91 std::set<ConfigurationPolicyProvider*> refresh_pending_; | 88 std::set<ConfigurationPolicyProvider*> refresh_pending_; |
| 92 | 89 |
| 93 // Callback invoked to manipulate a PolicyBundle before it is merged. | |
| 94 PreprocessCallback preprocess_callback_; | |
| 95 | |
| 96 // List of callbacks to invoke once all providers refresh after a | 90 // List of callbacks to invoke once all providers refresh after a |
| 97 // RefreshPolicies() call. | 91 // RefreshPolicies() call. |
| 98 std::vector<base::Closure> refresh_callbacks_; | 92 std::vector<base::Closure> refresh_callbacks_; |
| 99 | 93 |
| 100 // Used to create tasks to delay new policy updates while we may be already | 94 // Used to create tasks to delay new policy updates while we may be already |
| 101 // processing previous policy updates. | 95 // processing previous policy updates. |
| 102 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; | 96 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; |
| 103 | 97 |
| 104 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); | 98 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); |
| 105 }; | 99 }; |
| 106 | 100 |
| 107 } // namespace policy | 101 } // namespace policy |
| 108 | 102 |
| 109 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ | 103 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ |
| OLD | NEW |