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 CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_POLICY_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 20 matching lines...) Expand all Loading... |
31 // have the highest priority. The PolicyServiceImpl does not take ownership of | 31 // have the highest priority. The PolicyServiceImpl does not take ownership of |
32 // the providers, and they must outlive the PolicyServiceImpl. | 32 // the providers, and they must outlive the PolicyServiceImpl. |
33 explicit PolicyServiceImpl(const Providers& providers); | 33 explicit PolicyServiceImpl(const Providers& providers); |
34 virtual ~PolicyServiceImpl(); | 34 virtual ~PolicyServiceImpl(); |
35 | 35 |
36 // PolicyService overrides: | 36 // PolicyService overrides: |
37 virtual void AddObserver(PolicyDomain domain, | 37 virtual void AddObserver(PolicyDomain domain, |
38 PolicyService::Observer* observer) OVERRIDE; | 38 PolicyService::Observer* observer) OVERRIDE; |
39 virtual void RemoveObserver(PolicyDomain domain, | 39 virtual void RemoveObserver(PolicyDomain domain, |
40 PolicyService::Observer* observer) OVERRIDE; | 40 PolicyService::Observer* observer) OVERRIDE; |
41 virtual void RegisterPolicyDomain( | |
42 scoped_refptr<const PolicyDomainDescriptor> descriptor) OVERRIDE; | |
43 virtual const PolicyMap& GetPolicies( | 41 virtual const PolicyMap& GetPolicies( |
44 const PolicyNamespace& ns) const OVERRIDE; | 42 const PolicyNamespace& ns) const OVERRIDE; |
45 virtual scoped_refptr<const PolicyDomainDescriptor> GetPolicyDomainDescriptor( | |
46 PolicyDomain domain) const OVERRIDE; | |
47 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | 43 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; |
48 virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE; | 44 virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE; |
49 | 45 |
50 private: | 46 private: |
51 typedef ObserverList<PolicyService::Observer, true> Observers; | 47 typedef ObserverList<PolicyService::Observer, true> Observers; |
52 typedef std::map<PolicyDomain, Observers*> ObserverMap; | 48 typedef std::map<PolicyDomain, Observers*> ObserverMap; |
53 | 49 |
54 // ConfigurationPolicyProvider::Observer overrides: | 50 // ConfigurationPolicyProvider::Observer overrides: |
55 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; | 51 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; |
56 | 52 |
(...skipping 13 matching lines...) Expand all Loading... |
70 | 66 |
71 // Invokes all the refresh callbacks if there are no more refreshes pending. | 67 // Invokes all the refresh callbacks if there are no more refreshes pending. |
72 void CheckRefreshComplete(); | 68 void CheckRefreshComplete(); |
73 | 69 |
74 // The providers passed in the constructor, in order of decreasing priority. | 70 // The providers passed in the constructor, in order of decreasing priority. |
75 Providers providers_; | 71 Providers providers_; |
76 | 72 |
77 // Maps each policy namespace to its current policies. | 73 // Maps each policy namespace to its current policies. |
78 PolicyBundle policy_bundle_; | 74 PolicyBundle policy_bundle_; |
79 | 75 |
80 // Maps each policy domain to its current descriptor. | |
81 scoped_refptr<const PolicyDomainDescriptor> | |
82 domain_descriptors_[POLICY_DOMAIN_SIZE]; | |
83 | |
84 // Maps each policy domain to its observer list. | 76 // Maps each policy domain to its observer list. |
85 ObserverMap observers_; | 77 ObserverMap observers_; |
86 | 78 |
87 // True if all the providers are initialized for the indexed policy domain. | 79 // True if all the providers are initialized for the indexed policy domain. |
88 bool initialization_complete_[POLICY_DOMAIN_SIZE]; | 80 bool initialization_complete_[POLICY_DOMAIN_SIZE]; |
89 | 81 |
90 // Set of providers that have a pending update that was triggered by a | 82 // Set of providers that have a pending update that was triggered by a |
91 // call to RefreshPolicies(). | 83 // call to RefreshPolicies(). |
92 std::set<ConfigurationPolicyProvider*> refresh_pending_; | 84 std::set<ConfigurationPolicyProvider*> refresh_pending_; |
93 | 85 |
94 // List of callbacks to invoke once all providers refresh after a | 86 // List of callbacks to invoke once all providers refresh after a |
95 // RefreshPolicies() call. | 87 // RefreshPolicies() call. |
96 std::vector<base::Closure> refresh_callbacks_; | 88 std::vector<base::Closure> refresh_callbacks_; |
97 | 89 |
98 // Used to create tasks to delay new policy updates while we may be already | 90 // Used to create tasks to delay new policy updates while we may be already |
99 // processing previous policy updates. | 91 // processing previous policy updates. |
100 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; | 92 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; |
101 | 93 |
102 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); | 94 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); |
103 }; | 95 }; |
104 | 96 |
105 } // namespace policy | 97 } // namespace policy |
106 | 98 |
107 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ | 99 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_IMPL_H_ |
OLD | NEW |