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

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

Issue 309843002: Improve UMA tests; improve no-op reconcilor; new reconcilor test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « components/signin/core/browser/account_reconcilor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 VLOG(1) << "AccountReconcilor::GoogleSignedOut: signed out"; 352 VLOG(1) << "AccountReconcilor::GoogleSignedOut: signed out";
353 gaia_fetcher_.reset(); 353 gaia_fetcher_.reset();
354 get_gaia_accounts_callbacks_.clear(); 354 get_gaia_accounts_callbacks_.clear();
355 AbortReconcile(); 355 AbortReconcile();
356 UnregisterWithTokenService(); 356 UnregisterWithTokenService();
357 UnregisterForCookieChanges(); 357 UnregisterForCookieChanges();
358 PerformLogoutAllAccountsAction(); 358 PerformLogoutAllAccountsAction();
359 } 359 }
360 360
361 void AccountReconcilor::PerformMergeAction(const std::string& account_id) { 361 void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
362 if (!switches::IsNewProfileManagement()) 362 if (!switches::IsNewProfileManagement()) {
363 MarkAccountAsAddedToCookie(account_id);
363 return; 364 return;
365 }
364 VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id; 366 VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id;
365 merge_session_helper_.LogIn(account_id); 367 merge_session_helper_.LogIn(account_id);
366 } 368 }
367 369
368 void AccountReconcilor::PerformStartRemoveAction( 370 void AccountReconcilor::PerformStartRemoveAction(
369 const std::string& account_id) { 371 const std::string& account_id) {
370 VLOG(1) << "AccountReconcilor::PerformStartRemoveAction: " << account_id; 372 VLOG(1) << "AccountReconcilor::PerformStartRemoveAction: " << account_id;
371 GetAccountsFromCookie(base::Bind( 373 GetAccountsFromCookie(base::Bind(
372 &AccountReconcilor::PerformFinishRemoveAction, 374 &AccountReconcilor::PerformFinishRemoveAction,
373 base::Unretained(this), 375 base::Unretained(this),
(...skipping 17 matching lines...) Expand all
391 ++i) { 393 ++i) {
392 accounts_only.push_back(i->first); 394 accounts_only.push_back(i->first);
393 } 395 }
394 merge_session_helper_.LogOut(account_id, accounts_only); 396 merge_session_helper_.LogOut(account_id, accounts_only);
395 } 397 }
396 // Wait for the next ReconcileAction if there is an error. 398 // Wait for the next ReconcileAction if there is an error.
397 } 399 }
398 400
399 void AccountReconcilor::PerformAddToChromeAction(const std::string& account_id, 401 void AccountReconcilor::PerformAddToChromeAction(const std::string& account_id,
400 int session_index) { 402 int session_index) {
401 if (!switches::IsNewProfileManagement()) 403 if (!switches::IsNewProfileManagement()) {
404 MarkAccountAsAddedToChrome(account_id);
402 return; 405 return;
406 }
403 VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:" 407 VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:"
404 << " account=" << account_id << " session_index=" << session_index; 408 << " account=" << account_id << " session_index=" << session_index;
405 409
406 #if !defined(OS_ANDROID) && !defined(OS_IOS) 410 #if !defined(OS_ANDROID) && !defined(OS_IOS)
407 refresh_token_fetchers_.push_back( 411 refresh_token_fetchers_.push_back(
408 new RefreshTokenFetcher(this, account_id, session_index)); 412 new RefreshTokenFetcher(this, account_id, session_index));
409 #endif 413 #endif
410 } 414 }
411 415
412 void AccountReconcilor::PerformLogoutAllAccountsAction() { 416 void AccountReconcilor::PerformLogoutAllAccountsAction() {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 std::vector<std::string> new_chrome_accounts(token_service_->GetAccounts()); 705 std::vector<std::string> new_chrome_accounts(token_service_->GetAccounts());
702 std::sort(reconciled_accounts.begin(), reconciled_accounts.end()); 706 std::sort(reconciled_accounts.begin(), reconciled_accounts.end());
703 std::sort(new_chrome_accounts.begin(), new_chrome_accounts.end()); 707 std::sort(new_chrome_accounts.begin(), new_chrome_accounts.end());
704 if (reconciled_accounts != new_chrome_accounts) { 708 if (reconciled_accounts != new_chrome_accounts) {
705 base::MessageLoop::current()->PostTask( 709 base::MessageLoop::current()->PostTask(
706 FROM_HERE, 710 FROM_HERE,
707 base::Bind(&AccountReconcilor::StartReconcile, base::Unretained(this))); 711 base::Bind(&AccountReconcilor::StartReconcile, base::Unretained(this)));
708 } 712 }
709 } 713 }
710 714
711 void AccountReconcilor::MergeSessionCompleted( 715 // Remove the account from the list that is being merged.
712 const std::string& account_id, 716 void AccountReconcilor::MarkAccountAsAddedToCookie(
713 const GoogleServiceAuthError& error) { 717 const std::string& account_id) {
714 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
715 << account_id;
716
717 // Remove the account from the list that is being merged.
718 for (std::vector<std::string>::iterator i = add_to_cookie_.begin(); 718 for (std::vector<std::string>::iterator i = add_to_cookie_.begin();
719 i != add_to_cookie_.end(); 719 i != add_to_cookie_.end();
720 ++i) { 720 ++i) {
721 if (account_id == *i) { 721 if (account_id == *i) {
722 add_to_cookie_.erase(i); 722 add_to_cookie_.erase(i);
723 break; 723 break;
724 } 724 }
725 } 725 }
726 }
726 727
728 void AccountReconcilor::MergeSessionCompleted(
729 const std::string& account_id,
730 const GoogleServiceAuthError& error) {
731 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
732 << account_id;
733
734 MarkAccountAsAddedToCookie(account_id);
727 CalculateIfReconcileIsDone(); 735 CalculateIfReconcileIsDone();
728 ScheduleStartReconcileIfChromeAccountsChanged(); 736 ScheduleStartReconcileIfChromeAccountsChanged();
729 } 737 }
730 738
731 void AccountReconcilor::HandleSuccessfulAccountIdCheck( 739 void AccountReconcilor::HandleSuccessfulAccountIdCheck(
732 const std::string& account_id) { 740 const std::string& account_id) {
733 valid_chrome_accounts_.insert(account_id); 741 valid_chrome_accounts_.insert(account_id);
734 FinishReconcile(); 742 FinishReconcile();
735 } 743 }
736 744
737 void AccountReconcilor::HandleFailedAccountIdCheck( 745 void AccountReconcilor::HandleFailedAccountIdCheck(
738 const std::string& account_id) { 746 const std::string& account_id) {
739 invalid_chrome_accounts_.insert(account_id); 747 invalid_chrome_accounts_.insert(account_id);
740 FinishReconcile(); 748 FinishReconcile();
741 } 749 }
742 750
743 void AccountReconcilor::PerformAddAccountToTokenService( 751 void AccountReconcilor::PerformAddAccountToTokenService(
744 const std::string& account_id, 752 const std::string& account_id,
745 const std::string& refresh_token) { 753 const std::string& refresh_token) {
746 // The flow should never get to this method if new_profile_management is 754 // The flow should never get to this method if new_profile_management is
747 // false, but better safe than sorry. 755 // false, but better safe than sorry.
748 if (!switches::IsNewProfileManagement()) 756 if (!switches::IsNewProfileManagement())
749 return; 757 return;
750 token_service_->UpdateCredentials(account_id, refresh_token); 758 token_service_->UpdateCredentials(account_id, refresh_token);
751 } 759 }
752 760
753 void AccountReconcilor::HandleRefreshTokenFetched( 761 // Remove the account from the list that is being updated.
754 const std::string& account_id, 762 void AccountReconcilor::MarkAccountAsAddedToChrome(
755 const std::string& refresh_token) { 763 const std::string& account_id) {
756 if (!refresh_token.empty()) {
757 PerformAddAccountToTokenService(account_id, refresh_token);
758 }
759 // Remove the account from the list that is being updated.
760 for (std::vector<std::pair<std::string, int> >::iterator i = 764 for (std::vector<std::pair<std::string, int> >::iterator i =
761 add_to_chrome_.begin(); 765 add_to_chrome_.begin();
762 i != add_to_chrome_.end(); 766 i != add_to_chrome_.end();
763 ++i) { 767 ++i) {
764 if (gaia::AreEmailsSame(account_id, i->first)) { 768 if (gaia::AreEmailsSame(account_id, i->first)) {
765 add_to_chrome_.erase(i); 769 add_to_chrome_.erase(i);
766 break; 770 break;
767 } 771 }
768 } 772 }
773 }
769 774
775 void AccountReconcilor::HandleRefreshTokenFetched(
776 const std::string& account_id,
777 const std::string& refresh_token) {
778 if (!refresh_token.empty())
779 PerformAddAccountToTokenService(account_id, refresh_token);
780
781 MarkAccountAsAddedToChrome(account_id);
770 CalculateIfReconcileIsDone(); 782 CalculateIfReconcileIsDone();
771 } 783 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/account_reconcilor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698