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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 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 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 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" 5 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/task_runner.h" 9 #include "base/task_runner.h"
10 #include "chrome/browser/policy/cloud_policy_constants.h" 10 #include "chrome/browser/policy/cloud_policy_constants.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ScheduleRefresh(); 92 ScheduleRefresh();
93 } 93 }
94 94
95 void CloudPolicyRefreshScheduler::OnStoreError(CloudPolicyStore* store) { 95 void CloudPolicyRefreshScheduler::OnStoreError(CloudPolicyStore* store) {
96 // If |store_| fails, the is_managed bit that it provides may become stale. 96 // If |store_| fails, the is_managed bit that it provides may become stale.
97 // The best guess in that situation is to assume is_managed didn't change and 97 // The best guess in that situation is to assume is_managed didn't change and
98 // continue using the stale information. Thus, no specific response to a store 98 // continue using the stale information. Thus, no specific response to a store
99 // error is required. NB: Changes to is_managed fire OnStoreLoaded(). 99 // error is required. NB: Changes to is_managed fire OnStoreLoaded().
100 } 100 }
101 101
102 void CloudPolicyRefreshScheduler::Observe( 102 void CloudPolicyRefreshScheduler::OnPreferenceChanged(
103 int type, 103 PrefServiceBase* service,
104 const content::NotificationSource& source, 104 const std::string& pref_name) {
105 const content::NotificationDetails& details) { 105 DCHECK_EQ(refresh_delay_.GetPrefName(), pref_name);
106 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type);
107 DCHECK_EQ(refresh_delay_.GetPrefName(),
108 *content::Details<std::string>(details).ptr());
109 106
110 ScheduleRefresh(); 107 ScheduleRefresh();
111 } 108 }
112 109
113 void CloudPolicyRefreshScheduler::OnIPAddressChanged() { 110 void CloudPolicyRefreshScheduler::OnIPAddressChanged() {
114 if (client_->status() == DM_STATUS_REQUEST_FAILED) 111 if (client_->status() == DM_STATUS_REQUEST_FAILED)
115 RefreshAfter(0); 112 RefreshAfter(0);
116 } 113 }
117 114
118 void CloudPolicyRefreshScheduler::UpdateLastRefreshFromPolicy() { 115 void CloudPolicyRefreshScheduler::UpdateLastRefreshFromPolicy() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 task_runner_->PostDelayedTask(FROM_HERE, refresh_callback_.callback(), delay); 207 task_runner_->PostDelayedTask(FROM_HERE, refresh_callback_.callback(), delay);
211 } 208 }
212 209
213 int64 CloudPolicyRefreshScheduler::GetRefreshDelay() { 210 int64 CloudPolicyRefreshScheduler::GetRefreshDelay() {
214 return std::min(std::max<int64>(refresh_delay_.GetValue(), 211 return std::min(std::max<int64>(refresh_delay_.GetValue(),
215 kRefreshDelayMinMs), 212 kRefreshDelayMinMs),
216 kRefreshDelayMaxMs); 213 kRefreshDelayMaxMs);
217 } 214 }
218 215
219 } // namespace policy 216 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_refresh_scheduler.h ('k') | chrome/browser/policy/cloud_policy_subsystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698