diff options
11 files changed, 79 insertions, 0 deletions
diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc index 36b3dc3..bd8bcd6 100644 --- a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc +++ b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc @@ -519,3 +519,8 @@ void MutableProfileOAuth2TokenServiceDelegate::OnNetworkChanged( // by a previous lack of network connectivity don't prevent new requests. backoff_entry_.Reset(); } + +const net::BackoffEntry* + MutableProfileOAuth2TokenServiceDelegate::BackoffEntry() const { + return &backoff_entry_; +} diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h index 1e6c4db..0c4faea 100644 --- a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h +++ b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h @@ -58,6 +58,9 @@ class MutableProfileOAuth2TokenServiceDelegate void OnNetworkChanged(net::NetworkChangeNotifier::ConnectionType type) override; + // Overridden from OAuth2TokenServiceDelegate. + const net::BackoffEntry* BackoffEntry() const override; + private: friend class MutableProfileOAuth2TokenServiceDelegateTest; diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc index 7b992fd..7e8c81b 100644 --- a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc +++ b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc @@ -415,6 +415,9 @@ TEST_F(MutableProfileOAuth2TokenServiceDelegateTest, RetryBackoff) { base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, access_token_success_count_); EXPECT_EQ(1, access_token_failure_count_); + // Expect a positive backoff time. + EXPECT_GT(oauth2_service_delegate_->backoff_entry_.GetTimeUntilRelease(), + TimeDelta()); // Pretend that backoff has expired and try again. oauth2_service_delegate_->backoff_entry_.SetCustomReleaseTime( diff --git a/components/signin/core/browser/about_signin_internals.cc b/components/signin/core/browser/about_signin_internals.cc index 7f3a6a1..4bec52f 100644 --- a/components/signin/core/browser/about_signin_internals.cc +++ b/components/signin/core/browser/about_signin_internals.cc @@ -21,6 +21,7 @@ #include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/common/profile_management_switches.h" #include "components/signin/core/common/signin_switches.h" +#include "net/base/backoff_entry.h" using base::Time; using namespace signin_internals_util; @@ -270,6 +271,7 @@ void AboutSigninInternals::NotifyObservers() { signin_manager_, signin_error_controller_, token_service_, + cookie_manager_service_, product_version); // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is @@ -288,6 +290,7 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() { signin_manager_, signin_error_controller_, token_service_, + cookie_manager_service_, client_->GetProductVersion()).Pass(); } @@ -498,6 +501,7 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( SigninManagerBase* signin_manager, SigninErrorController* signin_error_controller, ProfileOAuth2TokenService* token_service, + GaiaCookieManagerService* cookie_manager_service_, const std::string& product_version) { // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is // fixed. @@ -574,6 +578,42 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( timed_signin_fields[i - TIMED_FIELDS_BEGIN].first, timed_signin_fields[i - TIMED_FIELDS_BEGIN].second); } + + const net::BackoffEntry* cookie_manager_backoff_entry = + cookie_manager_service_->GetBackoffEntry(); + + if (cookie_manager_backoff_entry->ShouldRejectRequest()) { + Time next_retry_time = Time::NowFromSystemTime() + + cookie_manager_backoff_entry->GetTimeUntilRelease(); + + std::string next_retry_time_as_str = + base::UTF16ToUTF8( + base::TimeFormatShortDateAndTime(next_retry_time)); + + AddSectionEntry(detailed_info, + "Cookie Manager Next Retry", + next_retry_time_as_str, + ""); + } + + const net::BackoffEntry* token_service_backoff_entry = token_service-> + GetDelegateBackoffEntry(); + + if (token_service_backoff_entry && + token_service_backoff_entry->ShouldRejectRequest()) { + Time next_retry_time = Time::NowFromSystemTime() + + token_service_backoff_entry->GetTimeUntilRelease(); + + std::string next_retry_time_as_str = + base::UTF16ToUTF8( + base::TimeFormatShortDateAndTime(next_retry_time)); + + AddSectionEntry(detailed_info, + "Token Service Next Retry", + next_retry_time_as_str, + ""); + } + #endif // !defined(OS_CHROMEOS) // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is diff --git a/components/signin/core/browser/about_signin_internals.h b/components/signin/core/browser/about_signin_internals.h index 7e0dca5..10fb002 100644 --- a/components/signin/core/browser/about_signin_internals.h +++ b/components/signin/core/browser/about_signin_internals.h @@ -161,6 +161,7 @@ class AboutSigninInternals SigninManagerBase* signin_manager, SigninErrorController* signin_error_controller, ProfileOAuth2TokenService* token_service, + GaiaCookieManagerService* cookie_manager_service_, const std::string& product_version); }; diff --git a/components/signin/core/browser/gaia_cookie_manager_service.h b/components/signin/core/browser/gaia_cookie_manager_service.h index d3cf34e..c50fb1b 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service.h +++ b/components/signin/core/browser/gaia_cookie_manager_service.h @@ -206,6 +206,11 @@ class GaiaCookieManagerService : public KeyedService, list_accounts_stale_ = stale; } + // Returns a non-NULL pointer to its instance of net::BackoffEntry + const net::BackoffEntry* GetBackoffEntry() { + return &fetcher_backoff_; + } + private: net::URLRequestContextGetter* request_context() { return signin_client_->GetURLRequestContext(); diff --git a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc index e2fa05d8..218dcb5 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc +++ b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc @@ -242,6 +242,8 @@ TEST_F(GaiaCookieManagerServiceTest, MergeSessionRetriedTwice) { SimulateMergeSessionFailure(&helper, canceled()); DCHECK(helper.is_running()); // Transient error incurs a retry after 1 second. + EXPECT_LT(helper.GetBackoffEntry()->GetTimeUntilRelease(), + base::TimeDelta::FromMilliseconds(1100)); base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(1100)); @@ -249,6 +251,8 @@ TEST_F(GaiaCookieManagerServiceTest, MergeSessionRetriedTwice) { SimulateMergeSessionFailure(&helper, canceled()); DCHECK(helper.is_running()); // Next transient error incurs a retry after 3 seconds. + EXPECT_LT(helper.GetBackoffEntry()->GetTimeUntilRelease(), + base::TimeDelta::FromMilliseconds(3100)); base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromMilliseconds(3100)); diff --git a/components/signin/core/browser/profile_oauth2_token_service.cc b/components/signin/core/browser/profile_oauth2_token_service.cc index e55c2cc..b7fd8d0 100644 --- a/components/signin/core/browser/profile_oauth2_token_service.cc +++ b/components/signin/core/browser/profile_oauth2_token_service.cc @@ -46,3 +46,7 @@ void ProfileOAuth2TokenService::RevokeCredentials( const std::string& account_id) { GetDelegate()->RevokeCredentials(account_id); } + +const net::BackoffEntry* ProfileOAuth2TokenService::GetDelegateBackoffEntry() { + return GetDelegate()->BackoffEntry(); +} diff --git a/components/signin/core/browser/profile_oauth2_token_service.h b/components/signin/core/browser/profile_oauth2_token_service.h index ab290e3..6fb0004 100644 --- a/components/signin/core/browser/profile_oauth2_token_service.h +++ b/components/signin/core/browser/profile_oauth2_token_service.h @@ -11,6 +11,7 @@ #include "components/keyed_service/core/keyed_service.h" #include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gaia/oauth2_token_service_delegate.h" +#include "net/base/backoff_entry.h" // ProfileOAuth2TokenService is a KeyedService that retrieves // OAuth2 access tokens for a given set of scopes using the OAuth2 login @@ -54,6 +55,10 @@ class ProfileOAuth2TokenService : public OAuth2TokenService, virtual void RevokeCredentials(const std::string& account_id); + // Returns a pointer to its instance of net::BackoffEntry or nullptr if there + // is no such instance. + const net::BackoffEntry* GetDelegateBackoffEntry(); + private: void OnRefreshTokenAvailable(const std::string& account_id) override; void OnRefreshTokenRevoked(const std::string& account_id) override; diff --git a/google_apis/gaia/oauth2_token_service_delegate.cc b/google_apis/gaia/oauth2_token_service_delegate.cc index 3c5f75b..0898c7a 100644 --- a/google_apis/gaia/oauth2_token_service_delegate.cc +++ b/google_apis/gaia/oauth2_token_service_delegate.cc @@ -113,3 +113,7 @@ bool OAuth2TokenServiceDelegate::RefreshTokenHasError( std::vector<std::string> OAuth2TokenServiceDelegate::GetAccounts() { return std::vector<std::string>(); } + +const net::BackoffEntry* OAuth2TokenServiceDelegate::BackoffEntry() const { + return nullptr; +} diff --git a/google_apis/gaia/oauth2_token_service_delegate.h b/google_apis/gaia/oauth2_token_service_delegate.h index 24bf063..b727633 100644 --- a/google_apis/gaia/oauth2_token_service_delegate.h +++ b/google_apis/gaia/oauth2_token_service_delegate.h @@ -8,6 +8,7 @@ #include "base/observer_list.h" #include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/oauth2_token_service.h" +#include "net/base/backoff_entry.h" namespace net { class URLRequestContextGetter; @@ -54,6 +55,10 @@ class OAuth2TokenServiceDelegate { void AddObserver(OAuth2TokenService::Observer* observer); void RemoveObserver(OAuth2TokenService::Observer* observer); + // Returns a pointer to its instance of net::BackoffEntry if it has one, or + // a nullptr otherwise. + virtual const net::BackoffEntry* BackoffEntry() const; + protected: // Called by subclasses to notify observers. virtual void FireRefreshTokenAvailable(const std::string& account_id); |