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

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

Issue 338573002: Differentiate primary account compares on GAIA cookie presence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // tokens individually is done before proceeding with reconciliation. 597 // tokens individually is done before proceeding with reconciliation.
598 if (!are_gaia_accounts_set_ || !AreAllRefreshTokensChecked()) 598 if (!are_gaia_accounts_set_ || !AreAllRefreshTokensChecked())
599 return; 599 return;
600 600
601 VLOG(1) << "AccountReconcilor::FinishReconcile"; 601 VLOG(1) << "AccountReconcilor::FinishReconcile";
602 602
603 DeleteFetchers(); 603 DeleteFetchers();
604 604
605 DCHECK(add_to_cookie_.empty()); 605 DCHECK(add_to_cookie_.empty());
606 DCHECK(add_to_chrome_.empty()); 606 DCHECK(add_to_chrome_.empty());
607 int number_gaia_accounts = gaia_accounts_.size();
607 bool are_primaries_equal = 608 bool are_primaries_equal =
608 gaia_accounts_.size() > 0 && 609 number_gaia_accounts > 0 &&
609 gaia::AreEmailsSame(primary_account_, gaia_accounts_[0].first); 610 gaia::AreEmailsSame(primary_account_, gaia_accounts_[0].first);
610 611
612
611 if (are_primaries_equal) { 613 if (are_primaries_equal) {
612 // Determine if we need to merge accounts from gaia cookie to chrome. 614 // Determine if we need to merge accounts from gaia cookie to chrome.
613 for (size_t i = 0; i < gaia_accounts_.size(); ++i) { 615 for (size_t i = 0; i < gaia_accounts_.size(); ++i) {
614 const std::string& gaia_account = gaia_accounts_[i].first; 616 const std::string& gaia_account = gaia_accounts_[i].first;
615 if (gaia_accounts_[i].second && 617 if (gaia_accounts_[i].second &&
616 valid_chrome_accounts_.find(gaia_account) == 618 valid_chrome_accounts_.find(gaia_account) ==
617 valid_chrome_accounts_.end()) { 619 valid_chrome_accounts_.end()) {
618 add_to_chrome_.push_back(std::make_pair(gaia_account, i)); 620 add_to_chrome_.push_back(std::make_pair(gaia_account, i));
619 } 621 }
620 } 622 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 add_to_chrome_copy.begin(); 670 add_to_chrome_copy.begin();
669 i != add_to_chrome_copy.end(); 671 i != add_to_chrome_copy.end();
670 ++i) { 672 ++i) {
671 PerformAddToChromeAction(i->first, i->second); 673 PerformAddToChromeAction(i->first, i->second);
672 } 674 }
673 675
674 signin_metrics::LogSigninAccountReconciliation(valid_chrome_accounts_.size(), 676 signin_metrics::LogSigninAccountReconciliation(valid_chrome_accounts_.size(),
675 added_to_cookie, 677 added_to_cookie,
676 add_to_chrome_.size(), 678 add_to_chrome_.size(),
677 are_primaries_equal, 679 are_primaries_equal,
678 first_execution_); 680 first_execution_,
681 number_gaia_accounts);
679 first_execution_ = false; 682 first_execution_ = false;
680 CalculateIfReconcileIsDone(); 683 CalculateIfReconcileIsDone();
681 ScheduleStartReconcileIfChromeAccountsChanged(); 684 ScheduleStartReconcileIfChromeAccountsChanged();
682 } 685 }
683 686
684 void AccountReconcilor::AbortReconcile() { 687 void AccountReconcilor::AbortReconcile() {
685 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later"; 688 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later";
686 DeleteFetchers(); 689 DeleteFetchers();
687 add_to_cookie_.clear(); 690 add_to_cookie_.clear();
688 add_to_chrome_.clear(); 691 add_to_chrome_.clear();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 777
775 void AccountReconcilor::HandleRefreshTokenFetched( 778 void AccountReconcilor::HandleRefreshTokenFetched(
776 const std::string& account_id, 779 const std::string& account_id,
777 const std::string& refresh_token) { 780 const std::string& refresh_token) {
778 if (!refresh_token.empty()) 781 if (!refresh_token.empty())
779 PerformAddAccountToTokenService(account_id, refresh_token); 782 PerformAddAccountToTokenService(account_id, refresh_token);
780 783
781 MarkAccountAsAddedToChrome(account_id); 784 MarkAccountAsAddedToChrome(account_id);
782 CalculateIfReconcileIsDone(); 785 CalculateIfReconcileIsDone();
783 } 786 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/account_reconcilor_unittest.cc ('k') | components/signin/core/browser/signin_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698