OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_CLOUD_POLICY_REFRESH_SCHEDULER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
bartfab (slow)
2012/12/04 12:25:18
Nit: No longer needed.
Mattias Nissler (ping if slow)
2012/12/04 13:20:40
Done.
| |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/api/prefs/pref_member.h" | |
15 #include "chrome/browser/policy/cloud_policy_client.h" | 14 #include "chrome/browser/policy/cloud_policy_client.h" |
16 #include "chrome/browser/policy/cloud_policy_store.h" | 15 #include "chrome/browser/policy/cloud_policy_store.h" |
17 #include "net/base/network_change_notifier.h" | 16 #include "net/base/network_change_notifier.h" |
18 | 17 |
19 class PrefService; | 18 class PrefService; |
bartfab (slow)
2012/12/04 12:25:18
Nit: No longer needed.
Mattias Nissler (ping if slow)
2012/12/04 13:20:40
Done.
| |
20 | 19 |
21 namespace base { | 20 namespace base { |
22 class TaskRunner; | 21 class TaskRunner; |
23 } | 22 } |
24 | 23 |
25 namespace policy { | 24 namespace policy { |
26 | 25 |
27 // Observes CloudPolicyClient and CloudPolicyStore to trigger periodic policy | 26 // Observes CloudPolicyClient and CloudPolicyStore to trigger periodic policy |
28 // fetches and issue retries on error conditions. | 27 // fetches and issue retries on error conditions. |
29 class CloudPolicyRefreshScheduler | 28 class CloudPolicyRefreshScheduler |
30 : public CloudPolicyClient::Observer, | 29 : public CloudPolicyClient::Observer, |
31 public CloudPolicyStore::Observer, | 30 public CloudPolicyStore::Observer, |
32 public net::NetworkChangeNotifier::IPAddressObserver { | 31 public net::NetworkChangeNotifier::IPAddressObserver { |
33 public: | 32 public: |
34 // Refresh constants. | 33 // Refresh constants. |
34 static const int64 kDefaultRefreshDelayMs; | |
35 static const int64 kUnmanagedRefreshDelayMs; | 35 static const int64 kUnmanagedRefreshDelayMs; |
36 static const int64 kInitialErrorRetryDelayMs; | 36 static const int64 kInitialErrorRetryDelayMs; |
37 | 37 |
38 // Refresh delay bounds. | 38 // Refresh delay bounds. |
39 static const int64 kRefreshDelayMinMs; | 39 static const int64 kRefreshDelayMinMs; |
40 static const int64 kRefreshDelayMaxMs; | 40 static const int64 kRefreshDelayMaxMs; |
41 | 41 |
42 // |client|, |store| and |prefs| pointers must stay valid throughout the | 42 // |client|, |store| and |prefs| pointers must stay valid throughout the |
43 // lifetime of CloudPolicyRefreshScheduler. | 43 // lifetime of CloudPolicyRefreshScheduler. |
44 CloudPolicyRefreshScheduler( | 44 CloudPolicyRefreshScheduler( |
45 CloudPolicyClient* client, | 45 CloudPolicyClient* client, |
46 CloudPolicyStore* store, | 46 CloudPolicyStore* store, |
47 PrefService* prefs, | |
48 const std::string& refresh_pref, | |
49 const scoped_refptr<base::TaskRunner>& task_runner); | 47 const scoped_refptr<base::TaskRunner>& task_runner); |
50 virtual ~CloudPolicyRefreshScheduler(); | 48 virtual ~CloudPolicyRefreshScheduler(); |
51 | 49 |
50 // Sets the refresh delay to |refresh_delay| (subject to min/max clamping). | |
51 void SetRefreshDelay(int64 refresh_delay); | |
52 | |
52 // CloudPolicyClient::Observer: | 53 // CloudPolicyClient::Observer: |
53 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; | 54 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
54 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; | 55 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
55 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; | 56 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
56 | 57 |
57 // CloudPolicyStore::Observer: | 58 // CloudPolicyStore::Observer: |
58 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; | 59 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
59 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; | 60 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
60 | 61 |
61 // net::NetworkChangeNotifier::IPAddressObserver: | 62 // net::NetworkChangeNotifier::IPAddressObserver: |
(...skipping 29 matching lines...) Expand all Loading... | |
91 | 92 |
92 // The delayed refresh callback. | 93 // The delayed refresh callback. |
93 base::CancelableClosure refresh_callback_; | 94 base::CancelableClosure refresh_callback_; |
94 | 95 |
95 // The last time a refresh callback completed. | 96 // The last time a refresh callback completed. |
96 base::Time last_refresh_; | 97 base::Time last_refresh_; |
97 | 98 |
98 // Error retry delay in milliseconds. | 99 // Error retry delay in milliseconds. |
99 int64 error_retry_delay_ms_; | 100 int64 error_retry_delay_ms_; |
100 | 101 |
101 IntegerPrefMember refresh_delay_; | 102 // The refresh delay. |
103 int64 refresh_delay_ms_; | |
102 | 104 |
103 DISALLOW_COPY_AND_ASSIGN(CloudPolicyRefreshScheduler); | 105 DISALLOW_COPY_AND_ASSIGN(CloudPolicyRefreshScheduler); |
104 }; | 106 }; |
105 | 107 |
106 } // namespace policy | 108 } // namespace policy |
107 | 109 |
108 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ | 110 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ |
OLD | NEW |