| 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 #include "google_apis/gaia/ubertoken_fetcher.h" | 5 #include "google_apis/gaia/ubertoken_fetcher.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 UbertokenFetcher::~UbertokenFetcher() { | 36 UbertokenFetcher::~UbertokenFetcher() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) { | 39 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) { |
| 40 DCHECK(!account_id.empty()); | 40 DCHECK(!account_id.empty()); |
| 41 account_id_ = account_id; | 41 account_id_ = account_id; |
| 42 second_access_token_request_ = false; | 42 second_access_token_request_ = false; |
| 43 RequestAccessToken(); | 43 RequestAccessToken(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void UbertokenFetcher::StartFetchingTokenWithAccessToken( |
| 47 const std::string& account_id, const std::string& access_token) { |
| 48 DCHECK(!account_id.empty()); |
| 49 DCHECK(!access_token.empty()); |
| 50 |
| 51 account_id_ = account_id; |
| 52 access_token_ = access_token; |
| 53 ExchangeTokens(); |
| 54 } |
| 55 |
| 46 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { | 56 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { |
| 47 consumer_->OnUbertokenSuccess(token); | 57 consumer_->OnUbertokenSuccess(token); |
| 48 } | 58 } |
| 49 | 59 |
| 50 void UbertokenFetcher::OnUberAuthTokenFailure( | 60 void UbertokenFetcher::OnUberAuthTokenFailure( |
| 51 const GoogleServiceAuthError& error) { | 61 const GoogleServiceAuthError& error) { |
| 52 // Retry only transient errors. | 62 // Retry only transient errors. |
| 53 bool should_retry = | 63 bool should_retry = |
| 54 error.state() == GoogleServiceAuthError::CONNECTION_FAILED || | 64 error.state() == GoogleServiceAuthError::CONNECTION_FAILED || |
| 55 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE; | 65 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 access_token_request_ = | 119 access_token_request_ = |
| 110 token_service_->StartRequest(account_id_, scopes, this); | 120 token_service_->StartRequest(account_id_, scopes, this); |
| 111 } | 121 } |
| 112 | 122 |
| 113 void UbertokenFetcher::ExchangeTokens() { | 123 void UbertokenFetcher::ExchangeTokens() { |
| 114 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, | 124 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, |
| 115 source_, | 125 source_, |
| 116 request_context_)); | 126 request_context_)); |
| 117 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); | 127 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); |
| 118 } | 128 } |
| OLD | NEW |