Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

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

Issue 10500013: Delete old policy code after AsyncPolicyLoader refactor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
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/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "chrome/browser/policy/configuration_policy_provider.h"
14
15 namespace policy {
16
17 class AsynchronousPolicyLoader;
18 class PolicyBundle;
19
20 // Policy provider that loads policy asynchronously. Providers should subclass
21 // from this class if loading the policy requires disk access or must for some
22 // other reason be performed on the file thread. The actual logic for loading
23 // policy is handled by a delegate passed at construction time.
24 class AsynchronousPolicyProvider
25 : public ConfigurationPolicyProvider,
26 public base::NonThreadSafe {
27 public:
28 // Must be implemented by subclasses of the asynchronous policy provider to
29 // provide the implementation details of how policy is loaded.
30 class Delegate {
31 public:
32 virtual ~Delegate() {}
33
34 // Load policy from the delegate's source, and return a PolicyBundle.
35 virtual scoped_ptr<PolicyBundle> Load() = 0;
36 };
37
38 // Assumes ownership of |loader|.
39 AsynchronousPolicyProvider(
40 const PolicyDefinitionList* policy_list,
41 scoped_refptr<AsynchronousPolicyLoader> loader);
42 virtual ~AsynchronousPolicyProvider();
43
44 // ConfigurationPolicyProvider implementation.
45 virtual void RefreshPolicies() OVERRIDE;
46
47 private:
48 // Used to trigger a Reload on |loader| on the FILE thread.
49 static void PostReloadOnFileThread(AsynchronousPolicyLoader* loader);
50
51 // Used to notify UI that a reload task has been submitted.
52 void OnReloadPosted();
53
54 // Callback from the loader. This is invoked whenever the loader has completed
55 // a reload of the policies.
56 void OnLoaderReloaded(scoped_ptr<PolicyBundle> bundle);
57
58 // The loader object used internally.
59 scoped_refptr<AsynchronousPolicyLoader> loader_;
60
61 // Number of refreshes requested whose reload is still pending. Used to only
62 // fire notifications when all pending refreshes are done.
63 int pending_refreshes_;
64
65 // Used to post tasks to self on UI.
66 base::WeakPtrFactory<AsynchronousPolicyProvider> weak_ptr_factory_;
67
68 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider);
69 };
70
71 } // namespace policy
72
73 #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
This is Rietveld 408576698