| OLD | NEW |
| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // tokens individually is done before proceeding with reconciliation. | 580 // tokens individually is done before proceeding with reconciliation. |
| 581 if (!are_gaia_accounts_set_ || !AreAllRefreshTokensChecked()) | 581 if (!are_gaia_accounts_set_ || !AreAllRefreshTokensChecked()) |
| 582 return; | 582 return; |
| 583 | 583 |
| 584 VLOG(1) << "AccountReconcilor::FinishReconcile"; | 584 VLOG(1) << "AccountReconcilor::FinishReconcile"; |
| 585 | 585 |
| 586 DeleteFetchers(); | 586 DeleteFetchers(); |
| 587 | 587 |
| 588 DCHECK(add_to_cookie_.empty()); | 588 DCHECK(add_to_cookie_.empty()); |
| 589 DCHECK(add_to_chrome_.empty()); | 589 DCHECK(add_to_chrome_.empty()); |
| 590 int number_gaia_accounts = gaia_accounts_.size(); |
| 590 bool are_primaries_equal = | 591 bool are_primaries_equal = |
| 591 gaia_accounts_.size() > 0 && | 592 number_gaia_accounts > 0 && |
| 592 gaia::AreEmailsSame(primary_account_, gaia_accounts_[0].first); | 593 gaia::AreEmailsSame(primary_account_, gaia_accounts_[0].first); |
| 593 | 594 |
| 595 |
| 594 if (are_primaries_equal) { | 596 if (are_primaries_equal) { |
| 595 // Determine if we need to merge accounts from gaia cookie to chrome. | 597 // Determine if we need to merge accounts from gaia cookie to chrome. |
| 596 for (size_t i = 0; i < gaia_accounts_.size(); ++i) { | 598 for (size_t i = 0; i < gaia_accounts_.size(); ++i) { |
| 597 const std::string& gaia_account = gaia_accounts_[i].first; | 599 const std::string& gaia_account = gaia_accounts_[i].first; |
| 598 if (gaia_accounts_[i].second && | 600 if (gaia_accounts_[i].second && |
| 599 valid_chrome_accounts_.find(gaia_account) == | 601 valid_chrome_accounts_.find(gaia_account) == |
| 600 valid_chrome_accounts_.end()) { | 602 valid_chrome_accounts_.end()) { |
| 601 add_to_chrome_.push_back(std::make_pair(gaia_account, i)); | 603 add_to_chrome_.push_back(std::make_pair(gaia_account, i)); |
| 602 } | 604 } |
| 603 } | 605 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 add_to_chrome_.begin(); | 651 add_to_chrome_.begin(); |
| 650 i != add_to_chrome_.end(); | 652 i != add_to_chrome_.end(); |
| 651 ++i) { | 653 ++i) { |
| 652 PerformAddToChromeAction(i->first, i->second); | 654 PerformAddToChromeAction(i->first, i->second); |
| 653 } | 655 } |
| 654 | 656 |
| 655 signin_metrics::LogSigninAccountReconciliation(valid_chrome_accounts_.size(), | 657 signin_metrics::LogSigninAccountReconciliation(valid_chrome_accounts_.size(), |
| 656 added_to_cookie, | 658 added_to_cookie, |
| 657 add_to_chrome_.size(), | 659 add_to_chrome_.size(), |
| 658 are_primaries_equal, | 660 are_primaries_equal, |
| 659 first_execution_); | 661 first_execution_, |
| 662 number_gaia_accounts); |
| 660 first_execution_ = false; | 663 first_execution_ = false; |
| 661 CalculateIfReconcileIsDone(); | 664 CalculateIfReconcileIsDone(); |
| 662 ScheduleStartReconcileIfChromeAccountsChanged(); | 665 ScheduleStartReconcileIfChromeAccountsChanged(); |
| 663 } | 666 } |
| 664 | 667 |
| 665 void AccountReconcilor::AbortReconcile() { | 668 void AccountReconcilor::AbortReconcile() { |
| 666 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later"; | 669 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later"; |
| 667 DeleteFetchers(); | 670 DeleteFetchers(); |
| 668 add_to_cookie_.clear(); | 671 add_to_cookie_.clear(); |
| 669 add_to_chrome_.clear(); | 672 add_to_chrome_.clear(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 i != add_to_chrome_.end(); | 750 i != add_to_chrome_.end(); |
| 748 ++i) { | 751 ++i) { |
| 749 if (gaia::AreEmailsSame(account_id, i->first)) { | 752 if (gaia::AreEmailsSame(account_id, i->first)) { |
| 750 add_to_chrome_.erase(i); | 753 add_to_chrome_.erase(i); |
| 751 break; | 754 break; |
| 752 } | 755 } |
| 753 } | 756 } |
| 754 | 757 |
| 755 CalculateIfReconcileIsDone(); | 758 CalculateIfReconcileIsDone(); |
| 756 } | 759 } |
| OLD | NEW |