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 17 matching lines...) Expand all Loading... |
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 | 31 |
32 // The PolicyServiceImpl will merge policies from |providers|. |providers| | 32 // The PolicyServiceImpl will merge policies from |providers|. |providers| |
33 // 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 |
34 // have the highest priority. The PolicyServiceImpl does not take ownership of | 34 // have the highest priority. The PolicyServiceImpl does not take ownership of |
35 // the providers, and they must outlive the PolicyServiceImpl. | 35 // the providers, and they must outlive the PolicyServiceImpl. |
36 explicit PolicyServiceImpl(const Providers& providers); | 36 explicit PolicyServiceImpl(const Providers& providers); |
37 | 37 |
38 virtual ~PolicyServiceImpl(); | 38 ~PolicyServiceImpl() override; |
39 | 39 |
40 // PolicyService overrides: | 40 // PolicyService overrides: |
41 virtual void AddObserver(PolicyDomain domain, | 41 void AddObserver(PolicyDomain domain, |
42 PolicyService::Observer* observer) override; | 42 PolicyService::Observer* observer) override; |
43 virtual void RemoveObserver(PolicyDomain domain, | 43 void RemoveObserver(PolicyDomain domain, |
44 PolicyService::Observer* observer) override; | 44 PolicyService::Observer* observer) override; |
45 virtual const PolicyMap& GetPolicies( | 45 const PolicyMap& GetPolicies(const PolicyNamespace& ns) const override; |
46 const PolicyNamespace& ns) const override; | 46 bool IsInitializationComplete(PolicyDomain domain) const override; |
47 virtual bool IsInitializationComplete(PolicyDomain domain) const override; | 47 void RefreshPolicies(const base::Closure& callback) override; |
48 virtual void RefreshPolicies(const base::Closure& callback) override; | |
49 | 48 |
50 private: | 49 private: |
51 typedef ObserverList<PolicyService::Observer, true> Observers; | 50 typedef ObserverList<PolicyService::Observer, true> Observers; |
52 typedef std::map<PolicyDomain, Observers*> ObserverMap; | 51 typedef std::map<PolicyDomain, Observers*> ObserverMap; |
53 | 52 |
54 // ConfigurationPolicyProvider::Observer overrides: | 53 // ConfigurationPolicyProvider::Observer overrides: |
55 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) override; | 54 void OnUpdatePolicy(ConfigurationPolicyProvider* provider) override; |
56 | 55 |
57 // Posts a task to notify observers of |ns| that its policies have changed, | 56 // Posts a task to notify observers of |ns| that its policies have changed, |
58 // passing along the |previous| and the |current| policies. | 57 // passing along the |previous| and the |current| policies. |
59 void NotifyNamespaceUpdated(const PolicyNamespace& ns, | 58 void NotifyNamespaceUpdated(const PolicyNamespace& ns, |
60 const PolicyMap& previous, | 59 const PolicyMap& previous, |
61 const PolicyMap& current); | 60 const PolicyMap& current); |
62 | 61 |
63 // Combines the policies from all the providers, and notifies the observers | 62 // Combines the policies from all the providers, and notifies the observers |
64 // of namespaces whose policies have been modified. | 63 // of namespaces whose policies have been modified. |
65 void MergeAndTriggerUpdates(); | 64 void MergeAndTriggerUpdates(); |
(...skipping 28 matching lines...) Expand all Loading... |
94 // Used to create tasks to delay new policy updates while we may be already | 93 // Used to create tasks to delay new policy updates while we may be already |
95 // processing previous policy updates. | 94 // processing previous policy updates. |
96 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; | 95 base::WeakPtrFactory<PolicyServiceImpl> update_task_ptr_factory_; |
97 | 96 |
98 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); | 97 DISALLOW_COPY_AND_ASSIGN(PolicyServiceImpl); |
99 }; | 98 }; |
100 | 99 |
101 } // namespace policy | 100 } // namespace policy |
102 | 101 |
103 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ | 102 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_IMPL_H_ |
OLD | NEW |