Commit e33484a6 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

[s13n] Use kWaitUntilRefreshTokenAvailable mode for ProfileDownloader

This CL makes ProfileDownloader use AccessTokenFetcher in
kWaitUntilAvailable mode, which simplifies it as it doesn't need
to observe OnRefreshTokenUpdatedForAccount().

This is a follow-up CL of https://crrev.com/c/1436780.

Bug: 922757, 922758
Change-Id: If2b664a6e4e303db16cf028b947592e2f463c291
Reviewed-on: https://chromium-review.googlesource.com/c/1457575Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#629912}
parent 3d4f3ff1
......@@ -51,8 +51,7 @@ ProfileDownloader::ProfileDownloader(ProfileDownloaderDelegate* delegate)
identity_manager_(IdentityManagerFactory::GetForProfile(
delegate_->GetBrowserProfile())),
identity_manager_observer_(this),
waiting_for_account_info_(false),
waiting_for_refresh_token_(false) {
waiting_for_account_info_(false) {
DCHECK(delegate_);
identity_manager_observer_.Add(identity_manager_);
}
......@@ -75,10 +74,7 @@ void ProfileDownloader::StartForAccount(const std::string& account_id) {
account_id_ = account_id.empty() ? identity_manager_->GetPrimaryAccountId()
: account_id;
if (identity_manager_->HasAccountWithRefreshToken(account_id_))
StartFetchingOAuth2AccessToken();
else
waiting_for_refresh_token_ = true;
StartFetchingOAuth2AccessToken();
}
base::string16 ProfileDownloader::GetProfileHostedDomain() const {
......@@ -150,7 +146,7 @@ void ProfileDownloader::StartFetchingOAuth2AccessToken() {
account_id_, "profile_downloader", scopes,
base::BindOnce(&ProfileDownloader::OnAccessTokenFetchComplete,
base::Unretained(this)),
identity::AccessTokenFetcher::Mode::kImmediate);
identity::AccessTokenFetcher::Mode::kWaitUntilRefreshTokenAvailable);
}
ProfileDownloader::~ProfileDownloader() {
......@@ -292,15 +288,6 @@ void ProfileDownloader::OnDecodeImageFailed() {
this, ProfileDownloaderDelegate::IMAGE_DECODE_FAILED);
}
void ProfileDownloader::OnRefreshTokenUpdatedForAccount(
const AccountInfo& account_info) {
if (account_info.account_id != account_id_ || !waiting_for_refresh_token_)
return;
waiting_for_refresh_token_ = false;
StartFetchingOAuth2AccessToken();
}
void ProfileDownloader::OnAccessTokenFetchComplete(
GoogleServiceAuthError error,
identity::AccessTokenInfo access_token_info) {
......
......@@ -95,8 +95,6 @@ class ProfileDownloader : public ImageDecoder::ImageRequest,
void OnDecodeImageFailed() override;
// Overriden from identity::IdentityManager::Observer:
void OnRefreshTokenUpdatedForAccount(
const AccountInfo& account_info) override;
void OnAccountUpdated(const AccountInfo& info) override;
// Callback for AccessTokenFetcher.
......@@ -125,7 +123,6 @@ class ProfileDownloader : public ImageDecoder::ImageRequest,
ScopedObserver<identity::IdentityManager, identity::IdentityManager::Observer>
identity_manager_observer_;
bool waiting_for_account_info_;
bool waiting_for_refresh_token_;
DISALLOW_COPY_AND_ASSIGN(ProfileDownloader);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment