OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_ACCOUNT_TOKEN_FETCHER_IMPL_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_ACCOUNT_TOKEN_FETCHER_IMPL_H |
| 7 |
| 8 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" |
| 9 #include "google_apis/gaia/oauth2_token_service.h" |
| 10 |
| 11 namespace proximity_auth { |
| 12 |
| 13 // Implementation of CryptAuthAccessTokenFetcher fetching an access token for a |
| 14 // given account using the provided OAuth2TokenService. |
| 15 class CryptAuthAccountTokenFetcher : public CryptAuthAccessTokenFetcher, |
| 16 public OAuth2TokenService::Consumer { |
| 17 public: |
| 18 // |token_service| is not owned, and must outlive this object. |
| 19 CryptAuthAccountTokenFetcher(OAuth2TokenService* token_service, |
| 20 const std::string& account_id); |
| 21 virtual ~CryptAuthAccountTokenFetcher(); |
| 22 |
| 23 // CryptAuthAccessTokenFetcher: |
| 24 void FetchAccessToken(const AccessTokenCallback& callback) override; |
| 25 |
| 26 private: |
| 27 // OAuth2TokenService::Consumer: |
| 28 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 29 const std::string& access_token, |
| 30 const base::Time& expiration_time) override; |
| 31 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 32 const GoogleServiceAuthError& error) override; |
| 33 |
| 34 // System service that caches and fetches tokens for a given account. |
| 35 // Not owned. |
| 36 OAuth2TokenService* token_service_; |
| 37 |
| 38 // The account id for whom to mint the token. |
| 39 std::string account_id_; |
| 40 |
| 41 // True if FetchAccessToken() has been called. |
| 42 bool fetch_started_; |
| 43 |
| 44 // Stores the request from |token_service_| to mint the token. |
| 45 scoped_ptr<OAuth2TokenService::Request> token_request_; |
| 46 |
| 47 // Callback to invoke when the token fetch succeeds or fails. |
| 48 AccessTokenCallback callback_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(CryptAuthAccountTokenFetcher); |
| 51 }; |
| 52 |
| 53 } // namespace proximity_auth |
| 54 |
| 55 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_ACCESS_TOKEN_FETCHER_IMPL_H |
OLD | NEW |