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

Side by Side Diff: chrome/browser/profiles/gaia_info_update_service.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/profiles/gaia_info_update_service.h" 5 #include "chrome/browser/profiles/gaia_info_update_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ProfileDownloader* downloader) { 157 ProfileDownloader* downloader) {
158 profile_image_downloader_.reset(); 158 profile_image_downloader_.reset();
159 159
160 // Save the last updated time. 160 // Save the last updated time.
161 last_updated_ = base::Time::Now(); 161 last_updated_ = base::Time::Now();
162 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, 162 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime,
163 last_updated_.ToInternalValue()); 163 last_updated_.ToInternalValue());
164 ScheduleNextUpdate(); 164 ScheduleNextUpdate();
165 } 165 }
166 166
167 void GAIAInfoUpdateService::Observe( 167 void GAIAInfoUpdateService::OnPreferenceChanged(PrefServiceBase* service,
168 int type, 168 const std::string& pref_name) {
169 const content::NotificationSource& source, 169 if (prefs::kGoogleServicesUsername == pref_name)
170 const content::NotificationDetails& details) { 170 OnUsernameChanged();
171 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
172 std::string* name = content::Details<std::string>(details).ptr();
173 if (prefs::kGoogleServicesUsername == *name)
174 OnUsernameChanged();
175 } else {
176 NOTREACHED();
177 }
178 } 171 }
179 172
180 void GAIAInfoUpdateService::OnUsernameChanged() { 173 void GAIAInfoUpdateService::OnUsernameChanged() {
181 ProfileInfoCache& cache = 174 ProfileInfoCache& cache =
182 g_browser_process->profile_manager()->GetProfileInfoCache(); 175 g_browser_process->profile_manager()->GetProfileInfoCache();
183 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); 176 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
184 if (profile_index == std::string::npos) 177 if (profile_index == std::string::npos)
185 return; 178 return;
186 179
187 std::string username = profile_->GetPrefs()->GetString( 180 std::string username = profile_->GetPrefs()->GetString(
(...skipping 23 matching lines...) Expand all
211 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; 204 const base::TimeDelta update_delta = base::Time::Now() - last_updated_;
212 205
213 base::TimeDelta delta; 206 base::TimeDelta delta;
214 if (update_delta < base::TimeDelta() || update_delta > desired_delta) 207 if (update_delta < base::TimeDelta() || update_delta > desired_delta)
215 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); 208 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds);
216 else 209 else
217 delta = desired_delta - update_delta; 210 delta = desired_delta - update_delta;
218 211
219 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); 212 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update);
220 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.h ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698