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/memory/ptr_util.h" |
10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "google_apis/gaia/gaia_auth_fetcher.h" | 14 #include "google_apis/gaia/gaia_auth_fetcher.h" |
14 #include "google_apis/gaia/gaia_constants.h" | 15 #include "google_apis/gaia/gaia_constants.h" |
15 #include "google_apis/gaia/google_service_auth_error.h" | 16 #include "google_apis/gaia/google_service_auth_error.h" |
16 #include "google_apis/gaia/oauth2_token_service.h" | 17 #include "google_apis/gaia/oauth2_token_service.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 GaiaAuthFetcher* CreateGaiaAuthFetcher( | 20 std::unique_ptr<GaiaAuthFetcher> CreateGaiaAuthFetcher( |
20 GaiaAuthConsumer* consumer, | 21 GaiaAuthConsumer* consumer, |
21 const std::string& source, | 22 const std::string& source, |
22 net::URLRequestContextGetter* request_context) { | 23 net::URLRequestContextGetter* request_context) { |
23 return new GaiaAuthFetcher(consumer, source, request_context); | 24 return base::MakeUnique<GaiaAuthFetcher>(consumer, source, request_context); |
24 } | 25 } |
25 } | 26 } |
26 | 27 |
27 const int UbertokenFetcher::kMaxRetries = 3; | 28 const int UbertokenFetcher::kMaxRetries = 3; |
28 | 29 |
29 UbertokenFetcher::UbertokenFetcher( | 30 UbertokenFetcher::UbertokenFetcher( |
30 OAuth2TokenService* token_service, | 31 OAuth2TokenService* token_service, |
31 UbertokenConsumer* consumer, | 32 UbertokenConsumer* consumer, |
32 const std::string& source, | 33 const std::string& source, |
33 net::URLRequestContextGetter* request_context) | 34 net::URLRequestContextGetter* request_context) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 gaia_auth_fetcher_.reset(); | 143 gaia_auth_fetcher_.reset(); |
143 retry_timer_.Stop(); | 144 retry_timer_.Stop(); |
144 | 145 |
145 OAuth2TokenService::ScopeSet scopes; | 146 OAuth2TokenService::ScopeSet scopes; |
146 scopes.insert(GaiaConstants::kOAuth1LoginScope); | 147 scopes.insert(GaiaConstants::kOAuth1LoginScope); |
147 access_token_request_ = | 148 access_token_request_ = |
148 token_service_->StartRequest(account_id_, scopes, this); | 149 token_service_->StartRequest(account_id_, scopes, this); |
149 } | 150 } |
150 | 151 |
151 void UbertokenFetcher::ExchangeTokens() { | 152 void UbertokenFetcher::ExchangeTokens() { |
152 gaia_auth_fetcher_.reset( | 153 gaia_auth_fetcher_ = |
153 gaia_auth_fetcher_factory_.Run(this, source_, request_context_)); | 154 gaia_auth_fetcher_factory_.Run(this, source_, request_context_); |
154 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); | 155 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); |
155 } | 156 } |
OLD | NEW |