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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "google_apis/gaia/oauth2_access_token_fetcher.h" 5 #include "google_apis/gaia/oauth2_access_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DLOG(WARNING) << "Could not reach Google Accounts servers: errno " 53 DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
54 << status.error(); 54 << status.error();
55 return GoogleServiceAuthError::FromConnectionError(status.error()); 55 return GoogleServiceAuthError::FromConnectionError(status.error());
56 } 56 }
57 } 57 }
58 58
59 static URLFetcher* CreateFetcher(URLRequestContextGetter* getter, 59 static URLFetcher* CreateFetcher(URLRequestContextGetter* getter,
60 const GURL& url, 60 const GURL& url,
61 const std::string& body, 61 const std::string& body,
62 URLFetcherDelegate* delegate) { 62 URLFetcherDelegate* delegate) {
63 static int fetcher_index = 0;
63 bool empty_body = body.empty(); 64 bool empty_body = body.empty();
64 URLFetcher* result = net::URLFetcher::Create( 65 URLFetcher* result = net::URLFetcher::Create(
65 0, url, 66 fetcher_index++, url,
66 empty_body ? URLFetcher::GET : URLFetcher::POST, 67 empty_body ? URLFetcher::GET : URLFetcher::POST,
67 delegate); 68 delegate);
68 69
69 result->SetRequestContext(getter); 70 result->SetRequestContext(getter);
70 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 71 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
71 net::LOAD_DO_NOT_SAVE_COOKIES); 72 net::LOAD_DO_NOT_SAVE_COOKIES);
72 // Fetchers are sometimes cancelled because a network change was detected, 73 // Fetchers are sometimes cancelled because a network change was detected,
73 // especially at startup and after sign-in on ChromeOS. Retrying once should 74 // especially at startup and after sign-in on ChromeOS. Retrying once should
74 // be enough in those cases; let the fetcher retry up to 3 times just in case. 75 // be enough in those cases; let the fetcher retry up to 3 times just in case.
75 // http://crbug.com/163710 76 // http://crbug.com/163710
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 source->GetResponseAsString(&data); 225 source->GetResponseAsString(&data);
225 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); 226 scoped_ptr<base::Value> value(base::JSONReader::Read(data));
226 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) 227 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY)
227 return false; 228 return false;
228 229
229 base::DictionaryValue* dict = 230 base::DictionaryValue* dict =
230 static_cast<base::DictionaryValue*>(value.get()); 231 static_cast<base::DictionaryValue*>(value.get());
231 return dict->GetString(kAccessTokenKey, access_token) && 232 return dict->GetString(kAccessTokenKey, access_token) &&
232 dict->GetInteger(kExpiresInKey, expires_in); 233 dict->GetInteger(kExpiresInKey, expires_in);
233 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698