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

Unified Diff: google_apis/gaia/fake_oauth2_token_service_delegate.cc

Issue 1267843003: Fix reconcilor loop when the primary account is in an auth error state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/fake_oauth2_token_service_delegate.cc
diff --git a/google_apis/gaia/fake_oauth2_token_service_delegate.cc b/google_apis/gaia/fake_oauth2_token_service_delegate.cc
index 580025ceeb07fa2b98aacc4c502be42177bae27b..1ce991cb20a81d17dd42a3e4f1e5b7a611f4e5d5 100644
--- a/google_apis/gaia/fake_oauth2_token_service_delegate.cc
+++ b/google_apis/gaia/fake_oauth2_token_service_delegate.cc
@@ -5,6 +5,11 @@
#include "google_apis/gaia/fake_oauth2_token_service_delegate.h"
#include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
+FakeOAuth2TokenServiceDelegate::AccountInfo::AccountInfo(
+ const std::string& refresh_token)
+ : refresh_token(refresh_token),
+ error(GoogleServiceAuthError::NONE) {}
+
FakeOAuth2TokenServiceDelegate::FakeOAuth2TokenServiceDelegate(
net::URLRequestContextGetter* request_context)
: request_context_(request_context) {
@@ -18,11 +23,10 @@ FakeOAuth2TokenServiceDelegate::CreateAccessTokenFetcher(
const std::string& account_id,
net::URLRequestContextGetter* getter,
OAuth2AccessTokenConsumer* consumer) {
- std::map<std::string, std::string>::const_iterator it =
- refresh_tokens_.find(account_id);
+ AccountInfoMap::const_iterator it = refresh_tokens_.find(account_id);
DCHECK(it != refresh_tokens_.end());
- std::string refresh_token(it->second);
- return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token);
+ return new OAuth2AccessTokenFetcherImpl(consumer, getter,
+ it->second->refresh_token);
}
bool FakeOAuth2TokenServiceDelegate::RefreshTokenIsAvailable(
@@ -30,19 +34,24 @@ bool FakeOAuth2TokenServiceDelegate::RefreshTokenIsAvailable(
return !GetRefreshToken(account_id).empty();
}
+bool FakeOAuth2TokenServiceDelegate::RefreshTokenHasError(
+ const std::string& account_id) const {
+ auto it = refresh_tokens_.find(account_id);
+ // TODO(rogerta): should we distinguish between transient and persistent?
+ return it == refresh_tokens_.end() ? false : IsError(it->second->error);
+}
+
std::string FakeOAuth2TokenServiceDelegate::GetRefreshToken(
const std::string& account_id) const {
- std::map<std::string, std::string>::const_iterator it =
- refresh_tokens_.find(account_id);
+ AccountInfoMap::const_iterator it = refresh_tokens_.find(account_id);
if (it != refresh_tokens_.end())
- return it->second;
+ return it->second->refresh_token;
return std::string();
}
std::vector<std::string> FakeOAuth2TokenServiceDelegate::GetAccounts() {
std::vector<std::string> account_ids;
- for (std::map<std::string, std::string>::const_iterator iter =
- refresh_tokens_.begin();
+ for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin();
iter != refresh_tokens_.end(); ++iter) {
account_ids.push_back(iter->first);
}
@@ -76,7 +85,7 @@ void FakeOAuth2TokenServiceDelegate::IssueRefreshTokenForUser(
refresh_tokens_.erase(account_id);
FireRefreshTokenRevoked(account_id);
} else {
- refresh_tokens_[account_id] = token;
+ refresh_tokens_[account_id].reset(new AccountInfo(token));
FireRefreshTokenAvailable(account_id);
// TODO(atwilson): Maybe we should also call FireRefreshTokensLoaded() here?
}
@@ -91,3 +100,11 @@ net::URLRequestContextGetter*
FakeOAuth2TokenServiceDelegate::GetRequestContext() const {
return request_context_.get();
}
+
+void FakeOAuth2TokenServiceDelegate::SetLastErrorForAccount(
+ const std::string& account_id,
+ const GoogleServiceAuthError& error) {
+ auto it = refresh_tokens_.find(account_id);
+ DCHECK(it != refresh_tokens_.end());
+ it->second->error = error;
+}
« no previous file with comments | « google_apis/gaia/fake_oauth2_token_service_delegate.h ('k') | google_apis/gaia/oauth2_token_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698