summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/asynchronous_policy_loader.h
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 09:34:35 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 09:34:35 +0000
commit88616f47602e8a2a16c65ca0a59444e0ce550772 (patch)
tree285cad010b0aee7f2001fe419191cd1ee41a00ee /chrome/browser/policy/asynchronous_policy_loader.h
parent5e0750503a3c9743e1245f1b4c540124a9722ea0 (diff)
downloadchromium_src-88616f47602e8a2a16c65ca0a59444e0ce550772.zip
chromium_src-88616f47602e8a2a16c65ca0a59444e0ce550772.tar.gz
chromium_src-88616f47602e8a2a16c65ca0a59444e0ce550772.tar.bz2
Refactor the windows policy provider to use AsynchronousPolicyProvider.
BUG=66453,65094 TEST=*Policy.* Review URL: http://codereview.chromium.org/6091002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/asynchronous_policy_loader.h')
-rw-r--r--chrome/browser/policy/asynchronous_policy_loader.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/chrome/browser/policy/asynchronous_policy_loader.h b/chrome/browser/policy/asynchronous_policy_loader.h
index d88cdff..8a5838f 100644
--- a/chrome/browser/policy/asynchronous_policy_loader.h
+++ b/chrome/browser/policy/asynchronous_policy_loader.h
@@ -21,7 +21,8 @@ class AsynchronousPolicyLoader
: public base::RefCountedThreadSafe<AsynchronousPolicyLoader> {
public:
explicit AsynchronousPolicyLoader(
- AsynchronousPolicyProvider::Delegate* delegate);
+ AsynchronousPolicyProvider::Delegate* delegate,
+ int reload_interval_minutes);
// Triggers initial policy load.
virtual void Init();
@@ -55,13 +56,32 @@ class AsynchronousPolicyLoader
return delegate_.get();
}
- AsynchronousPolicyProvider* provider() {
- return provider_;
- }
+ // Performs start operations that must be performed on the file thread.
+ virtual void InitOnFileThread();
+
+ // Performs stop operations that must be performed on the file thread.
+ virtual void StopOnFileThread();
+
+ // Schedules a reload task to run when |delay| expires. Must be called on the
+ // file thread.
+ void ScheduleReloadTask(const base::TimeDelta& delay);
+
+ // Schedules a reload task to run after the number of minutes specified
+ // in |reload_interval_minutes_|. Must be called on the file thread.
+ void ScheduleFallbackReloadTask();
+
+ void CancelReloadTask();
+
+ // Invoked from the reload task on the file thread.
+ void ReloadFromTask();
private:
friend class AsynchronousPolicyLoaderTest;
+ // Finishes loader initialization after the threading system has been fully
+ // intialized.
+ void InitAfterFileThreadAvailable();
+
// Replaces the existing policy to value map with a new one, sending
// notification to the provider if there is a policy change. Must be called on
// |origin_loop_| so that it's safe to call back into the provider, which is
@@ -78,11 +98,21 @@ class AsynchronousPolicyLoader
// called the constructor. See |origin_loop_| below.
AsynchronousPolicyProvider* provider_;
+ // The reload task. Access only on the file thread. Holds a reference to the
+ // currently posted task, so we can cancel and repost it if necessary.
+ CancelableTask* reload_task_;
+
+ // The interval at which a policy reload will be triggered as a fallback.
+ const base::TimeDelta reload_interval_;
+
// The message loop on which this object was constructed. Recorded so that
// it's possible to call back into the non thread safe provider to fire the
// notification.
MessageLoop* origin_loop_;
+ // True if Stop has been called.
+ bool stopped_;
+
DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader);
};