OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CLOUD_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "chrome/browser/policy/configuration_policy_provider.h" | 10 #include "chrome/browser/policy/configuration_policy_provider.h" |
11 | 11 |
12 namespace policy { | 12 namespace policy { |
13 | 13 |
14 class CloudPolicyCacheBase; | 14 class CloudPolicyCacheBase; |
15 | 15 |
16 // A policy provider having multiple backend caches, combining their relevant | 16 // A policy provider having multiple backend caches, combining their relevant |
17 // PolicyMaps and keeping the result cached. The underlying caches are kept as | 17 // PolicyMaps and keeping the result cached. The underlying caches are kept as |
18 // weak references and can be added dynamically. Also the | 18 // weak references and can be added dynamically. Also the |
19 // |CloudPolicyProvider| instance listens to cache-notifications and removes | 19 // |CloudPolicyProvider| instance listens to cache-notifications and removes |
20 // the caches automatically when they go away. The order in which the caches are | 20 // the caches automatically when they go away. The order in which the caches are |
21 // stored matters! The first cache is applied as is and the following caches | 21 // stored matters! The first cache is applied as is and the following caches |
22 // only contribute the not-yet applied policies. There are two functions to add | 22 // only contribute the not-yet applied policies. There are two functions to add |
23 // a new cache: | 23 // a new cache: |
24 // PrependCache(cache): adds |cache| to the front (i.e. most important cache). | 24 // PrependCache(cache): adds |cache| to the front (i.e. most important cache). |
25 // AppendCache(cache): adds |cache| to the back (i.e. least important cache). | 25 // AppendCache(cache): adds |cache| to the back (i.e. least important cache). |
26 class CloudPolicyProvider : public ConfigurationPolicyProvider { | 26 class CloudPolicyProvider : public ConfigurationPolicyProvider { |
27 public: | 27 public: |
28 explicit CloudPolicyProvider( | 28 explicit CloudPolicyProvider(const PolicyDefinitionList* policy_list); |
29 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); | |
30 virtual ~CloudPolicyProvider(); | 29 virtual ~CloudPolicyProvider(); |
31 | 30 |
32 // Adds a new instance of CloudPolicyCacheBase to the end of |caches_|. | 31 // Adds a new instance of CloudPolicyCacheBase to the end of |caches_|. |
33 // Does not take ownership of |cache| and listens to OnCacheGoingAway to | 32 // Does not take ownership of |cache| and listens to OnCacheGoingAway to |
34 // automatically remove it from |caches_|. | 33 // automatically remove it from |caches_|. |
35 virtual void AppendCache(CloudPolicyCacheBase* cache) = 0; | 34 virtual void AppendCache(CloudPolicyCacheBase* cache) = 0; |
36 | 35 |
37 // Adds a new instance of CloudPolicyCacheBase to the beginning of |caches_|. | 36 // Adds a new instance of CloudPolicyCacheBase to the beginning of |caches_|. |
38 // Does not take ownership of |cache| and listens to OnCacheGoingAway to | 37 // Does not take ownership of |cache| and listens to OnCacheGoingAway to |
39 // automatically remove it from |caches_|. | 38 // automatically remove it from |caches_|. |
40 virtual void PrependCache(CloudPolicyCacheBase* cache) = 0; | 39 virtual void PrependCache(CloudPolicyCacheBase* cache) = 0; |
41 | 40 |
42 private: | 41 private: |
43 DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider); | 42 DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider); |
44 }; | 43 }; |
45 | 44 |
46 } // namespace policy | 45 } // namespace policy |
47 | 46 |
48 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ | 47 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_ |
OLD | NEW |