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

Unified Diff: chrome/browser/chromeos/login/signin/token_handle_fetcher.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
diff --git a/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc b/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
index 3f79988b7d29ed7c08daa862fc33174f1beab686..83a287ab91deb0456bc5d14d690e88dfcf13d3b2 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
+++ b/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
@@ -42,15 +42,10 @@ class ShutdownNotifierFactory
} // namespace
TokenHandleFetcher::TokenHandleFetcher(TokenHandleUtil* util,
- const user_manager::UserID& user_id)
+ const AccountId& account_id)
: OAuth2TokenService::Consumer("user_session_manager"),
token_handle_util_(util),
- user_id_(user_id),
- token_service_(nullptr),
- waiting_for_refresh_token_(false),
- profile_(nullptr),
- tokeninfo_response_start_time_(base::TimeTicks()) {
-}
+ account_id_(account_id) {}
TokenHandleFetcher::~TokenHandleFetcher() {
if (waiting_for_refresh_token_)
@@ -65,9 +60,9 @@ void TokenHandleFetcher::BackfillToken(Profile* profile,
token_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
- std::string account_id = signin_manager->GetAuthenticatedAccountId();
- if (!token_service_->RefreshTokenIsAvailable(account_id)) {
- account_without_token_ = account_id;
+ const std::string user_email = signin_manager->GetAuthenticatedAccountId();
+ if (!token_service_->RefreshTokenIsAvailable(user_email)) {
+ account_without_token_ = user_email;
profile_shutdown_notification_ =
ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe(
base::Bind(&TokenHandleFetcher::OnProfileDestroyed,
@@ -77,23 +72,23 @@ void TokenHandleFetcher::BackfillToken(Profile* profile,
waiting_for_refresh_token_ = true;
return;
}
- RequestAccessToken(account_id);
+ RequestAccessToken(user_email);
}
void TokenHandleFetcher::OnRefreshTokenAvailable(
- const std::string& account_id) {
- if (account_without_token_ != account_id)
+ const std::string& user_email) {
+ if (account_without_token_ != user_email)
return;
waiting_for_refresh_token_ = false;
token_service_->RemoveObserver(this);
- RequestAccessToken(account_id);
+ RequestAccessToken(user_email);
}
-void TokenHandleFetcher::RequestAccessToken(const std::string& account_id) {
+void TokenHandleFetcher::RequestAccessToken(const std::string& user_email) {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kOAuth1LoginScope);
oauth2_access_token_request_ =
- token_service_->StartRequest(account_id, scopes, this);
+ token_service_->StartRequest(user_email, scopes, this);
}
void TokenHandleFetcher::OnGetTokenSuccess(
@@ -110,7 +105,7 @@ void TokenHandleFetcher::OnGetTokenFailure(
oauth2_access_token_request_.reset();
LOG(ERROR) << "Could not get access token to backfill token handler"
<< error.ToString();
- callback_.Run(user_id_, false);
+ callback_.Run(account_id_, false);
}
void TokenHandleFetcher::FillForNewUser(const std::string& access_token,
@@ -129,11 +124,11 @@ void TokenHandleFetcher::FillForAccessToken(const std::string& access_token) {
}
void TokenHandleFetcher::OnOAuthError() {
- callback_.Run(user_id_, false);
+ callback_.Run(account_id_, false);
}
void TokenHandleFetcher::OnNetworkError(int response_code) {
- callback_.Run(user_id_, false);
+ callback_.Run(account_id_, false);
}
void TokenHandleFetcher::OnGetTokenInfoResponse(
@@ -143,15 +138,15 @@ void TokenHandleFetcher::OnGetTokenInfoResponse(
std::string handle;
if (token_info->GetString("token_handle", &handle)) {
success = true;
- token_handle_util_->StoreTokenHandle(user_id_, handle);
+ token_handle_util_->StoreTokenHandle(account_id_, handle);
}
}
const base::TimeDelta duration =
base::TimeTicks::Now() - tokeninfo_response_start_time_;
UMA_HISTOGRAM_TIMES("Login.TokenObtainResponseTime", duration);
- callback_.Run(user_id_, success);
+ callback_.Run(account_id_, success);
}
void TokenHandleFetcher::OnProfileDestroyed() {
- callback_.Run(user_id_, false);
+ callback_.Run(account_id_, false);
}
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_fetcher.h ('k') | chrome/browser/chromeos/login/signin/token_handle_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698