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