| OLD | NEW |
| 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/chromeos/login/signin/token_handle_util.h" | 5 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (!user_manager::known_user::FindPrefs(account_id, &dict)) { | 79 if (!user_manager::known_user::FindPrefs(account_id, &dict)) { |
| 80 callback.Run(account_id, UNKNOWN); | 80 callback.Run(account_id, UNKNOWN); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 if (!dict->GetString(kTokenHandlePref, &token)) { | 83 if (!dict->GetString(kTokenHandlePref, &token)) { |
| 84 callback.Run(account_id, UNKNOWN); | 84 callback.Run(account_id, UNKNOWN); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (!gaia_client_.get()) { | 88 if (!gaia_client_.get()) { |
| 89 auto request_context = | 89 auto* request_context = |
| 90 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext(); | 90 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext(); |
| 91 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context)); | 91 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 validation_delegates_.set( | 94 validation_delegates_.set( |
| 95 token, std::unique_ptr<TokenDelegate>(new TokenDelegate( | 95 token, std::unique_ptr<TokenDelegate>(new TokenDelegate( |
| 96 weak_factory_.GetWeakPtr(), account_id, token, callback))); | 96 weak_factory_.GetWeakPtr(), account_id, token, callback))); |
| 97 gaia_client_->GetTokenHandleInfo(token, kMaxRetries, | 97 gaia_client_->GetTokenHandleInfo(token, kMaxRetries, |
| 98 validation_delegates_.get(token)); | 98 validation_delegates_.get(token)); |
| 99 } | 99 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (token_info->GetInteger("expires_in", &expires_in)) | 151 if (token_info->GetInteger("expires_in", &expires_in)) |
| 152 outcome = (expires_in < 0) ? INVALID : VALID; | 152 outcome = (expires_in < 0) ? INVALID : VALID; |
| 153 } | 153 } |
| 154 | 154 |
| 155 const base::TimeDelta duration = | 155 const base::TimeDelta duration = |
| 156 base::TimeTicks::Now() - tokeninfo_response_start_time_; | 156 base::TimeTicks::Now() - tokeninfo_response_start_time_; |
| 157 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration); | 157 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration); |
| 158 callback_.Run(account_id_, outcome); | 158 callback_.Run(account_id_, outcome); |
| 159 NotifyDone(); | 159 NotifyDone(); |
| 160 } | 160 } |
| OLD | NEW |