| 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/gaia_cookie_manager_service.h" | 5 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "components/signin/core/browser/signin_metrics.h" | 17 #include "components/signin/core/browser/signin_metrics.h" |
| 17 #include "google_apis/gaia/gaia_auth_fetcher.h" | 18 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 18 #include "google_apis/gaia/gaia_auth_util.h" | 19 #include "google_apis/gaia/gaia_auth_util.h" |
| 19 #include "google_apis/gaia/gaia_constants.h" | 20 #include "google_apis/gaia/gaia_constants.h" |
| 20 #include "google_apis/gaia/gaia_urls.h" | 21 #include "google_apis/gaia/gaia_urls.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 520 |
| 520 void GaiaCookieManagerService::OnMergeSessionFailure( | 521 void GaiaCookieManagerService::OnMergeSessionFailure( |
| 521 const GoogleServiceAuthError& error) { | 522 const GoogleServiceAuthError& error) { |
| 522 DCHECK(requests_.front().request_type() == | 523 DCHECK(requests_.front().request_type() == |
| 523 GaiaCookieRequestType::ADD_ACCOUNT); | 524 GaiaCookieRequestType::ADD_ACCOUNT); |
| 524 VLOG(1) << "Failed MergeSession" | 525 VLOG(1) << "Failed MergeSession" |
| 525 << " account=" << requests_.front().account_id() | 526 << " account=" << requests_.front().account_id() |
| 526 << " error=" << error.ToString(); | 527 << " error=" << error.ToString(); |
| 527 if (++fetcher_retries_ < kMaxFetcherRetries && IsTransientError(error)) { | 528 if (++fetcher_retries_ < kMaxFetcherRetries && IsTransientError(error)) { |
| 528 fetcher_backoff_.InformOfRequest(false); | 529 fetcher_backoff_.InformOfRequest(false); |
| 530 UMA_HISTOGRAM_ENUMERATION("OAuth2Login.MergeSessionRetry", |
| 531 error.state(), GoogleServiceAuthError::NUM_STATES); |
| 529 fetcher_timer_.Start( | 532 fetcher_timer_.Start( |
| 530 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), | 533 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), |
| 531 base::Bind(&SigninClient::DelayNetworkCall, | 534 base::Bind(&SigninClient::DelayNetworkCall, |
| 532 base::Unretained(signin_client_), | 535 base::Unretained(signin_client_), |
| 533 base::Bind( | 536 base::Bind( |
| 534 &GaiaCookieManagerService::StartFetchingMergeSession, | 537 &GaiaCookieManagerService::StartFetchingMergeSession, |
| 535 base::Unretained(this)))); | 538 base::Unretained(this)))); |
| 536 return; | 539 return; |
| 537 } | 540 } |
| 538 | 541 |
| 539 uber_token_ = std::string(); | 542 uber_token_ = std::string(); |
| 540 const std::string account_id = requests_.front().account_id(); | 543 const std::string account_id = requests_.front().account_id(); |
| 544 |
| 545 UMA_HISTOGRAM_ENUMERATION("OAuth2Login.MergeSessionFailure", |
| 546 error.state(), GoogleServiceAuthError::NUM_STATES); |
| 541 HandleNextRequest(); | 547 HandleNextRequest(); |
| 542 SignalComplete(account_id, error); | 548 SignalComplete(account_id, error); |
| 543 } | 549 } |
| 544 | 550 |
| 545 void GaiaCookieManagerService::OnListAccountsSuccess(const std::string& data) { | 551 void GaiaCookieManagerService::OnListAccountsSuccess(const std::string& data) { |
| 546 VLOG(1) << "ListAccounts successful"; | 552 VLOG(1) << "ListAccounts successful"; |
| 547 DCHECK(requests_.front().request_type() == | 553 DCHECK(requests_.front().request_type() == |
| 548 GaiaCookieRequestType::LIST_ACCOUNTS); | 554 GaiaCookieRequestType::LIST_ACCOUNTS); |
| 549 fetcher_backoff_.InformOfRequest(true); | 555 fetcher_backoff_.InformOfRequest(true); |
| 550 | 556 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 567 GoogleServiceAuthError(GoogleServiceAuthError::NONE))); | 573 GoogleServiceAuthError(GoogleServiceAuthError::NONE))); |
| 568 } | 574 } |
| 569 | 575 |
| 570 void GaiaCookieManagerService::OnListAccountsFailure( | 576 void GaiaCookieManagerService::OnListAccountsFailure( |
| 571 const GoogleServiceAuthError& error) { | 577 const GoogleServiceAuthError& error) { |
| 572 VLOG(1) << "ListAccounts failed"; | 578 VLOG(1) << "ListAccounts failed"; |
| 573 DCHECK(requests_.front().request_type() == | 579 DCHECK(requests_.front().request_type() == |
| 574 GaiaCookieRequestType::LIST_ACCOUNTS); | 580 GaiaCookieRequestType::LIST_ACCOUNTS); |
| 575 if (++fetcher_retries_ < kMaxFetcherRetries && IsTransientError(error)) { | 581 if (++fetcher_retries_ < kMaxFetcherRetries && IsTransientError(error)) { |
| 576 fetcher_backoff_.InformOfRequest(false); | 582 fetcher_backoff_.InformOfRequest(false); |
| 583 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsRetry", |
| 584 error.state(), GoogleServiceAuthError::NUM_STATES); |
| 577 fetcher_timer_.Start( | 585 fetcher_timer_.Start( |
| 578 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), | 586 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), |
| 579 base::Bind(&SigninClient::DelayNetworkCall, | 587 base::Bind(&SigninClient::DelayNetworkCall, |
| 580 base::Unretained(signin_client_), | 588 base::Unretained(signin_client_), |
| 581 base::Bind( | 589 base::Bind( |
| 582 &GaiaCookieManagerService::StartFetchingListAccounts, | 590 &GaiaCookieManagerService::StartFetchingListAccounts, |
| 583 base::Unretained(this)))); | 591 base::Unretained(this)))); |
| 584 return; | 592 return; |
| 585 } | 593 } |
| 586 | 594 |
| 595 UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsFailure", |
| 596 error.state(), GoogleServiceAuthError::NUM_STATES); |
| 587 FOR_EACH_OBSERVER(Observer, observer_list_, | 597 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 588 OnGaiaAccountsInCookieUpdated(listed_accounts_, error)); | 598 OnGaiaAccountsInCookieUpdated(listed_accounts_, error)); |
| 589 HandleNextRequest(); | 599 HandleNextRequest(); |
| 590 } | 600 } |
| 591 | 601 |
| 592 void GaiaCookieManagerService::StartFetchingUbertoken() { | 602 void GaiaCookieManagerService::StartFetchingUbertoken() { |
| 593 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" | 603 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" |
| 594 << requests_.front().account_id(); | 604 << requests_.front().account_id(); |
| 595 uber_token_fetcher_.reset( | 605 uber_token_fetcher_.reset( |
| 596 new UbertokenFetcher(token_service_, this, source_, | 606 new UbertokenFetcher(token_service_, this, source_, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 break; | 683 break; |
| 674 case GaiaCookieRequestType::LIST_ACCOUNTS: | 684 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 675 uber_token_fetcher_.reset(); | 685 uber_token_fetcher_.reset(); |
| 676 signin_client_->DelayNetworkCall( | 686 signin_client_->DelayNetworkCall( |
| 677 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, | 687 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, |
| 678 base::Unretained(this))); | 688 base::Unretained(this))); |
| 679 break; | 689 break; |
| 680 }; | 690 }; |
| 681 } | 691 } |
| 682 } | 692 } |
| OLD | NEW |