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

Side by Side Diff: chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc

Issue 2672833002: [Desktop] Add diagnostics about loading the refresh tokens. (Closed)
Patch Set: Nit Created 3 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/signin/mutable_profile_oauth2_token_service_delegate.h" 5 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 GoogleServiceAuthError 121 GoogleServiceAuthError
122 MutableProfileOAuth2TokenServiceDelegate::AccountStatus::GetAuthStatus() const { 122 MutableProfileOAuth2TokenServiceDelegate::AccountStatus::GetAuthStatus() const {
123 return last_auth_error_; 123 return last_auth_error_;
124 } 124 }
125 125
126 MutableProfileOAuth2TokenServiceDelegate:: 126 MutableProfileOAuth2TokenServiceDelegate::
127 MutableProfileOAuth2TokenServiceDelegate( 127 MutableProfileOAuth2TokenServiceDelegate(
128 SigninClient* client, 128 SigninClient* client,
129 SigninErrorController* signin_error_controller, 129 SigninErrorController* signin_error_controller,
130 AccountTrackerService* account_tracker_service) 130 AccountTrackerService* account_tracker_service)
131 : web_data_service_request_(0), 131 : load_credentials_state_(LOAD_CREDENTIALS_NOT_STARTED),
132 web_data_service_request_(0),
132 backoff_entry_(&backoff_policy_), 133 backoff_entry_(&backoff_policy_),
133 backoff_error_(GoogleServiceAuthError::NONE), 134 backoff_error_(GoogleServiceAuthError::NONE),
134 client_(client), 135 client_(client),
135 signin_error_controller_(signin_error_controller), 136 signin_error_controller_(signin_error_controller),
136 account_tracker_service_(account_tracker_service) { 137 account_tracker_service_(account_tracker_service) {
137 VLOG(1) << "MutablePO2TS::MutablePO2TS"; 138 VLOG(1) << "MutablePO2TS::MutablePO2TS";
138 DCHECK(client); 139 DCHECK(client);
139 DCHECK(signin_error_controller); 140 DCHECK(signin_error_controller);
140 // It's okay to fill the backoff policy after being used in construction. 141 // It's okay to fill the backoff policy after being used in construction.
141 backoff_policy_.num_errors_to_ignore = 0; 142 backoff_policy_.num_errors_to_ignore = 0;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 account_ids.push_back(token.first); 238 account_ids.push_back(token.first);
238 } 239 }
239 return account_ids; 240 return account_ids;
240 } 241 }
241 242
242 net::URLRequestContextGetter* 243 net::URLRequestContextGetter*
243 MutableProfileOAuth2TokenServiceDelegate::GetRequestContext() const { 244 MutableProfileOAuth2TokenServiceDelegate::GetRequestContext() const {
244 return client_->GetURLRequestContext(); 245 return client_->GetURLRequestContext();
245 } 246 }
246 247
248 OAuth2TokenServiceDelegate::LoadCredentialsState
249 MutableProfileOAuth2TokenServiceDelegate::GetLoadCredentialsState() const {
250 return load_credentials_state_;
251 }
252
247 void MutableProfileOAuth2TokenServiceDelegate::LoadCredentials( 253 void MutableProfileOAuth2TokenServiceDelegate::LoadCredentials(
248 const std::string& primary_account_id) { 254 const std::string& primary_account_id) {
255 DCHECK_EQ(LOAD_CREDENTIALS_NOT_STARTED, load_credentials_state_);
249 if (primary_account_id.empty()) { 256 if (primary_account_id.empty()) {
257 load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_SUCCESS;
250 FireRefreshTokensLoaded(); 258 FireRefreshTokensLoaded();
251 return; 259 return;
252 } 260 }
261
262 load_credentials_state_ = LOAD_CREDENTIALS_IN_PROGRESS;
263
253 ValidateAccountId(primary_account_id); 264 ValidateAccountId(primary_account_id);
254 DCHECK(loading_primary_account_id_.empty()); 265 DCHECK(loading_primary_account_id_.empty());
255 DCHECK_EQ(0, web_data_service_request_); 266 DCHECK_EQ(0, web_data_service_request_);
256 267
257 refresh_tokens_.clear(); 268 refresh_tokens_.clear();
258 269
259 // If the account_id is an email address, then canonicalize it. This 270 // If the account_id is an email address, then canonicalize it. This
260 // is to support legacy account_ids, and will not be needed after 271 // is to support legacy account_ids, and will not be needed after
261 // switching to gaia-ids. 272 // switching to gaia-ids.
262 if (primary_account_id.find('@') != std::string::npos) { 273 if (primary_account_id.find('@') != std::string::npos) {
(...skipping 17 matching lines...) Expand all
280 // fixed. 291 // fixed.
281 tracked_objects::ScopedTracker tracking_profile( 292 tracked_objects::ScopedTracker tracking_profile(
282 FROM_HERE_WITH_EXPLICIT_FUNCTION( 293 FROM_HERE_WITH_EXPLICIT_FUNCTION(
283 "422460 MutableProfileOAuth2Token...::OnWebDataServiceRequestDone")); 294 "422460 MutableProfileOAuth2Token...::OnWebDataServiceRequestDone"));
284 295
285 DCHECK_EQ(web_data_service_request_, handle); 296 DCHECK_EQ(web_data_service_request_, handle);
286 web_data_service_request_ = 0; 297 web_data_service_request_ = 0;
287 298
288 if (result) { 299 if (result) {
289 DCHECK(result->GetType() == TOKEN_RESULT); 300 DCHECK(result->GetType() == TOKEN_RESULT);
290 const WDResult<std::map<std::string, std::string>>* token_result = 301 const WDResult<TokenResult>* token_result =
291 static_cast<const WDResult<std::map<std::string, std::string>>*>( 302 static_cast<const WDResult<TokenResult>*>(result.get());
292 result.get()); 303 LoadAllCredentialsIntoMemory(token_result->GetValue().tokens);
293 LoadAllCredentialsIntoMemory(token_result->GetValue()); 304 switch (token_result->GetValue().db_result) {
305 case TokenServiceTable::TOKEN_DB_RESULT_SQL_INVALID_STATEMENT:
306 case TokenServiceTable::TOKEN_DB_RESULT_BAD_ENTRY:
307 load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_DB_ERRORS;
308 break;
309 case TokenServiceTable::TOKEN_DB_RESULT_DECRYPT_ERROR:
310 load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_DECRYPT_ERRORS;
311 break;
312 case TokenServiceTable::TOKEN_DB_RESULT_SUCCESS:
313 load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_SUCCESS;
314 break;
315 }
316 FireRefreshTokensLoaded();
317 } else {
318 load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_UNKNOWN_ERRORS;
319 // TODO(msarda): Should |FireRefreshTokensLoaded| be called on this branch
320 // as well?
Roger Tawa OOO till Jul 10th 2017/02/02 18:58:25 I'm not sure why you wouldn't fire the event here
msarda 2017/02/03 09:07:09 It did not cause any specific errors. I did not fi
294 } 321 }
295 322
296 // Make sure that we have an entry for |loading_primary_account_id_| in the 323 // Make sure that we have an entry for |loading_primary_account_id_| in the
297 // map. The entry could be missing if there is a corruption in the token DB 324 // map. The entry could be missing if there is a corruption in the token DB
298 // while this profile is connected to an account. 325 // while this profile is connected to an account.
299 DCHECK(!loading_primary_account_id_.empty()); 326 DCHECK(!loading_primary_account_id_.empty());
300 if (refresh_tokens_.count(loading_primary_account_id_) == 0) { 327 if (refresh_tokens_.count(loading_primary_account_id_) == 0) {
301 refresh_tokens_[loading_primary_account_id_].reset(new AccountStatus( 328 refresh_tokens_[loading_primary_account_id_].reset(new AccountStatus(
302 signin_error_controller_, loading_primary_account_id_, std::string())); 329 signin_error_controller_, loading_primary_account_id_, std::string()));
303 } 330 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 420 }
394 } 421 }
395 } 422 }
396 423
397 if (!old_login_token.empty()) { 424 if (!old_login_token.empty()) {
398 DCHECK(!loading_primary_account_id_.empty()); 425 DCHECK(!loading_primary_account_id_.empty());
399 if (refresh_tokens_.count(loading_primary_account_id_) == 0) 426 if (refresh_tokens_.count(loading_primary_account_id_) == 0)
400 UpdateCredentials(loading_primary_account_id_, old_login_token); 427 UpdateCredentials(loading_primary_account_id_, old_login_token);
401 } 428 }
402 } 429 }
403
404 FireRefreshTokensLoaded();
405 } 430 }
406 431
407 void MutableProfileOAuth2TokenServiceDelegate::UpdateCredentials( 432 void MutableProfileOAuth2TokenServiceDelegate::UpdateCredentials(
408 const std::string& account_id, 433 const std::string& account_id,
409 const std::string& refresh_token) { 434 const std::string& refresh_token) {
410 DCHECK(thread_checker_.CalledOnValidThread()); 435 DCHECK(thread_checker_.CalledOnValidThread());
411 DCHECK(!account_id.empty()); 436 DCHECK(!account_id.empty());
412 DCHECK(!refresh_token.empty()); 437 DCHECK(!refresh_token.empty());
413 ValidateAccountId(account_id); 438 ValidateAccountId(account_id);
414 439
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 net::NetworkChangeNotifier::ConnectionType type) { 550 net::NetworkChangeNotifier::ConnectionType type) {
526 // If our network has changed, reset the backoff timer so that errors caused 551 // If our network has changed, reset the backoff timer so that errors caused
527 // by a previous lack of network connectivity don't prevent new requests. 552 // by a previous lack of network connectivity don't prevent new requests.
528 backoff_entry_.Reset(); 553 backoff_entry_.Reset();
529 } 554 }
530 555
531 const net::BackoffEntry* 556 const net::BackoffEntry*
532 MutableProfileOAuth2TokenServiceDelegate::BackoffEntry() const { 557 MutableProfileOAuth2TokenServiceDelegate::BackoffEntry() const {
533 return &backoff_entry_; 558 return &backoff_entry_;
534 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698