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

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

Issue 2422943002: Remove usage of FOR_EACH_OBSERVER macro in components/signin (Closed)
Patch Set: Created 4 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/gaia_cookie_manager_service.h" 5 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 10
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 base::Unretained(this))); 512 base::Unretained(this)));
513 } 513 }
514 } 514 }
515 515
516 void GaiaCookieManagerService::SignalComplete( 516 void GaiaCookieManagerService::SignalComplete(
517 const std::string& account_id, 517 const std::string& account_id,
518 const GoogleServiceAuthError& error) { 518 const GoogleServiceAuthError& error) {
519 // Its possible for the observer to delete |this| object. Don't access 519 // Its possible for the observer to delete |this| object. Don't access
520 // access any members after this calling the observer. This method should 520 // access any members after this calling the observer. This method should
521 // be the last call in any other method. 521 // be the last call in any other method.
522 FOR_EACH_OBSERVER(Observer, observer_list_, 522 for (auto& observer : observer_list_)
523 OnAddAccountToCookieCompleted(account_id, error)); 523 observer.OnAddAccountToCookieCompleted(account_id, error);
524 } 524 }
525 525
526 void GaiaCookieManagerService::OnUbertokenSuccess( 526 void GaiaCookieManagerService::OnUbertokenSuccess(
527 const std::string& uber_token) { 527 const std::string& uber_token) {
528 DCHECK(requests_.front().request_type() == 528 DCHECK(requests_.front().request_type() ==
529 GaiaCookieRequestType::ADD_ACCOUNT); 529 GaiaCookieRequestType::ADD_ACCOUNT);
530 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" 530 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess"
531 << " account=" << requests_.front().account_id(); 531 << " account=" << requests_.front().account_id();
532 fetcher_retries_ = 0; 532 fetcher_retries_ = 0;
533 uber_token_ = uber_token; 533 uber_token_ = uber_token;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 account.id = AccountTrackerService::PickAccountIdForAccount( 620 account.id = AccountTrackerService::PickAccountIdForAccount(
621 signin_client_->GetPrefs(), account.gaia_id, account.email); 621 signin_client_->GetPrefs(), account.gaia_id, account.email);
622 } 622 }
623 623
624 list_accounts_stale_ = false; 624 list_accounts_stale_ = false;
625 HandleNextRequest(); 625 HandleNextRequest();
626 // HandleNextRequest before sending out the notification because some 626 // HandleNextRequest before sending out the notification because some
627 // services, in response to OnGaiaAccountsInCookieUpdated, may try in return 627 // services, in response to OnGaiaAccountsInCookieUpdated, may try in return
628 // to call ListAccounts, which would immediately return false if the 628 // to call ListAccounts, which would immediately return false if the
629 // ListAccounts request is still sitting in queue. 629 // ListAccounts request is still sitting in queue.
630 FOR_EACH_OBSERVER(Observer, observer_list_, 630 for (auto& observer : observer_list_) {
631 OnGaiaAccountsInCookieUpdated( 631 observer.OnGaiaAccountsInCookieUpdated(
632 listed_accounts_, 632 listed_accounts_, signed_out_accounts_,
633 signed_out_accounts_, 633 GoogleServiceAuthError(GoogleServiceAuthError::NONE));
634 GoogleServiceAuthError(GoogleServiceAuthError::NONE))); 634 }
635 } 635 }
636 636
637 void GaiaCookieManagerService::OnListAccountsFailure( 637 void GaiaCookieManagerService::OnListAccountsFailure(
638 const GoogleServiceAuthError& error) { 638 const GoogleServiceAuthError& error) {
639 VLOG(1) << "ListAccounts failed"; 639 VLOG(1) << "ListAccounts failed";
640 DCHECK(requests_.front().request_type() == 640 DCHECK(requests_.front().request_type() ==
641 GaiaCookieRequestType::LIST_ACCOUNTS); 641 GaiaCookieRequestType::LIST_ACCOUNTS);
642 if (++fetcher_retries_ < kMaxFetcherRetries && error.IsTransientError()) { 642 if (++fetcher_retries_ < kMaxFetcherRetries && error.IsTransientError()) {
643 fetcher_backoff_.InformOfRequest(false); 643 fetcher_backoff_.InformOfRequest(false);
644 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsRetry", 644 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsRetry",
645 error.state(), GoogleServiceAuthError::NUM_STATES); 645 error.state(), GoogleServiceAuthError::NUM_STATES);
646 fetcher_timer_.Start( 646 fetcher_timer_.Start(
647 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), 647 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(),
648 base::Bind(&SigninClient::DelayNetworkCall, 648 base::Bind(&SigninClient::DelayNetworkCall,
649 base::Unretained(signin_client_), 649 base::Unretained(signin_client_),
650 base::Bind( 650 base::Bind(
651 &GaiaCookieManagerService::StartFetchingListAccounts, 651 &GaiaCookieManagerService::StartFetchingListAccounts,
652 base::Unretained(this)))); 652 base::Unretained(this))));
653 return; 653 return;
654 } 654 }
655 655
656 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsFailure", 656 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsFailure",
657 error.state(), GoogleServiceAuthError::NUM_STATES); 657 error.state(), GoogleServiceAuthError::NUM_STATES);
658 FOR_EACH_OBSERVER(Observer, observer_list_, 658 for (auto& observer : observer_list_) {
659 OnGaiaAccountsInCookieUpdated( 659 observer.OnGaiaAccountsInCookieUpdated(listed_accounts_,
660 listed_accounts_, signed_out_accounts_, error)); 660 signed_out_accounts_, error);
661 }
661 HandleNextRequest(); 662 HandleNextRequest();
662 } 663 }
663 664
664 void GaiaCookieManagerService::OnLogOutSuccess() { 665 void GaiaCookieManagerService::OnLogOutSuccess() {
665 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); 666 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT);
666 VLOG(1) << "GaiaCookieManagerService::OnLogOutSuccess"; 667 VLOG(1) << "GaiaCookieManagerService::OnLogOutSuccess";
667 668
668 list_accounts_stale_ = true; 669 list_accounts_stale_ = true;
669 fetcher_backoff_.InformOfRequest(true); 670 fetcher_backoff_.InformOfRequest(true);
670 FOR_EACH_OBSERVER(Observer, observer_list_, 671 for (auto& observer : observer_list_) {
671 OnLogOutAccountsFromCookieCompleted( 672 observer.OnLogOutAccountsFromCookieCompleted(
672 GoogleServiceAuthError(GoogleServiceAuthError::NONE))); 673 GoogleServiceAuthError(GoogleServiceAuthError::NONE));
674 }
673 HandleNextRequest(); 675 HandleNextRequest();
674 } 676 }
675 677
676 void GaiaCookieManagerService::OnLogOutFailure( 678 void GaiaCookieManagerService::OnLogOutFailure(
677 const GoogleServiceAuthError& error) { 679 const GoogleServiceAuthError& error) {
678 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); 680 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT);
679 VLOG(1) << "GaiaCookieManagerService::OnLogOutFailure"; 681 VLOG(1) << "GaiaCookieManagerService::OnLogOutFailure";
680 682
681 if (++fetcher_retries_ < kMaxFetcherRetries) { 683 if (++fetcher_retries_ < kMaxFetcherRetries) {
682 fetcher_backoff_.InformOfRequest(false); 684 fetcher_backoff_.InformOfRequest(false);
683 fetcher_timer_.Start( 685 fetcher_timer_.Start(
684 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), 686 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(),
685 base::Bind(&SigninClient::DelayNetworkCall, 687 base::Bind(&SigninClient::DelayNetworkCall,
686 base::Unretained(signin_client_), 688 base::Unretained(signin_client_),
687 base::Bind(&GaiaCookieManagerService::StartFetchingLogOut, 689 base::Bind(&GaiaCookieManagerService::StartFetchingLogOut,
688 base::Unretained(this)))); 690 base::Unretained(this))));
689 return; 691 return;
690 } 692 }
691 693
692 FOR_EACH_OBSERVER(Observer, observer_list_, 694 for (auto& observer : observer_list_)
693 OnLogOutAccountsFromCookieCompleted(error)); 695 observer.OnLogOutAccountsFromCookieCompleted(error);
694 HandleNextRequest(); 696 HandleNextRequest();
695 } 697 }
696 698
697 void GaiaCookieManagerService::StartFetchingUbertoken() { 699 void GaiaCookieManagerService::StartFetchingUbertoken() {
698 VLOG(1) << "GaiaCookieManagerService::StartFetchingUbertoken account_id=" 700 VLOG(1) << "GaiaCookieManagerService::StartFetchingUbertoken account_id="
699 << requests_.front().account_id(); 701 << requests_.front().account_id();
700 uber_token_fetcher_.reset(new UbertokenFetcher( 702 uber_token_fetcher_.reset(new UbertokenFetcher(
701 token_service_, this, source_, signin_client_->GetURLRequestContext(), 703 token_service_, this, source_, signin_client_->GetURLRequestContext(),
702 base::Bind(&SigninClient::CreateGaiaAuthFetcher, 704 base::Bind(&SigninClient::CreateGaiaAuthFetcher,
703 base::Unretained(signin_client_)))); 705 base::Unretained(signin_client_))));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 break; 772 break;
771 case GaiaCookieRequestType::LIST_ACCOUNTS: 773 case GaiaCookieRequestType::LIST_ACCOUNTS:
772 uber_token_fetcher_.reset(); 774 uber_token_fetcher_.reset();
773 signin_client_->DelayNetworkCall( 775 signin_client_->DelayNetworkCall(
774 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, 776 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts,
775 base::Unretained(this))); 777 base::Unretained(this)));
776 break; 778 break;
777 } 779 }
778 } 780 }
779 } 781 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/fake_signin_manager.cc ('k') | components/signin/core/browser/signin_error_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698