Chromium Code Reviews| 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 if (access_token.empty()) | |
|
Andrew T Wilson (Slow)
2015/05/11 10:06:21
Adding a DCHECK() then handling this case seems ba
Roger Tawa OOO till Jul 10th
2015/05/11 16:56:16
This code is DCHECKing one thing and handling anot
Andrew T Wilson (Slow)
2015/05/12 15:08:08
Ah, you are right, I missed that one was checking
Mike Lerman
2015/05/12 20:51:44
Changed this method so that it should always have
| |
| 50 StartFetchingToken(account_id); | |
|
xiyuan
2015/05/11 16:11:58
Should we return here to let access token fetching
Mike Lerman
2015/05/12 20:51:44
I no longer permit access_token.empty(). The calle
| |
| 51 | |
| 52 account_id_ = account_id; | |
| 53 access_token_ = access_token; | |
| 54 ExchangeTokens(); | |
| 55 } | |
| 56 | |
| 46 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { | 57 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { |
| 47 consumer_->OnUbertokenSuccess(token); | 58 consumer_->OnUbertokenSuccess(token); |
| 48 } | 59 } |
| 49 | 60 |
| 50 void UbertokenFetcher::OnUberAuthTokenFailure( | 61 void UbertokenFetcher::OnUberAuthTokenFailure( |
| 51 const GoogleServiceAuthError& error) { | 62 const GoogleServiceAuthError& error) { |
| 52 // Retry only transient errors. | 63 // Retry only transient errors. |
| 53 bool should_retry = | 64 bool should_retry = |
| 54 error.state() == GoogleServiceAuthError::CONNECTION_FAILED || | 65 error.state() == GoogleServiceAuthError::CONNECTION_FAILED || |
| 55 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE; | 66 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 access_token_request_ = | 120 access_token_request_ = |
| 110 token_service_->StartRequest(account_id_, scopes, this); | 121 token_service_->StartRequest(account_id_, scopes, this); |
| 111 } | 122 } |
| 112 | 123 |
| 113 void UbertokenFetcher::ExchangeTokens() { | 124 void UbertokenFetcher::ExchangeTokens() { |
| 114 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, | 125 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, |
| 115 source_, | 126 source_, |
| 116 request_context_)); | 127 request_context_)); |
| 117 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); | 128 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); |
| 118 } | 129 } |
| OLD | NEW |