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

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: 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
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 std::vector<std::string> new_chrome_accounts(token_service_->GetAccounts()); 690 std::vector<std::string> new_chrome_accounts(token_service_->GetAccounts());
687 std::sort(reconciled_accounts.begin(), reconciled_accounts.end()); 691 std::sort(reconciled_accounts.begin(), reconciled_accounts.end());
688 std::sort(new_chrome_accounts.begin(), new_chrome_accounts.end()); 692 std::sort(new_chrome_accounts.begin(), new_chrome_accounts.end());
689 if (reconciled_accounts != new_chrome_accounts) { 693 if (reconciled_accounts != new_chrome_accounts) {
690 base::MessageLoop::current()->PostTask( 694 base::MessageLoop::current()->PostTask(
691 FROM_HERE, 695 FROM_HERE,
692 base::Bind(&AccountReconcilor::StartReconcile, base::Unretained(this))); 696 base::Bind(&AccountReconcilor::StartReconcile, base::Unretained(this)));
693 } 697 }
694 } 698 }
695 699
696 void AccountReconcilor::MergeSessionCompleted( 700 // Remove the account from the list that is being merged.
697 const std::string& account_id, 701 void AccountReconcilor::MarkAccountAsAddedToCookie(
698 const GoogleServiceAuthError& error) { 702 const std::string& account_id) {
699 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
700 << account_id;
701
702 // Remove the account from the list that is being merged.
703 for (std::vector<std::string>::iterator i = add_to_cookie_.begin(); 703 for (std::vector<std::string>::iterator i = add_to_cookie_.begin();
704 i != add_to_cookie_.end(); 704 i != add_to_cookie_.end();
705 ++i) { 705 ++i) {
706 if (account_id == *i) { 706 if (account_id == *i) {
707 add_to_cookie_.erase(i); 707 add_to_cookie_.erase(i);
708 break; 708 break;
709 } 709 }
710 } 710 }
711 }
711 712
713 void AccountReconcilor::MergeSessionCompleted(
714 const std::string& account_id,
715 const GoogleServiceAuthError& error) {
716 VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
Alexei Svitkine (slow) 2014/06/12 17:09:14 Does this need to be VLOG(1)? The string will live
Mike Lerman 2014/06/12 18:12:16 We do use these in release builds to debug what's
717 << account_id;
718
719 MarkAccountAsAddedToCookie(account_id);
712 CalculateIfReconcileIsDone(); 720 CalculateIfReconcileIsDone();
713 ScheduleStartReconcileIfChromeAccountsChanged(); 721 ScheduleStartReconcileIfChromeAccountsChanged();
714 } 722 }
715 723
716 void AccountReconcilor::HandleSuccessfulAccountIdCheck( 724 void AccountReconcilor::HandleSuccessfulAccountIdCheck(
717 const std::string& account_id) { 725 const std::string& account_id) {
718 valid_chrome_accounts_.insert(account_id); 726 valid_chrome_accounts_.insert(account_id);
719 FinishReconcile(); 727 FinishReconcile();
720 } 728 }
721 729
722 void AccountReconcilor::HandleFailedAccountIdCheck( 730 void AccountReconcilor::HandleFailedAccountIdCheck(
723 const std::string& account_id) { 731 const std::string& account_id) {
724 invalid_chrome_accounts_.insert(account_id); 732 invalid_chrome_accounts_.insert(account_id);
725 FinishReconcile(); 733 FinishReconcile();
726 } 734 }
727 735
728 void AccountReconcilor::PerformAddAccountToTokenService( 736 void AccountReconcilor::PerformAddAccountToTokenService(
729 const std::string& account_id, 737 const std::string& account_id,
730 const std::string& refresh_token) { 738 const std::string& refresh_token) {
731 // The flow should never get to this method if new_profile_management is 739 // The flow should never get to this method if new_profile_management is
732 // false, but better safe than sorry. 740 // false, but better safe than sorry.
733 if (!switches::IsNewProfileManagement()) 741 if (!switches::IsNewProfileManagement())
734 return; 742 return;
735 token_service_->UpdateCredentials(account_id, refresh_token); 743 token_service_->UpdateCredentials(account_id, refresh_token);
736 } 744 }
737 745
738 void AccountReconcilor::HandleRefreshTokenFetched( 746 // Remove the account from the list that is being updated.
739 const std::string& account_id, 747 void AccountReconcilor::MarkAccountAsAddedToChrome(
740 const std::string& refresh_token) { 748 const std::string& account_id) {
741 if (!refresh_token.empty()) {
742 PerformAddAccountToTokenService(account_id, refresh_token);
743 }
744 // Remove the account from the list that is being updated.
745 for (std::vector<std::pair<std::string, int> >::iterator i = 749 for (std::vector<std::pair<std::string, int> >::iterator i =
746 add_to_chrome_.begin(); 750 add_to_chrome_.begin();
747 i != add_to_chrome_.end(); 751 i != add_to_chrome_.end();
748 ++i) { 752 ++i) {
749 if (gaia::AreEmailsSame(account_id, i->first)) { 753 if (gaia::AreEmailsSame(account_id, i->first)) {
750 add_to_chrome_.erase(i); 754 add_to_chrome_.erase(i);
751 break; 755 break;
752 } 756 }
753 } 757 }
758 }
754 759
760 void AccountReconcilor::HandleRefreshTokenFetched(
761 const std::string& account_id,
762 const std::string& refresh_token) {
763 if (!refresh_token.empty()) {
Alexei Svitkine (slow) 2014/06/12 17:09:14 Nit: No {}'s
Mike Lerman 2014/06/12 18:12:16 Done.
764 PerformAddAccountToTokenService(account_id, refresh_token);
765 }
766
767 MarkAccountAsAddedToChrome(account_id);
755 CalculateIfReconcileIsDone(); 768 CalculateIfReconcileIsDone();
756 } 769 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698