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

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

Issue 601643002: Use a distinct source parameter on gaia endpoints for the reconcilor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uber
Patch Set: rebased Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_reconcilor.h" 5 #include "components/signin/core/browser/account_reconcilor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } // namespace 54 } // namespace
55 55
56 56
57 AccountReconcilor::AccountReconcilor(ProfileOAuth2TokenService* token_service, 57 AccountReconcilor::AccountReconcilor(ProfileOAuth2TokenService* token_service,
58 SigninManagerBase* signin_manager, 58 SigninManagerBase* signin_manager,
59 SigninClient* client) 59 SigninClient* client)
60 : token_service_(token_service), 60 : token_service_(token_service),
61 signin_manager_(signin_manager), 61 signin_manager_(signin_manager),
62 client_(client), 62 client_(client),
63 merge_session_helper_(token_service_, 63 merge_session_helper_(token_service_,
64 GaiaConstants::kReconcilorSource,
64 client->GetURLRequestContext(), 65 client->GetURLRequestContext(),
65 this), 66 this),
66 registered_with_token_service_(false), 67 registered_with_token_service_(false),
67 is_reconcile_started_(false), 68 is_reconcile_started_(false),
68 first_execution_(true), 69 first_execution_(true),
69 are_gaia_accounts_set_(false) { 70 are_gaia_accounts_set_(false) {
70 VLOG(1) << "AccountReconcilor::AccountReconcilor"; 71 VLOG(1) << "AccountReconcilor::AccountReconcilor";
71 } 72 }
72 73
73 AccountReconcilor::~AccountReconcilor() { 74 AccountReconcilor::~AccountReconcilor() {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Reset state for validating oauth2 tokens. 237 // Reset state for validating oauth2 tokens.
237 primary_account_.clear(); 238 primary_account_.clear();
238 chrome_accounts_.clear(); 239 chrome_accounts_.clear();
239 add_to_cookie_.clear(); 240 add_to_cookie_.clear();
240 ValidateAccountsFromTokenService(); 241 ValidateAccountsFromTokenService();
241 } 242 }
242 243
243 void AccountReconcilor::GetAccountsFromCookie( 244 void AccountReconcilor::GetAccountsFromCookie(
244 GetAccountsFromCookieCallback callback) { 245 GetAccountsFromCookieCallback callback) {
245 get_gaia_accounts_callbacks_.push_back(callback); 246 get_gaia_accounts_callbacks_.push_back(callback);
246 if (!gaia_fetcher_) { 247 if (!gaia_fetcher_)
247 // There is no list account request in flight. 248 MayBeDoNextListAccounts();
248 gaia_fetcher_.reset(new GaiaAuthFetcher(
249 this, GaiaConstants::kChromeSource, client_->GetURLRequestContext()));
250 gaia_fetcher_->StartListAccounts();
251 }
252 } 249 }
253 250
254 void AccountReconcilor::StartFetchingExternalCcResult() { 251 void AccountReconcilor::StartFetchingExternalCcResult() {
255 merge_session_helper_.StartFetchingExternalCcResult(); 252 merge_session_helper_.StartFetchingExternalCcResult();
256 } 253 }
257 254
258 void AccountReconcilor::OnListAccountsSuccess(const std::string& data) { 255 void AccountReconcilor::OnListAccountsSuccess(const std::string& data) {
259 gaia_fetcher_.reset(); 256 gaia_fetcher_.reset();
260 257
261 // Get account information from response data. 258 // Get account information from response data.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 292
296 get_gaia_accounts_callbacks_.front().Run(error, empty_accounts); 293 get_gaia_accounts_callbacks_.front().Run(error, empty_accounts);
297 get_gaia_accounts_callbacks_.pop_front(); 294 get_gaia_accounts_callbacks_.pop_front();
298 295
299 MayBeDoNextListAccounts(); 296 MayBeDoNextListAccounts();
300 } 297 }
301 298
302 void AccountReconcilor::MayBeDoNextListAccounts() { 299 void AccountReconcilor::MayBeDoNextListAccounts() {
303 if (!get_gaia_accounts_callbacks_.empty()) { 300 if (!get_gaia_accounts_callbacks_.empty()) {
304 gaia_fetcher_.reset(new GaiaAuthFetcher( 301 gaia_fetcher_.reset(new GaiaAuthFetcher(
305 this, GaiaConstants::kChromeSource, client_->GetURLRequestContext())); 302 this, GaiaConstants::kReconcilorSource,
303 client_->GetURLRequestContext()));
306 gaia_fetcher_->StartListAccounts(); 304 gaia_fetcher_->StartListAccounts();
307 } 305 }
308 } 306 }
309 307
310 void AccountReconcilor::ContinueReconcileActionAfterGetGaiaAccounts( 308 void AccountReconcilor::ContinueReconcileActionAfterGetGaiaAccounts(
311 const GoogleServiceAuthError& error, 309 const GoogleServiceAuthError& error,
312 const std::vector<std::pair<std::string, bool> >& accounts) { 310 const std::vector<std::pair<std::string, bool> >& accounts) {
313 if (error.state() == GoogleServiceAuthError::NONE) { 311 if (error.state() == GoogleServiceAuthError::NONE) {
314 gaia_accounts_ = accounts; 312 gaia_accounts_ = accounts;
315 are_gaia_accounts_set_ = true; 313 are_gaia_accounts_set_ = true;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 const std::string& account_id, 479 const std::string& account_id,
482 const GoogleServiceAuthError& error) { 480 const GoogleServiceAuthError& error) {
483 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id=" 481 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
484 << account_id << " error=" << error.ToString(); 482 << account_id << " error=" << error.ToString();
485 483
486 if (MarkAccountAsAddedToCookie(account_id)) { 484 if (MarkAccountAsAddedToCookie(account_id)) {
487 CalculateIfReconcileIsDone(); 485 CalculateIfReconcileIsDone();
488 ScheduleStartReconcileIfChromeAccountsChanged(); 486 ScheduleStartReconcileIfChromeAccountsChanged();
489 } 487 }
490 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698