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

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

Issue 10448118: Add the AsyncPolicyProvider and AsyncPolicyLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments 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 | Annotate | Revision Log
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_ASYNC_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_
7 #pragma once
8
9 #include "base/cancelable_callback.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 AsyncPolicyLoader;
18 class PolicyBundle;
19
20 // A policy provider that loads its policies asynchronously on the FILE thread.
21 // Platform-specific providers are created by passing an implementation of
22 // AsyncPolicyLoader to a new AsyncPolicyProvider.
23 class AsyncPolicyProvider : public ConfigurationPolicyProvider,
24 public base::NonThreadSafe {
25 public:
26 // Takes ownership of |loader|.
Mattias Nissler (ping if slow) 2012/06/04 15:25:39 no need for the ownership comment.
Joao da Silva 2012/06/04 17:28:12 Done.
27 AsyncPolicyProvider(const PolicyDefinitionList* policy_list,
28 scoped_ptr<AsyncPolicyLoader> loader);
29 virtual ~AsyncPolicyProvider();
30
31 // ConfigurationPolicyProvider implementation.
32 virtual void RefreshPolicies() OVERRIDE;
33
34 private:
35 // Resumes initialization once the loops are spinning.
36 void InitWithLoopsReady();
37
38 // Helper for RefreshPolicies().
39 void ReloadAfterRefreshSync();
40
41 // Invoked with the latest bundle loaded by the |loader_|.
42 void OnLoaderReloaded(scoped_ptr<PolicyBundle> bundle);
43
44 // The |loader_| that does the platform-specific policy loading. It lives
45 // on the FILE thread, and always outlives |this|.
46 AsyncPolicyLoader* loader_;
47
48 // Used to get a WeakPtr to |this| for the update callback given to the
49 // loader.
50 base::WeakPtrFactory<AsyncPolicyProvider> weak_factory_;
51
52 // Callback used to synchronize RefreshPolicies() calls with the FILE thread.
53 // See the implementation for the details.
54 base::CancelableClosure refresh_callback_;
55
Mattias Nissler (ping if slow) 2012/06/04 15:25:39 excess blank line
Joao da Silva 2012/06/04 17:28:12 Done.
56
57 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProvider);
58 };
59
60 } // namespace policy
61
62 #endif // CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698