OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/ref_counted.h" |
| 10 #include "base/weak_ptr.h" |
| 11 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 12 |
| 13 namespace policy { |
| 14 |
| 15 class AsynchronousPolicyLoader; |
| 16 |
| 17 // Policy provider that loads policy asynchronously. Providers should subclass |
| 18 // from this class if loading the policy requires disk access or must for some |
| 19 // other reason be performed on the file thread. The actual logic for loading |
| 20 // policy is handled by a delegate passed at construction time. |
| 21 class AsynchronousPolicyProvider |
| 22 : public ConfigurationPolicyProvider, |
| 23 public base::SupportsWeakPtr<AsynchronousPolicyProvider> { |
| 24 public: |
| 25 // Must be implemented by subclasses of the asynchronous policy provider to |
| 26 // provide the implementation details of how policy is loaded. |
| 27 class Delegate { |
| 28 public: |
| 29 virtual ~Delegate() {} |
| 30 |
| 31 virtual DictionaryValue* Load() = 0; |
| 32 }; |
| 33 |
| 34 // Assumes ownership of |loader|. |
| 35 AsynchronousPolicyProvider( |
| 36 const PolicyDefinitionList* policy_list, |
| 37 scoped_refptr<AsynchronousPolicyLoader> loader); |
| 38 virtual ~AsynchronousPolicyProvider(); |
| 39 |
| 40 // ConfigurationPolicyProvider implementation. |
| 41 virtual bool Provide(ConfigurationPolicyStoreInterface* store); |
| 42 |
| 43 // For tests to trigger reloads. |
| 44 scoped_refptr<AsynchronousPolicyLoader> loader(); |
| 45 |
| 46 protected: |
| 47 // The loader object used internally. |
| 48 scoped_refptr<AsynchronousPolicyLoader> loader_; |
| 49 |
| 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); |
| 52 }; |
| 53 |
| 54 } // namespace policy |
| 55 |
| 56 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
OLD | NEW |