Chromium Code Reviews| Index: chrome/browser/policy/asynchronous_policy_provider.h |
| diff --git a/chrome/browser/policy/asynchronous_policy_provider.h b/chrome/browser/policy/asynchronous_policy_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c2c9e55c2dee41b0d77bdfa5c9adee878f4716e8 |
| --- /dev/null |
| +++ b/chrome/browser/policy/asynchronous_policy_provider.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| +#define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |
| +#pragma once |
| + |
| +#include "base/ref_counted.h" |
| +#include "base/time.h" |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
do you need this header?
danno
2010/12/06 14:05:12
Done.
|
| +#include "base/weak_ptr.h" |
| +#include "chrome/browser/policy/configuration_policy_provider.h" |
| + |
| +class CancelableTask; |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
not needed?
danno
2010/12/06 14:05:12
Done.
|
| +class MessageLoop; |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
not needed?
danno
2010/12/06 14:05:12
Done.
|
| + |
| +namespace policy { |
| + |
| +class AsynchronousPolicyLoader; |
| + |
| +// Policy provider that loads policy asynchronously. Providers should subclass |
| +// from this class if loading the policy requires disk access or must for some |
| +// other reason be performed on the file thread. The actual logic for loading |
| +// policy is handled by a delegate passed at construction time. |
| +class AsynchronousPolicyProvider |
| + : public ConfigurationPolicyProvider, |
| + public base::SupportsWeakPtr<AsynchronousPolicyProvider> { |
| + public: |
| + // Must be implemented by subclasses of the asynchronous policy provider to |
| + // provide the implementation details of how policy is loaded. |
| + class Delegate { |
| + public: |
| + Delegate() {} |
| + virtual ~Delegate() {} |
| + |
| + virtual DictionaryValue* Load() = 0; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Delegate); |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
I think technically you don't need DISALLOW_COPY_A
danno
2010/12/06 14:05:12
Done.
|
| + }; |
| + |
| + // Assumes ownership of |delegate|. |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
s/delegate/loader/
danno
2010/12/06 14:05:12
Done.
|
| + AsynchronousPolicyProvider( |
| + const PolicyDefinitionList* policy_list, |
| + scoped_refptr<AsynchronousPolicyLoader> loader); |
| + virtual ~AsynchronousPolicyProvider(); |
| + |
| + // ConfigurationPolicyProvider implementation. |
| + virtual bool Provide(ConfigurationPolicyStoreInterface* store); |
| + |
| + // For tests to trigger reloads |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
missing period. If tests construct the provider th
danno
2010/12/06 14:05:12
One the AsynchronousPolicyProvider allows the load
|
| + scoped_refptr<AsynchronousPolicyLoader> loader(); |
| + |
| + protected: |
| + // The loader object used internally. |
|
Mattias Nissler (ping if slow)
2010/12/06 10:26:20
Indentation.
danno
2010/12/06 14:05:12
Done.
|
| + scoped_refptr<AsynchronousPolicyLoader> loader_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ |