Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: google_apis/gaia/ubertoken_fetcher.cc

Issue 1129463004: Let Ubertoken Fetch be primed with an access token. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ChromeOS doesn't always have an access token Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « google_apis/gaia/ubertoken_fetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « google_apis/gaia/ubertoken_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698