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

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

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/cancelable_callback.h" 9 #include "base/cancelable_callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/policy/cloud_policy_client.h" 12 #include "chrome/browser/policy/cloud_policy_client.h"
13 #include "chrome/browser/policy/cloud_policy_store.h" 13 #include "chrome/browser/policy/cloud_policy_store.h"
14 #include "net/base/network_change_notifier.h" 14 #include "net/base/network_change_notifier.h"
15 15
16 namespace base { 16 namespace base {
17 class TaskRunner; 17 class TaskRunner;
18 } 18 }
19 19
20 namespace policy { 20 namespace policy {
21 21
22 // Observes CloudPolicyClient and CloudPolicyStore to trigger periodic policy 22 // Observes CloudPolicyClient and CloudPolicyStore to trigger periodic policy
23 // fetches and issue retries on error conditions. 23 // fetches and issue retries on error conditions.
24 class CloudPolicyRefreshScheduler 24 class CloudPolicyRefreshScheduler
25 : public CloudPolicyClient::Observer, 25 : public CloudPolicyClient::Observer,
26 public CloudPolicyStore::Observer, 26 public CloudPolicyStore::Observer,
27 public net::NetworkChangeNotifier::IPAddressObserver { 27 public net::NetworkChangeNotifier::NetworkChangeObserver {
28 public: 28 public:
29 // Refresh constants. 29 // Refresh constants.
30 static const int64 kDefaultRefreshDelayMs; 30 static const int64 kDefaultRefreshDelayMs;
31 static const int64 kUnmanagedRefreshDelayMs; 31 static const int64 kUnmanagedRefreshDelayMs;
32 static const int64 kInitialErrorRetryDelayMs; 32 static const int64 kInitialErrorRetryDelayMs;
33 33
34 // Refresh delay bounds. 34 // Refresh delay bounds.
35 static const int64 kRefreshDelayMinMs; 35 static const int64 kRefreshDelayMinMs;
36 static const int64 kRefreshDelayMaxMs; 36 static const int64 kRefreshDelayMaxMs;
37 37
(...skipping 13 matching lines...) Expand all
51 51
52 // CloudPolicyClient::Observer: 52 // CloudPolicyClient::Observer:
53 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; 53 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
54 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; 54 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
55 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; 55 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
56 56
57 // CloudPolicyStore::Observer: 57 // CloudPolicyStore::Observer:
58 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 58 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
59 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 59 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
60 60
61 // net::NetworkChangeNotifier::IPAddressObserver: 61 // net::NetworkChangeNotifier::NetworkChangeObserver:
62 virtual void OnIPAddressChanged() OVERRIDE; 62 virtual void OnNetworkChanged(
63 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
63 64
64 private: 65 private:
65 // Initializes |last_refresh_| to the policy timestamp from |store_| in case 66 // Initializes |last_refresh_| to the policy timestamp from |store_| in case
66 // there is policy present that indicates this client is not managed. This 67 // there is policy present that indicates this client is not managed. This
67 // results in policy fetches only to occur after the entire unmanaged refresh 68 // results in policy fetches only to occur after the entire unmanaged refresh
68 // delay expires, even over restarts. For managed clients, we want to trigger 69 // delay expires, even over restarts. For managed clients, we want to trigger
69 // a refresh on every restart. 70 // a refresh on every restart.
70 void UpdateLastRefreshFromPolicy(); 71 void UpdateLastRefreshFromPolicy();
71 72
72 // Evaluates when the next refresh is pending and updates the callback to 73 // Evaluates when the next refresh is pending and updates the callback to
(...skipping 24 matching lines...) Expand all
97 98
98 // The refresh delay. 99 // The refresh delay.
99 int64 refresh_delay_ms_; 100 int64 refresh_delay_ms_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(CloudPolicyRefreshScheduler); 102 DISALLOW_COPY_AND_ASSIGN(CloudPolicyRefreshScheduler);
102 }; 103 };
103 104
104 } // namespace policy 105 } // namespace policy
105 106
106 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_ 107 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_REFRESH_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698