| 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" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "google_apis/gaia/gaia_auth_fetcher.h" | 12 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 13 #include "google_apis/gaia/gaia_constants.h" | 13 #include "google_apis/gaia/gaia_constants.h" |
| 14 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
| 15 #include "google_apis/gaia/oauth2_token_service.h" | 15 #include "google_apis/gaia/oauth2_token_service.h" |
| 16 | 16 |
| 17 const int UbertokenFetcher::kMaxRetries = 3; | 17 const int UbertokenFetcher::kMaxRetries = 3; |
| 18 | 18 |
| 19 UbertokenFetcher::UbertokenFetcher( | 19 UbertokenFetcher::UbertokenFetcher( |
| 20 OAuth2TokenService* token_service, | 20 OAuth2TokenService* token_service, |
| 21 UbertokenConsumer* consumer, | 21 UbertokenConsumer* consumer, |
| 22 const std::string& source, |
| 22 net::URLRequestContextGetter* request_context) | 23 net::URLRequestContextGetter* request_context) |
| 23 : OAuth2TokenService::Consumer("uber_token_fetcher"), | 24 : OAuth2TokenService::Consumer("uber_token_fetcher"), |
| 24 token_service_(token_service), | 25 token_service_(token_service), |
| 25 consumer_(consumer), | 26 consumer_(consumer), |
| 27 source_(source), |
| 26 request_context_(request_context), | 28 request_context_(request_context), |
| 27 retry_number_(0), | 29 retry_number_(0), |
| 28 second_access_token_request_(false) { | 30 second_access_token_request_(false) { |
| 29 DCHECK(token_service); | 31 DCHECK(token_service); |
| 30 DCHECK(consumer); | 32 DCHECK(consumer); |
| 31 DCHECK(request_context); | 33 DCHECK(request_context); |
| 32 } | 34 } |
| 33 | 35 |
| 34 UbertokenFetcher::~UbertokenFetcher() { | 36 UbertokenFetcher::~UbertokenFetcher() { |
| 35 } | 37 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 105 |
| 104 void UbertokenFetcher::RequestAccessToken() { | 106 void UbertokenFetcher::RequestAccessToken() { |
| 105 OAuth2TokenService::ScopeSet scopes; | 107 OAuth2TokenService::ScopeSet scopes; |
| 106 scopes.insert(GaiaConstants::kOAuth1LoginScope); | 108 scopes.insert(GaiaConstants::kOAuth1LoginScope); |
| 107 access_token_request_ = | 109 access_token_request_ = |
| 108 token_service_->StartRequest(account_id_, scopes, this); | 110 token_service_->StartRequest(account_id_, scopes, this); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void UbertokenFetcher::ExchangeTokens() { | 113 void UbertokenFetcher::ExchangeTokens() { |
| 112 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, | 114 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, |
| 113 GaiaConstants::kChromeSource, | 115 source_, |
| 114 request_context_)); | 116 request_context_)); |
| 115 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); | 117 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); |
| 116 } | 118 } |
| OLD | NEW |