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

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

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build 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
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 content::URLFetcherDelegate
63 virtual void OnURLFetchComplete(const content::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
73 // Helper methods for the flow. 73 // Helper methods for the flow.
74 void StartGetAccessToken(); 74 void StartGetAccessToken();
75 void EndGetAccessToken(const content::URLFetcher* source); 75 void EndGetAccessToken(const net::URLFetcher* source);
76 76
77 // Helper mehtods for reporting back results. 77 // Helper mehtods for reporting back results.
78 void OnGetTokenSuccess(const std::string& access_token); 78 void OnGetTokenSuccess(const std::string& access_token);
79 void OnGetTokenFailure(const GoogleServiceAuthError& error); 79 void OnGetTokenFailure(const GoogleServiceAuthError& error);
80 80
81 // Other helpers. 81 // Other helpers.
82 static GURL MakeGetAccessTokenUrl(); 82 static GURL MakeGetAccessTokenUrl();
83 static std::string MakeGetAccessTokenBody( 83 static std::string MakeGetAccessTokenBody(
84 const std::string& client_id, 84 const std::string& client_id,
85 const std::string& client_secret, 85 const std::string& client_secret,
86 const std::string& refresh_token, 86 const std::string& refresh_token,
87 const std::vector<std::string>& scopes); 87 const std::vector<std::string>& scopes);
88 static bool ParseGetAccessTokenResponse(const content::URLFetcher* source, 88 static bool ParseGetAccessTokenResponse(const net::URLFetcher* source,
89 std::string* access_token); 89 std::string* access_token);
90 90
91 // State that is set during construction. 91 // State that is set during construction.
92 OAuth2AccessTokenConsumer* const consumer_; 92 OAuth2AccessTokenConsumer* const consumer_;
93 net::URLRequestContextGetter* const getter_; 93 net::URLRequestContextGetter* const getter_;
94 State state_; 94 State state_;
95 95
96 // While a fetch is in progress. 96 // While a fetch is in progress.
97 scoped_ptr<content::URLFetcher> fetcher_; 97 scoped_ptr<content::URLFetcher> fetcher_;
98 std::string client_id_; 98 std::string client_id_;
99 std::string client_secret_; 99 std::string client_secret_;
100 std::string refresh_token_; 100 std::string refresh_token_;
101 std::vector<std::string> scopes_; 101 std::vector<std::string> scopes_;
102 102
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
« no previous file with comments | « chrome/common/net/gaia/gaia_oauth_client.cc ('k') | chrome/common/net/gaia/oauth2_access_token_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698