OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 GET_ACCESS_TOKEN_STARTED, | 58 GET_ACCESS_TOKEN_STARTED, |
59 GET_ACCESS_TOKEN_DONE, | 59 GET_ACCESS_TOKEN_DONE, |
60 ERROR_STATE, | 60 ERROR_STATE, |
61 }; | 61 }; |
62 | 62 |
63 // Helper methods for the flow. | 63 // Helper methods for the flow. |
64 void StartGetAccessToken(); | 64 void StartGetAccessToken(); |
65 void EndGetAccessToken(const content::URLFetcher* source); | 65 void EndGetAccessToken(const content::URLFetcher* source); |
66 | 66 |
67 // Helper mehtods for reporting back results. | 67 // Helper mehtods for reporting back results. |
68 void ReportSuccess(const std::string& access_token); | 68 void OnGetTokenSuccess(const std::string& access_token); |
69 void ReportFailure(GoogleServiceAuthError error); | 69 void OnGetTokenFailure(GoogleServiceAuthError error); |
70 | 70 |
71 // Other helpers. | 71 // Other helpers. |
72 static GURL MakeGetAccessTokenUrl(); | 72 static GURL MakeGetAccessTokenUrl(); |
73 static std::string MakeGetAccessTokenBody(const std::string& refresh_token); | 73 static std::string MakeGetAccessTokenBody(const std::string& refresh_token); |
74 static bool ParseGetAccessTokenResponse(const content::URLFetcher* source, | 74 static bool ParseGetAccessTokenResponse(const content::URLFetcher* source, |
75 std::string* access_token); | 75 std::string* access_token); |
76 | 76 |
77 // State that is set during construction. | 77 // State that is set during construction. |
78 OAuth2AccessTokenConsumer* const consumer_; | 78 OAuth2AccessTokenConsumer* const consumer_; |
79 net::URLRequestContextGetter* const getter_; | 79 net::URLRequestContextGetter* const getter_; |
80 std::string source_; | 80 std::string source_; |
81 State state_; | 81 State state_; |
82 | 82 |
83 // While a fetch is in progress. | 83 // While a fetch is in progress. |
84 scoped_ptr<content::URLFetcher> fetcher_; | 84 scoped_ptr<content::URLFetcher> fetcher_; |
85 std::string refresh_token_; | 85 std::string refresh_token_; |
86 | 86 |
87 friend class OAuth2AccessTokenFetcherTest; | 87 friend class OAuth2AccessTokenFetcherTest; |
88 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 88 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, |
89 ParseGetAccessTokenResponse); | 89 ParseGetAccessTokenResponse); |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); | 91 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); |
92 }; | 92 }; |
93 | 93 |
94 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 94 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
OLD | NEW |