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

Side by Side Diff: chrome/common/net/gaia/oauth2_access_token_fetcher.h

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
6 #define CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 6 #define CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
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 "chrome/common/net/gaia/oauth2_access_token_consumer.h" 13 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h"
14 #include "content/public/common/url_fetcher.h" 14 #include "content/public/common/url_fetcher.h"
15 #include "content/public/common/url_fetcher_delegate.h"
16 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/url_request/url_fetcher_delegate.h"
17 17
18 class OAuth2AccessTokenFetcherTest; 18 class OAuth2AccessTokenFetcherTest;
19 19
20 namespace net { 20 namespace net {
21 class URLRequestContextGetter; 21 class URLRequestContextGetter;
22 class URLRequestStatus; 22 class URLRequestStatus;
23 } 23 }
24 24
25 // Abstracts the details to get OAuth2 access token token from 25 // Abstracts the details to get OAuth2 access token token from
26 // OAuth2 refresh token. 26 // OAuth2 refresh token.
27 // See "Using the Refresh Token" section in: 27 // See "Using the Refresh Token" section in:
28 // http://code.google.com/apis/accounts/docs/OAuth2WebServer.html 28 // http://code.google.com/apis/accounts/docs/OAuth2WebServer.html
29 // 29 //
30 // This class should be used on a single thread, but it can be whichever thread 30 // This class should be used on a single thread, but it can be whichever thread
31 // that you like. 31 // that you like.
32 // Also, do not reuse the same instance. Once Start() is called, the instance 32 // Also, do not reuse the same instance. Once Start() is called, the instance
33 // should not be reused. 33 // should not be reused.
34 // 34 //
35 // Usage: 35 // Usage:
36 // * Create an instance with a consumer. 36 // * Create an instance with a consumer.
37 // * Call Start() 37 // * Call Start()
38 // * The consumer passed in the constructor will be called on the same 38 // * The consumer passed in the constructor will be called on the same
39 // thread Start was called with the results. 39 // thread Start was called with the results.
40 // 40 //
41 // This class can handle one request at a time. To parallelize requests, 41 // This class can handle one request at a time. To parallelize requests,
42 // create multiple instances. 42 // create multiple instances.
43 class OAuth2AccessTokenFetcher : public content::URLFetcherDelegate { 43 class OAuth2AccessTokenFetcher : public net::URLFetcherDelegate {
44 public: 44 public:
45 OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer, 45 OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer,
46 net::URLRequestContextGetter* getter); 46 net::URLRequestContextGetter* getter);
47 virtual ~OAuth2AccessTokenFetcher(); 47 virtual ~OAuth2AccessTokenFetcher();
48 48
49 // Starts the flow with the given parameters. 49 // Starts the flow with the given parameters.
50 // |scopes| can be empty. If it is empty then the access token will have the 50 // |scopes| can be empty. If it is empty then the access token will have the
51 // same scope as the refresh token. If not empty, then access token will have 51 // same scope as the refresh token. If not empty, then access token will have
52 // the scopes specified. In this case, the access token will successfully be 52 // the scopes specified. In this case, the access token will successfully be
53 // generated only if refresh token has login scope of a list of scopes that is 53 // generated only if refresh token has login scope of a list of scopes that is
54 // a super-set of the specified scopes. 54 // a super-set of the specified scopes.
55 virtual void Start(const std::string& client_id, 55 virtual void Start(const std::string& client_id,
56 const std::string& client_secret, 56 const std::string& client_secret,
57 const std::string& refresh_token, 57 const std::string& refresh_token,
58 const std::vector<std::string>& scopes); 58 const std::vector<std::string>& scopes);
59 59
60 void CancelRequest(); 60 void CancelRequest();
61 61
62 // Implementation of content::URLFetcherDelegate 62 // Implementation of net::URLFetcherDelegate
63 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 63 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
64 64
65 private: 65 private:
66 enum State { 66 enum State {
67 INITIAL, 67 INITIAL,
68 GET_ACCESS_TOKEN_STARTED, 68 GET_ACCESS_TOKEN_STARTED,
69 GET_ACCESS_TOKEN_DONE, 69 GET_ACCESS_TOKEN_DONE,
70 ERROR_STATE, 70 ERROR_STATE,
71 }; 71 };
72 72
(...skipping 30 matching lines...) Expand all
103 friend class OAuth2AccessTokenFetcherTest; 103 friend class OAuth2AccessTokenFetcherTest;
104 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, 104 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest,
105 ParseGetAccessTokenResponse); 105 ParseGetAccessTokenResponse);
106 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, 106 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest,
107 MakeGetAccessTokenBody); 107 MakeGetAccessTokenBody);
108 108
109 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); 109 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher);
110 }; 110 };
111 111
112 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ 112 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698