Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_ | |
| 7 | |
| 8 #include <string> | |
|
Joao da Silva
2013/01/11 16:45:07
Not needed
zel
2013/01/11 19:51:16
Done.
| |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "google_apis/gaia/gaia_auth_consumer.h" | |
| 15 #include "google_apis/gaia/gaia_auth_fetcher.h" | |
| 16 | |
| 17 class Profile; | |
|
Joao da Silva
2013/01/11 16:45:07
Not needed
zel
2013/01/11 19:51:16
Done.
| |
| 18 | |
| 19 namespace chromeos { | |
| 20 | |
| 21 // OAuth2TokenFetcher is used to convert authenticated cookie jar from the | |
| 22 // authentication profile into OAuth2 tokens and GAIA credentials that will be | |
| 23 // used to kick off other token retrieval tasks (i.e. TokenService). | |
| 24 class OAuth2TokenFetcher : public base::SupportsWeakPtr<OAuth2TokenFetcher>, | |
| 25 public GaiaAuthConsumer { | |
| 26 public: | |
| 27 class Delegate { | |
| 28 public: | |
| 29 virtual ~Delegate() {} | |
| 30 virtual void OnOAuth2TokenAvailable( | |
| 31 const GaiaAuthConsumer::ClientLoginResult& gaia_credentials, | |
| 32 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) = 0; | |
| 33 virtual void OnOAuth2TokenFetchFailed() = 0; | |
| 34 }; | |
| 35 | |
| 36 OAuth2TokenFetcher(OAuth2TokenFetcher::Delegate* delegate, | |
| 37 net::URLRequestContextGetter* context_getter); | |
|
Joao da Silva
2013/01/11 16:45:07
Needs forward decl
zel
2013/01/11 19:51:16
Done.
| |
| 38 virtual ~OAuth2TokenFetcher(); | |
| 39 | |
| 40 void Start(); | |
| 41 | |
| 42 private: | |
| 43 // Starts OAuthLogin call. | |
| 44 void StartOAuthLogin(); | |
| 45 // Decides how to proceed on GAIA |error|. If the error looks temporary, | |
| 46 // retries |task| until max retry count is reached. | |
| 47 // If retry count runs out, or error condition is unrecoverable, it calls | |
| 48 // Delegate::OnOAuth2TokenFetchFailed(). | |
| 49 void RetryOnError(const GoogleServiceAuthError& error, | |
| 50 const base::Closure& task); | |
| 51 | |
| 52 // GaiaAuthConsumer overrides. | |
| 53 virtual void OnClientOAuthSuccess( | |
| 54 const GaiaAuthConsumer::ClientOAuthResult& result) OVERRIDE; | |
| 55 virtual void OnClientOAuthFailure( | |
| 56 const GoogleServiceAuthError& error) OVERRIDE; | |
| 57 virtual void OnClientLoginSuccess( | |
| 58 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; | |
| 59 virtual void OnClientLoginFailure( | |
| 60 const GoogleServiceAuthError& error) OVERRIDE; | |
| 61 | |
| 62 OAuth2TokenFetcher::Delegate* delegate_; | |
| 63 GaiaAuthConsumer::ClientOAuthResult oauth_tokens_; | |
| 64 GaiaAuthFetcher auth_fetcher_; | |
| 65 | |
| 66 // The retry counter. Increment this only when failure happened. | |
| 67 int retry_count_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenFetcher); | |
| 70 }; | |
| 71 | |
| 72 } // namespace chromeos | |
| 73 | |
| 74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_TOKEN_FETCHER_H_ | |
| OLD | NEW |