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

Side by Side Diff: chrome/browser/chromeos/login/oauth2_login_verifier.cc

Issue 59883010: This is the fourth CL of several that will eventually replace TokenService with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change LOG(INFO) to VLOG(1) Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/login/oauth2_login_verifier.h" 5 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 gaia_fetcher_.reset( 100 gaia_fetcher_.reset(
101 new GaiaAuthFetcher(this, 101 new GaiaAuthFetcher(this,
102 std::string(GaiaConstants::kChromeOSSource), 102 std::string(GaiaConstants::kChromeOSSource),
103 user_request_context_.get())); 103 user_request_context_.get()));
104 gaia_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); 104 gaia_fetcher_->StartTokenFetchForUberAuthExchange(access_token_);
105 } 105 }
106 106
107 107
108 void OAuth2LoginVerifier::OnUberAuthTokenSuccess( 108 void OAuth2LoginVerifier::OnUberAuthTokenSuccess(
109 const std::string& uber_token) { 109 const std::string& uber_token) {
110 LOG(INFO) << "OAuthLogin(uber_token) successful!"; 110 VLOG(1) << "OAuthLogin(uber_token) successful!";
111 retry_count_ = 0; 111 retry_count_ = 0;
112 gaia_token_ = uber_token; 112 gaia_token_ = uber_token;
113 StartMergeSession(); 113 StartMergeSession();
114 } 114 }
115 115
116 void OAuth2LoginVerifier::OnUberAuthTokenFailure( 116 void OAuth2LoginVerifier::OnUberAuthTokenFailure(
117 const GoogleServiceAuthError& error) { 117 const GoogleServiceAuthError& error) {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
119 LOG(WARNING) << "OAuthLogin(uber_token) failed," 119 LOG(WARNING) << "OAuthLogin(uber_token) failed,"
120 << " error: " << error.state(); 120 << " error: " << error.state();
121 RetryOnError("OAuthLoginUberToken", error, 121 RetryOnError("OAuthLoginUberToken", error,
122 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForUberToken, 122 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForUberToken,
123 AsWeakPtr()), 123 AsWeakPtr()),
124 base::Bind(&Delegate::OnOAuthLoginFailure, 124 base::Bind(&Delegate::OnOAuthLoginFailure,
125 base::Unretained(delegate_))); 125 base::Unretained(delegate_)));
126 } 126 }
127 127
128 void OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials() { 128 void OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials() {
129 // No service will fetch us uber auth token. 129 // No service will fetch us uber auth token.
130 gaia_fetcher_.reset( 130 gaia_fetcher_.reset(
131 new GaiaAuthFetcher(this, 131 new GaiaAuthFetcher(this,
132 std::string(GaiaConstants::kChromeOSSource), 132 std::string(GaiaConstants::kChromeOSSource),
133 user_request_context_.get())); 133 user_request_context_.get()));
134 gaia_fetcher_->StartOAuthLogin(access_token_, EmptyString()); 134 gaia_fetcher_->StartOAuthLogin(access_token_, EmptyString());
135 } 135 }
136 136
137 void OAuth2LoginVerifier::OnClientLoginSuccess( 137 void OAuth2LoginVerifier::OnClientLoginSuccess(
138 const ClientLoginResult& gaia_credentials) { 138 const ClientLoginResult& gaia_credentials) {
139 LOG(INFO) << "OAuthLogin(SID+LSID) successful!"; 139 VLOG(1) << "OAuthLogin(SID+LSID) successful!";
140 retry_count_ = 0; 140 retry_count_ = 0;
141 delegate_->OnOAuthLoginSuccess(gaia_credentials); 141 delegate_->OnOAuthLoginSuccess(gaia_credentials);
142 } 142 }
143 143
144 void OAuth2LoginVerifier::OnClientLoginFailure( 144 void OAuth2LoginVerifier::OnClientLoginFailure(
145 const GoogleServiceAuthError& error) { 145 const GoogleServiceAuthError& error) {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
147 LOG(WARNING) << "OAuthLogin(SID+LSID failed)," 147 LOG(WARNING) << "OAuthLogin(SID+LSID failed),"
148 << " error: " << error.state(); 148 << " error: " << error.state();
149 RetryOnError( 149 RetryOnError(
150 "OAuthLoginGaiaCred", error, 150 "OAuthLoginGaiaCred", error,
151 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials, 151 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials,
152 AsWeakPtr()), 152 AsWeakPtr()),
153 base::Bind(&Delegate::OnOAuthLoginFailure, 153 base::Bind(&Delegate::OnOAuthLoginFailure,
154 base::Unretained(delegate_))); 154 base::Unretained(delegate_)));
155 } 155 }
156 156
157 void OAuth2LoginVerifier::StartMergeSession() { 157 void OAuth2LoginVerifier::StartMergeSession() {
158 DCHECK(!gaia_token_.empty()); 158 DCHECK(!gaia_token_.empty());
159 gaia_fetcher_.reset( 159 gaia_fetcher_.reset(
160 new GaiaAuthFetcher(this, 160 new GaiaAuthFetcher(this,
161 std::string(GaiaConstants::kChromeOSSource), 161 std::string(GaiaConstants::kChromeOSSource),
162 user_request_context_.get())); 162 user_request_context_.get()));
163 gaia_fetcher_->StartMergeSession(gaia_token_); 163 gaia_fetcher_->StartMergeSession(gaia_token_);
164 } 164 }
165 165
166 void OAuth2LoginVerifier::OnMergeSessionSuccess(const std::string& data) { 166 void OAuth2LoginVerifier::OnMergeSessionSuccess(const std::string& data) {
167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
168 LOG(INFO) << "MergeSession successful."; 168 VLOG(1) << "MergeSession successful.";
169 delegate_->OnSessionMergeSuccess(); 169 delegate_->OnSessionMergeSuccess();
170 // Get GAIA credentials needed to kick off TokenService and friends. 170 // Get GAIA credentials needed to kick off OAuth2TokenService and friends.
171 StartOAuthLoginForGaiaCredentials(); 171 StartOAuthLoginForGaiaCredentials();
172 } 172 }
173 173
174 void OAuth2LoginVerifier::OnMergeSessionFailure( 174 void OAuth2LoginVerifier::OnMergeSessionFailure(
175 const GoogleServiceAuthError& error) { 175 const GoogleServiceAuthError& error) {
176 LOG(WARNING) << "Failed MergeSession request," 176 LOG(WARNING) << "Failed MergeSession request,"
177 << " error: " << error.state(); 177 << " error: " << error.state();
178 // If MergeSession from GAIA service token fails, retry the session restore 178 // If MergeSession from GAIA service token fails, retry the session restore
179 // from OAuth2 refresh token. If that failed too, signal the delegate. 179 // from OAuth2 refresh token. If that failed too, signal the delegate.
180 RetryOnError( 180 RetryOnError(
181 "MergeSession", 181 "MergeSession",
182 error, 182 error,
183 base::Bind(&OAuth2LoginVerifier::StartMergeSession, 183 base::Bind(&OAuth2LoginVerifier::StartMergeSession,
184 AsWeakPtr()), 184 AsWeakPtr()),
185 base::Bind(&Delegate::OnSessionMergeFailure, 185 base::Bind(&Delegate::OnSessionMergeFailure,
186 base::Unretained(delegate_))); 186 base::Unretained(delegate_)));
187 } 187 }
188 188
189 void OAuth2LoginVerifier::OnGetTokenSuccess( 189 void OAuth2LoginVerifier::OnGetTokenSuccess(
190 const OAuth2TokenService::Request* request, 190 const OAuth2TokenService::Request* request,
191 const std::string& access_token, 191 const std::string& access_token,
192 const base::Time& expiration_time) { 192 const base::Time& expiration_time) {
193 DCHECK_EQ(login_token_request_.get(), request); 193 DCHECK_EQ(login_token_request_.get(), request);
194 login_token_request_.reset(); 194 login_token_request_.reset();
195 195
196 LOG(INFO) << "Got OAuth2 access token!"; 196 VLOG(1) << "Got OAuth2 access token!";
197 retry_count_ = 0; 197 retry_count_ = 0;
198 access_token_ = access_token; 198 access_token_ = access_token;
199 StartOAuthLoginForUberToken(); 199 StartOAuthLoginForUberToken();
200 } 200 }
201 201
202 void OAuth2LoginVerifier::OnGetTokenFailure( 202 void OAuth2LoginVerifier::OnGetTokenFailure(
203 const OAuth2TokenService::Request* request, 203 const OAuth2TokenService::Request* request,
204 const GoogleServiceAuthError& error) { 204 const GoogleServiceAuthError& error) {
205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
206 DCHECK_EQ(login_token_request_.get(), request); 206 DCHECK_EQ(login_token_request_.get(), request);
(...skipping 29 matching lines...) Expand all
236 << operation_id; 236 << operation_id;
237 UMA_HISTOGRAM_ENUMERATION( 237 UMA_HISTOGRAM_ENUMERATION(
238 base::StringPrintf("OAuth2Login.%sFailure", operation_id), 238 base::StringPrintf("OAuth2Login.%sFailure", operation_id),
239 error.state(), 239 error.state(),
240 GoogleServiceAuthError::NUM_STATES); 240 GoogleServiceAuthError::NUM_STATES);
241 241
242 error_handler.Run(IsConnectionOrServiceError(error)); 242 error_handler.Run(IsConnectionOrServiceError(error));
243 } 243 }
244 244
245 } // namespace chromeos 245 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698