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

Unified Diff: google_apis/gaia/oauth2_access_token_fetcher.cc

Issue 22581003: Handling of multiple concurrent requests from different clients in OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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/oauth2_access_token_fetcher.cc
diff --git a/google_apis/gaia/oauth2_access_token_fetcher.cc b/google_apis/gaia/oauth2_access_token_fetcher.cc
index 456251f0134cf627ae70b4c3d73dc6d639b6b9b8..9fd46d73c134025578b16b1156c1d802221901aa 100644
--- a/google_apis/gaia/oauth2_access_token_fetcher.cc
+++ b/google_apis/gaia/oauth2_access_token_fetcher.cc
@@ -56,13 +56,14 @@ static GoogleServiceAuthError CreateAuthError(URLRequestStatus status) {
}
}
-static URLFetcher* CreateFetcher(URLRequestContextGetter* getter,
+static URLFetcher* CreateFetcher(int id,
+ URLRequestContextGetter* getter,
const GURL& url,
const std::string& body,
URLFetcherDelegate* delegate) {
bool empty_body = body.empty();
URLFetcher* result = net::URLFetcher::Create(
- 0, url,
+ id, url,
empty_body ? URLFetcher::GET : URLFetcher::POST,
delegate);
@@ -82,6 +83,8 @@ static URLFetcher* CreateFetcher(URLRequestContextGetter* getter,
}
} // namespace
+int OAuth2AccessTokenFetcher::last_fetcher_id_ = 0;
+
OAuth2AccessTokenFetcher::OAuth2AccessTokenFetcher(
OAuth2AccessTokenConsumer* consumer,
URLRequestContextGetter* getter)
@@ -110,6 +113,7 @@ void OAuth2AccessTokenFetcher::StartGetAccessToken() {
CHECK_EQ(INITIAL, state_);
state_ = GET_ACCESS_TOKEN_STARTED;
fetcher_.reset(CreateFetcher(
+ last_fetcher_id_++,
getter_,
MakeGetAccessTokenUrl(),
MakeGetAccessTokenBody(
@@ -231,3 +235,8 @@ bool OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
return dict->GetString(kAccessTokenKey, access_token) &&
dict->GetInteger(kExpiresInKey, expires_in);
}
+
+// static
+void OAuth2AccessTokenFetcher::ResetLastFetcherIdForTest() {
+ last_fetcher_id_ = 0;
+}

Powered by Google App Engine
This is Rietveld 408576698