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

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

Issue 6079012: Allow policy refresh rate to be configured through policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build. Created 9 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/device_management_policy_provider.h
diff --git a/chrome/browser/policy/device_management_policy_provider.h b/chrome/browser/policy/device_management_policy_provider.h
index fd18bc30f858e4f521986e0c1f146fd24e0f01d2..aa7ad46ff14373907d064aba92e128799f297da5 100644
--- a/chrome/browser/policy/device_management_policy_provider.h
+++ b/chrome/browser/policy/device_management_policy_provider.h
@@ -12,7 +12,6 @@
#include "base/observer_list.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
-#include "base/weak_ptr.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
#include "chrome/browser/policy/device_management_backend.h"
#include "chrome/browser/policy/device_token_fetcher.h"
@@ -31,7 +30,6 @@ class DeviceManagementPolicyCache;
class DeviceManagementPolicyProvider
: public ConfigurationPolicyProvider,
public DeviceManagementBackend::DevicePolicyResponseDelegate,
- public base::SupportsWeakPtr<DeviceManagementPolicyProvider>,
public DeviceTokenFetcher::Observer {
public:
DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list,
@@ -54,8 +52,28 @@ class DeviceManagementPolicyProvider
virtual void OnTokenError();
virtual void OnNotManaged();
+ // Sets the refresh rate at which to re-fetch policy information.
+ void SetRefreshRate(int64 refresh_rate_milliseconds);
+
private:
- class InitializeAfterIOThreadExistsTask;
+ // Indicates the current state the provider is in.
+ enum ProviderState {
+ // The provider is initializing, policy information not yet available.
+ STATE_INITIALIZING,
+ // This device is not managed through policy.
+ STATE_UNMANAGED,
+ // The token is valid, but policy is yet to be fetched.
+ STATE_TOKEN_VALID,
+ // Policy information is available and valid.
+ STATE_POLICY_VALID,
+ // The token was found to be invalid and needs to be obtained again.
+ STATE_TOKEN_RESET,
+ // There has been an error fetching the token, retry later.
+ STATE_TOKEN_ERROR,
+ // The service returned an error when requesting policy, ask again later.
+ STATE_POLICY_ERROR,
+ };
+
class RefreshTask;
friend class DeviceManagementPolicyProviderTest;
@@ -65,7 +83,8 @@ class DeviceManagementPolicyProvider
DeviceManagementBackend* backend,
Profile* profile,
int64 policy_refresh_rate_ms,
- int64 policy_refresh_max_earlier_ms,
+ int policy_refresh_fuzz_factor_percent,
danno 2011/01/06 19:16:26 how about "deviation" or "random_deviation" instea
Mattias Nissler (ping if slow) 2011/01/07 11:15:33 Done.
+ int64 policy_refresh_fuzz_max_ms,
int64 policy_refresh_error_delay_ms,
int64 token_fetch_error_delay_ms,
int64 unmanaged_device_refresh_rate_ms);
@@ -77,15 +96,12 @@ class DeviceManagementPolicyProvider
void Initialize(DeviceManagementBackend* backend,
Profile* profile,
int64 policy_refresh_rate_ms,
- int64 policy_refresh_max_earlier_ms,
+ int policy_refresh_fuzz_factor_percent,
+ int64 policy_refresh_fuzz_max_ms,
int64 policy_refresh_error_delay_ms,
int64 token_fetch_error_delay_ms,
int64 unmanaged_device_refresh_rate_ms);
- // Called by a deferred task posted to the UI thread to complete the portion
- // of initialization that requires the IOThread.
- void InitializeAfterIOThreadExists();
-
// ConfigurationPolicyProvider overrides:
virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer);
virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer);
@@ -98,13 +114,8 @@ class DeviceManagementPolicyProvider
// as necessary.
void RefreshTaskExecute();
- // Schedules a new RefreshTask.
- void ScheduleRefreshTask(int64 delay_in_milliseconds);
-
- // Calculates when the next RefreshTask shall be executed.
- int64 GetRefreshTaskDelay();
-
- void StopWaitingForInitialPolicies();
+ // Cancels the refresh task.
+ void CancelRefreshTask();
// Notify observers about a policy update.
void NotifyCloudPolicyUpdate();
@@ -115,6 +126,15 @@ class DeviceManagementPolicyProvider
// Used only by tests.
void SetDeviceTokenFetcher(DeviceTokenFetcher* token_fetcher);
+ // Switches to a new state and triggers any appropriate actions.
+ void SetState(ProviderState new_state);
+
+ // Check whether the current state is one in which the token is available.
+ bool TokenAvailable() const;
+
+ // Computes the refresh delay to use.
+ int64 GetRefreshDelay();
+
// Provides the URL at which requests are sent to from the device management
// backend.
static std::string GetDeviceManagementURL();
@@ -131,13 +151,15 @@ class DeviceManagementPolicyProvider
DeviceTokenFetcher::ObserverRegistrar registrar_;
ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_;
FilePath storage_dir_;
- bool policy_request_pending_;
- bool refresh_task_pending_;
- bool waiting_for_initial_policies_;
+ ProviderState state_;
+ RefreshTask* refresh_task_;
int64 policy_refresh_rate_ms_;
- int64 policy_refresh_max_earlier_ms_;
+ int policy_refresh_fuzz_factor_percent_;
+ int64 policy_refresh_fuzz_max_ms_;
int64 policy_refresh_error_delay_ms_;
+ int64 effective_policy_refresh_error_delay_ms_;
int64 token_fetch_error_delay_ms_;
+ int64 effective_token_fetch_error_delay_ms_;
int64 unmanaged_device_refresh_rate_ms_;
DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider);

Powered by Google App Engine
This is Rietveld 408576698