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

Side by Side Diff: components/signin/core/browser/account_fetcher_service.cc

Issue 1376933005: Reflect email address changes in the Avatar Menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/signin/core/browser/account_fetcher_service.h" 5 #include "components/signin/core/browser/account_fetcher_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 "account_tracker_service_last_update"; 48 "account_tracker_service_last_update";
49 49
50 // AccountFetcherService implementation 50 // AccountFetcherService implementation
51 AccountFetcherService::AccountFetcherService() 51 AccountFetcherService::AccountFetcherService()
52 : account_tracker_service_(nullptr), 52 : account_tracker_service_(nullptr),
53 token_service_(nullptr), 53 token_service_(nullptr),
54 signin_client_(nullptr), 54 signin_client_(nullptr),
55 invalidation_service_(nullptr), 55 invalidation_service_(nullptr),
56 network_fetches_enabled_(false), 56 network_fetches_enabled_(false),
57 shutdown_called_(false), 57 shutdown_called_(false),
58 refresh_required_on_load_(false),
58 child_info_request_(nullptr) {} 59 child_info_request_(nullptr) {}
59 60
60 AccountFetcherService::~AccountFetcherService() { 61 AccountFetcherService::~AccountFetcherService() {
61 DCHECK(shutdown_called_); 62 DCHECK(shutdown_called_);
62 } 63 }
63 64
64 // static 65 // static
65 void AccountFetcherService::RegisterPrefs( 66 void AccountFetcherService::RegisterPrefs(
66 user_prefs::PrefRegistrySyncable* user_prefs) { 67 user_prefs::PrefRegistrySyncable* user_prefs) {
67 user_prefs->RegisterInt64Pref(kLastUpdatePref, 0); 68 user_prefs->RegisterInt64Pref(kLastUpdatePref, 0);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 last_updated_.ToInternalValue()); 162 last_updated_.ToInternalValue());
162 ScheduleNextRefresh(); 163 ScheduleNextRefresh();
163 } 164 }
164 165
165 void AccountFetcherService::ScheduleNextRefresh() { 166 void AccountFetcherService::ScheduleNextRefresh() {
166 DCHECK(!timer_.IsRunning()); 167 DCHECK(!timer_.IsRunning());
167 DCHECK(network_fetches_enabled_); 168 DCHECK(network_fetches_enabled_);
168 169
169 const base::TimeDelta time_since_update = base::Time::Now() - last_updated_; 170 const base::TimeDelta time_since_update = base::Time::Now() - last_updated_;
170 if(time_since_update > kRefreshFromTokenServiceDelay) { 171 if(time_since_update > kRefreshFromTokenServiceDelay) {
171 RefreshAllAccountsAndScheduleNext(); 172 // The service is due for a refresh but the TokenService isn't ready at this
173 // point so |refresh_required_on_load_| is set to make sure we update all
174 // the accounts in OnRefreshTokensLoaded().
175 refresh_required_on_load_ = true;
172 } else { 176 } else {
173 timer_.Start(FROM_HERE, kRefreshFromTokenServiceDelay - time_since_update, 177 timer_.Start(FROM_HERE, kRefreshFromTokenServiceDelay - time_since_update,
174 this, 178 this,
175 &AccountFetcherService::RefreshAllAccountsAndScheduleNext); 179 &AccountFetcherService::RefreshAllAccountsAndScheduleNext);
176 } 180 }
177 } 181 }
178 182
179 // Starts fetching user information. This is called periodically to refresh. 183 // Starts fetching user information. This is called periodically to refresh.
180 void AccountFetcherService::StartFetchingUserInfo( 184 void AccountFetcherService::StartFetchingUserInfo(
181 const std::string& account_id) { 185 const std::string& account_id) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 314
311 DVLOG(1) << "REVOKED " << account_id; 315 DVLOG(1) << "REVOKED " << account_id;
312 user_info_requests_.erase(account_id); 316 user_info_requests_.erase(account_id);
313 UpdateChildInfo(); 317 UpdateChildInfo();
314 account_tracker_service_->StopTrackingAccount(account_id); 318 account_tracker_service_->StopTrackingAccount(account_id);
315 } 319 }
316 320
317 void AccountFetcherService::OnRefreshTokensLoaded() { 321 void AccountFetcherService::OnRefreshTokensLoaded() {
318 // OnRefreshTokenAvailable has been called for all accounts by this point. 322 // OnRefreshTokenAvailable has been called for all accounts by this point.
319 // Maybe remove this after further investigation. 323 // Maybe remove this after further investigation.
320 RefreshAllAccountInfo(true); 324 RefreshAllAccountInfo(!refresh_required_on_load_);
321 UpdateChildInfo(); 325 UpdateChildInfo();
322 } 326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698