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

Side by Side Diff: google_apis/gaia/oauth2_access_token_fetcher.h

Issue 23767004: Revert "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, 3 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 #ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
6 #define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 6 #define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "google_apis/gaia/oauth2_access_token_consumer.h" 13 #include "google_apis/gaia/oauth2_access_token_consumer.h"
14 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 class OAuth2AccessTokenFetcherTest; 17 class OAuth2AccessTokenFetcherTest;
18 18
19 namespace base { 19 namespace base {
20 class Time; 20 class Time;
21 } 21 }
22 22
23 namespace net { 23 namespace net {
24 class URLFetcher; 24 class URLFetcher;
25 class URLRequestContextGetter; 25 class URLRequestContextGetter;
26 class URLRequestStatus; 26 class URLRequestStatus;
27 } 27 }
28 28
29 namespace policy {
30 class UserPolicySigninServiceTest;
31 }
32
33 // Abstracts the details to get OAuth2 access token token from 29 // Abstracts the details to get OAuth2 access token token from
34 // OAuth2 refresh token. 30 // OAuth2 refresh token.
35 // See "Using the Refresh Token" section in: 31 // See "Using the Refresh Token" section in:
36 // http://code.google.com/apis/accounts/docs/OAuth2WebServer.html 32 // http://code.google.com/apis/accounts/docs/OAuth2WebServer.html
37 // 33 //
38 // This class should be used on a single thread, but it can be whichever thread 34 // This class should be used on a single thread, but it can be whichever thread
39 // that you like. 35 // that you like.
40 // Also, do not reuse the same instance. Once Start() is called, the instance 36 // Also, do not reuse the same instance. Once Start() is called, the instance
41 // should not be reused. 37 // should not be reused.
42 // 38 //
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 static GURL MakeGetAccessTokenUrl(); 87 static GURL MakeGetAccessTokenUrl();
92 static std::string MakeGetAccessTokenBody( 88 static std::string MakeGetAccessTokenBody(
93 const std::string& client_id, 89 const std::string& client_id,
94 const std::string& client_secret, 90 const std::string& client_secret,
95 const std::string& refresh_token, 91 const std::string& refresh_token,
96 const std::vector<std::string>& scopes); 92 const std::vector<std::string>& scopes);
97 static bool ParseGetAccessTokenResponse(const net::URLFetcher* source, 93 static bool ParseGetAccessTokenResponse(const net::URLFetcher* source,
98 std::string* access_token, 94 std::string* access_token,
99 int* expires_in); 95 int* expires_in);
100 96
101 // Resets |last_fetcher_id_| to 0.
102 static void ResetLastFetcherIdForTest();
103
104 // State that is set during construction. 97 // State that is set during construction.
105 OAuth2AccessTokenConsumer* const consumer_; 98 OAuth2AccessTokenConsumer* const consumer_;
106 net::URLRequestContextGetter* const getter_; 99 net::URLRequestContextGetter* const getter_;
107 State state_; 100 State state_;
108 101
109 // While a fetch is in progress. 102 // While a fetch is in progress.
110 scoped_ptr<net::URLFetcher> fetcher_; 103 scoped_ptr<net::URLFetcher> fetcher_;
111 std::string client_id_; 104 std::string client_id_;
112 std::string client_secret_; 105 std::string client_secret_;
113 std::string refresh_token_; 106 std::string refresh_token_;
114 std::vector<std::string> scopes_; 107 std::vector<std::string> scopes_;
115 108
116 // The last fetcher id.
117 static int last_fetcher_id_;
118
119 friend class OAuth2AccessTokenFetcherTest; 109 friend class OAuth2AccessTokenFetcherTest;
120 friend class OAuth2TokenServiceTest;
121 friend class policy::UserPolicySigninServiceTest;
122 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, 110 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest,
123 ParseGetAccessTokenResponse); 111 ParseGetAccessTokenResponse);
124 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, 112 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest,
125 MakeGetAccessTokenBody); 113 MakeGetAccessTokenBody);
126 114
127 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); 115 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher);
128 }; 116 };
129 117
130 #endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 118 #endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.cc ('k') | google_apis/gaia/oauth2_access_token_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698