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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
10 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
11 #include "chrome/browser/policy/configuration_policy_provider.h" 12 #include "chrome/browser/policy/configuration_policy_provider.h"
12 13
13 namespace policy { 14 namespace policy {
14 15
15 class AsynchronousPolicyLoader; 16 class AsynchronousPolicyLoader;
16 17
17 // Policy provider that loads policy asynchronously. Providers should subclass 18 // 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 // 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 // other reason be performed on the file thread. The actual logic for loading
(...skipping 10 matching lines...) Expand all
30 31
31 virtual DictionaryValue* Load() = 0; 32 virtual DictionaryValue* Load() = 0;
32 }; 33 };
33 34
34 // Assumes ownership of |loader|. 35 // Assumes ownership of |loader|.
35 AsynchronousPolicyProvider( 36 AsynchronousPolicyProvider(
36 const PolicyDefinitionList* policy_list, 37 const PolicyDefinitionList* policy_list,
37 scoped_refptr<AsynchronousPolicyLoader> loader); 38 scoped_refptr<AsynchronousPolicyLoader> loader);
38 virtual ~AsynchronousPolicyProvider(); 39 virtual ~AsynchronousPolicyProvider();
39 40
40 // Force a policy reload from the underlying data source.
41 void ForceReload();
42
43 protected:
44 // ConfigurationPolicyProvider implementation. 41 // ConfigurationPolicyProvider implementation.
45 virtual bool ProvideInternal(PolicyMap* map) OVERRIDE; 42 virtual bool ProvideInternal(PolicyMap* map) OVERRIDE;
43 virtual void RefreshPolicies() OVERRIDE;
44
45 private:
46 // Used to trigger a Reload on |loader| on the FILE thread.
47 static void PostReloadOnFileThread(AsynchronousPolicyLoader* loader);
48
49 // Used to notify UI that a reload task has been submitted.
50 void OnReloadPosted();
51
52 // Callback from the loader. This is invoked whenever the loader has completed
53 // a reload of the policies.
54 void OnLoaderReloaded();
46 55
47 // The loader object used internally. 56 // The loader object used internally.
48 scoped_refptr<AsynchronousPolicyLoader> loader_; 57 scoped_refptr<AsynchronousPolicyLoader> loader_;
49 58
50 private: 59 // Number of refreshes requested whose reload is still pending. Used to only
60 // fire notifications when all pending refreshes are done.
61 int pending_refreshes_;
62
63 // Used to post tasks to self on UI.
64 base::WeakPtrFactory<AsynchronousPolicyProvider> weak_ptr_factory_;
65
51 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); 66 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider);
52 }; 67 };
53 68
54 } // namespace policy 69 } // namespace policy
55 70
56 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_PROVIDER_H_ 71 #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