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

Unified Diff: chrome/browser/policy/asynchronous_policy_loader.h

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/asynchronous_policy_loader.h
diff --git a/chrome/browser/policy/asynchronous_policy_loader.h b/chrome/browser/policy/asynchronous_policy_loader.h
index 63a81f8800968c975bd65cc75867d3f896b3d18b..ae9441f9742cfe120f4636ff36448a563d41c757 100644
--- a/chrome/browser/policy/asynchronous_policy_loader.h
+++ b/chrome/browser/policy/asynchronous_policy_loader.h
@@ -27,14 +27,15 @@ class AsynchronousPolicyLoader
AsynchronousPolicyLoader(AsynchronousPolicyProvider::Delegate* delegate,
int reload_interval_minutes);
- // Triggers initial policy load, and installs |callback| as the callback to
- // invoke on policy updates.
- virtual void Init(const base::Closure& callback);
+ // Triggers initial policy load, and installs |default_callback| as the
+ // callback to invoke on policy updates that haven't been requested.
+ virtual void Init(const base::Closure& default_callback);
- // Reloads policy, sending notification of changes if necessary. Must be
- // called on the FILE thread. When |force| is true, the loader should do an
- // immediate full reload.
- virtual void Reload(bool force);
+ // Reloads policy and invokes |callback| on |origin_loop_| when done.
+ // The loader does a full reload immediately when |force| is true.
+ // |callback| is guaranteed to be eventually invoked, even if the loading
+ // fails. This method must be called on the FILE thread.
+ virtual void Reload(const base::Closure& callback, bool force);
// Stops any pending reload tasks. Updates callbacks won't be performed
// anymore once the loader is stopped.
@@ -50,12 +51,15 @@ class AsynchronousPolicyLoader
// Schedules a call to UpdatePolicy on |origin_loop_|. Takes ownership of
// |new_policy|.
- void PostUpdatePolicyTask(DictionaryValue* new_policy);
+ void PostUpdatePolicyTask(const base::Closure& callback,
+ DictionaryValue* new_policy);
AsynchronousPolicyProvider::Delegate* delegate() {
return delegate_.get();
}
+ const base::Closure& default_callback() { return default_callback_; }
+
// Performs start operations that must be performed on the FILE thread.
virtual void InitOnFileThread();
@@ -64,7 +68,8 @@ class AsynchronousPolicyLoader
// Schedules a reload task to run when |delay| expires. Must be called on the
// FILE thread.
- void ScheduleReloadTask(const base::TimeDelta& delay);
+ void ScheduleReloadTask(const base::Closure& callback,
+ 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.
@@ -72,9 +77,6 @@ class AsynchronousPolicyLoader
void CancelReloadTask();
- // Invoked from the reload task on the FILE thread.
- void ReloadFromTask();
-
private:
friend class AsynchronousPolicyLoaderTest;
@@ -82,11 +84,11 @@ class AsynchronousPolicyLoader
// intialized.
void InitAfterFileThreadAvailable();
- // Replaces the existing policy to value map with a new one, sending
- // notification to the observers 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 not thread-safe. Takes ownership of |new_policy|.
- void UpdatePolicy(DictionaryValue* new_policy);
+ // Replaces the existing policy to value map with a new one, and invokes
+ // |callback|. Must be called on |origin_loop_| so that it's safe to callback
+ // into the provider, which is not thread-safe. Takes ownership of
+ // |new_policy|.
+ void UpdatePolicy(const base::Closure& callback, DictionaryValue* new_policy);
// Provides the low-level mechanics for loading policy.
scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_;
@@ -99,7 +101,7 @@ class AsynchronousPolicyLoader
base::WeakPtrFactory<AsynchronousPolicyLoader> weak_ptr_factory_;
// The interval at which a policy reload will be triggered as a fallback.
- const base::TimeDelta reload_interval_;
+ 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
@@ -109,8 +111,9 @@ class AsynchronousPolicyLoader
// True if Stop has been called.
bool stopped_;
- // Callback to invoke on policy updates.
- base::Closure updates_callback_;
+ // Default callback to invoke on policy updates that weren't explicitly
+ // requested by the provider.
+ base::Closure default_callback_;
DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader);
};

Powered by Google App Engine
This is Rietveld 408576698