 Chromium Code Reviews
 Chromium Code Reviews Issue 182573003:
  Extract OAuth2AccessTokenFetcher interface.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 182573003:
  Extract OAuth2AccessTokenFetcher interface.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: google_apis/gaia/oauth2_access_token_fetcher_impl.h | 
| diff --git a/google_apis/gaia/oauth2_access_token_fetcher.h b/google_apis/gaia/oauth2_access_token_fetcher_impl.h | 
| similarity index 64% | 
| copy from google_apis/gaia/oauth2_access_token_fetcher.h | 
| copy to google_apis/gaia/oauth2_access_token_fetcher_impl.h | 
| index 90805c0996353a28d5c118e1403ec6071946c657..3c0151e1dee9125697eb93b64cb59c8fcd7aab96 100644 | 
| --- a/google_apis/gaia/oauth2_access_token_fetcher.h | 
| +++ b/google_apis/gaia/oauth2_access_token_fetcher_impl.h | 
| @@ -2,8 +2,8 @@ | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
| -#ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 
| -#define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 
| +#ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_IMPL_H_ | 
| +#define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_IMPL_H_ | 
| #include <string> | 
| #include <vector> | 
| @@ -11,10 +11,11 @@ | 
| #include "base/gtest_prod_util.h" | 
| #include "base/memory/scoped_ptr.h" | 
| #include "google_apis/gaia/oauth2_access_token_consumer.h" | 
| +#include "google_apis/gaia/oauth2_access_token_fetcher.h" | 
| #include "net/url_request/url_fetcher_delegate.h" | 
| #include "url/gurl.h" | 
| -class OAuth2AccessTokenFetcherTest; | 
| +class OAuth2AccessTokenFetcherImplTest; | 
| namespace base { | 
| class Time; | 
| @@ -44,24 +45,20 @@ class URLRequestStatus; | 
| // | 
| // This class can handle one request at a time. To parallelize requests, | 
| // create multiple instances. | 
| -class OAuth2AccessTokenFetcher : public net::URLFetcherDelegate { | 
| +class OAuth2AccessTokenFetcherImpl : public OAuth2AccessTokenFetcher, | 
| + public net::URLFetcherDelegate { | 
| public: | 
| - OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer, | 
| - net::URLRequestContextGetter* getter); | 
| - virtual ~OAuth2AccessTokenFetcher(); | 
| - | 
| - // Starts the flow with the given parameters. | 
| - // |scopes| can be empty. If it is empty then the access token will have the | 
| - // same scope as the refresh token. If not empty, then access token will have | 
| - // the scopes specified. In this case, the access token will successfully be | 
| - // generated only if refresh token has login scope of a list of scopes that is | 
| - // a super-set of the specified scopes. | 
| + OAuth2AccessTokenFetcherImpl(net::URLRequestContextGetter* getter); | 
| 
Joao da Silva
2014/03/03 20:58:19
explicit
 
msarda
2014/03/04 12:37:13
Done.
 | 
| + virtual ~OAuth2AccessTokenFetcherImpl(); | 
| + | 
| + // Implementation of OAuth2AccessTokenFetcher | 
| virtual void Start(const std::string& client_id, | 
| const std::string& client_secret, | 
| const std::string& refresh_token, | 
| - const std::vector<std::string>& scopes); | 
| + const std::vector<std::string>& scopes, | 
| + OAuth2AccessTokenConsumer* consumer) OVERRIDE; | 
| 
Roger Tawa OOO till Jul 10th
2014/03/03 21:24:44
Why move |consumer| from ctor to here?
 
msarda
2014/03/04 12:37:13
I did this to have a sane interface for OAuth2Acce
 
Roger Tawa OOO till Jul 10th
2014/03/04 15:20:02
I think you can keep the |consumer| in the ctor of
 
msarda
2014/03/04 16:13:54
Done.
 | 
| - void CancelRequest(); | 
| + virtual void CancelRequest() OVERRIDE; | 
| // Implementation of net::URLFetcherDelegate | 
| virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 
| @@ -91,17 +88,15 @@ class OAuth2AccessTokenFetcher : public net::URLFetcherDelegate { | 
| const std::string& refresh_token, | 
| const std::vector<std::string>& scopes); | 
| - static bool ParseGetAccessTokenSuccessResponse( | 
| - const net::URLFetcher* source, | 
| - std::string* access_token, | 
| - int* expires_in); | 
| + static bool ParseGetAccessTokenSuccessResponse(const net::URLFetcher* source, | 
| + std::string* access_token, | 
| + int* expires_in); | 
| - static bool ParseGetAccessTokenFailureResponse( | 
| - const net::URLFetcher* source, | 
| - std::string* error); | 
| + static bool ParseGetAccessTokenFailureResponse(const net::URLFetcher* source, | 
| + std::string* error); | 
| // State that is set during construction. | 
| - OAuth2AccessTokenConsumer* const consumer_; | 
| + OAuth2AccessTokenConsumer* consumer_; | 
| net::URLRequestContextGetter* const getter_; | 
| State state_; | 
| @@ -112,13 +107,13 @@ class OAuth2AccessTokenFetcher : public net::URLFetcherDelegate { | 
| std::string refresh_token_; | 
| std::vector<std::string> scopes_; | 
| - friend class OAuth2AccessTokenFetcherTest; | 
| - FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 
| + friend class OAuth2AccessTokenFetcherImplTest; | 
| + FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherImplTest, | 
| ParseGetAccessTokenResponse); | 
| - FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 
| + FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherImplTest, | 
| MakeGetAccessTokenBody); | 
| - DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); | 
| + DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcherImpl); | 
| }; | 
| -#endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 
| +#endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_IMPL_H_ |