Chromium Code Reviews

Side by Side Diff: chrome/browser/policy/asynchronous_policy_provider.h

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with TOT Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
(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/non_thread_safe.h"
10 #include "base/ref_counted.h"
11 #include "base/weak_ptr.h"
12 #include "chrome/browser/policy/configuration_policy_provider.h"
13
14 namespace policy {
15
16 class AsynchronousPolicyLoader;
17
18 // Policy provider that loads policy asynchronously. Providers should subclass
19 // from this class if loading the policy requires disk access or must for some
20 // other reason be performed on the file thread. The actual logic for loading
21 // policy is handled by a delegate passed at construction time.
22 class AsynchronousPolicyProvider
23 : public ConfigurationPolicyProvider,
24 public base::SupportsWeakPtr<AsynchronousPolicyProvider>,
25 public NonThreadSafe {
26 public:
27 // Must be implemented by subclasses of the asynchronous policy provider to
28 // provide the implementation details of how policy is loaded.
29 class Delegate {
30 public:
31 virtual ~Delegate() {}
32
33 virtual DictionaryValue* Load() = 0;
34 };
35
36 // Assumes ownership of |loader|.
37 AsynchronousPolicyProvider(
38 const PolicyDefinitionList* policy_list,
39 scoped_refptr<AsynchronousPolicyLoader> loader);
40 virtual ~AsynchronousPolicyProvider();
41
42 // ConfigurationPolicyProvider implementation.
43 virtual bool Provide(ConfigurationPolicyStoreInterface* store);
44
45 // For tests to trigger reloads.
46 scoped_refptr<AsynchronousPolicyLoader> loader();
47
48 protected:
49 // The loader object used internally.
50 scoped_refptr<AsynchronousPolicyLoader> loader_;
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider);
54 };
55
56 } // namespace policy
57
58 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/asynchronous_policy_loader_unittest.cc ('k') | chrome/browser/policy/asynchronous_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine