| 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_ASYNCHRONOUS_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "chrome/browser/policy/configuration_policy_provider.h" | 13 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 14 | 14 |
| 15 namespace policy { | 15 namespace policy { |
| 16 | 16 |
| 17 class AsynchronousPolicyLoader; | 17 class AsynchronousPolicyLoader; |
| 18 class PolicyBundle; | 18 class PolicyBundle; |
| 19 class PolicyMap; | |
| 20 | 19 |
| 21 // Policy provider that loads policy asynchronously. Providers should subclass | 20 // Policy provider that loads policy asynchronously. Providers should subclass |
| 22 // from this class if loading the policy requires disk access or must for some | 21 // from this class if loading the policy requires disk access or must for some |
| 23 // other reason be performed on the file thread. The actual logic for loading | 22 // other reason be performed on the file thread. The actual logic for loading |
| 24 // policy is handled by a delegate passed at construction time. | 23 // policy is handled by a delegate passed at construction time. |
| 25 class AsynchronousPolicyProvider | 24 class AsynchronousPolicyProvider |
| 26 : public ConfigurationPolicyProvider, | 25 : public ConfigurationPolicyProvider, |
| 27 public base::NonThreadSafe { | 26 public base::NonThreadSafe { |
| 28 public: | 27 public: |
| 29 // Must be implemented by subclasses of the asynchronous policy provider to | 28 // Must be implemented by subclasses of the asynchronous policy provider to |
| 30 // provide the implementation details of how policy is loaded. | 29 // provide the implementation details of how policy is loaded. |
| 31 class Delegate { | 30 class Delegate { |
| 32 public: | 31 public: |
| 33 virtual ~Delegate() {} | 32 virtual ~Delegate() {} |
| 34 | 33 |
| 35 // Load policy from the delegate's source, and return a PolicyMap. Ownership | 34 // Load policy from the delegate's source, and return a PolicyBundle. |
| 36 // is transferred to the caller. | 35 virtual scoped_ptr<PolicyBundle> Load() = 0; |
| 37 virtual PolicyMap* Load() = 0; | |
| 38 }; | 36 }; |
| 39 | 37 |
| 40 // Assumes ownership of |loader|. | 38 // Assumes ownership of |loader|. |
| 41 AsynchronousPolicyProvider( | 39 AsynchronousPolicyProvider( |
| 42 const PolicyDefinitionList* policy_list, | 40 const PolicyDefinitionList* policy_list, |
| 43 scoped_refptr<AsynchronousPolicyLoader> loader); | 41 scoped_refptr<AsynchronousPolicyLoader> loader); |
| 44 virtual ~AsynchronousPolicyProvider(); | 42 virtual ~AsynchronousPolicyProvider(); |
| 45 | 43 |
| 46 // ConfigurationPolicyProvider implementation. | 44 // ConfigurationPolicyProvider implementation. |
| 47 virtual void RefreshPolicies() OVERRIDE; | 45 virtual void RefreshPolicies() OVERRIDE; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 | 64 |
| 67 // Used to post tasks to self on UI. | 65 // Used to post tasks to self on UI. |
| 68 base::WeakPtrFactory<AsynchronousPolicyProvider> weak_ptr_factory_; | 66 base::WeakPtrFactory<AsynchronousPolicyProvider> weak_ptr_factory_; |
| 69 | 67 |
| 70 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); | 68 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); |
| 71 }; | 69 }; |
| 72 | 70 |
| 73 } // namespace policy | 71 } // namespace policy |
| 74 | 72 |
| 75 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ | 73 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| OLD | NEW |