Commit 0156251a authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[ProfileOAuth2TokenService] Expose whether refresh tokens are loaded

Consumers of ProfileOAuth2TokenService currently have the ability to load
credentials but no way to query whether all credentilas have been loaded.
This functionality will be needed by the Identity Service internal
implementation in order to delay responding to consumer requests until
all refresh tokens have been loaded (listening to the observer event
isn't enough because the Identity Service might be started after the
event has fired).

This CL adds this functionality.

Bug: 740117
Change-Id: Ia2d61aefa9310f05bbc58c2884a68bc19d647c08
Reviewed-on: https://chromium-review.googlesource.com/563616Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485253}
parent 1089d064
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
ProfileOAuth2TokenService::ProfileOAuth2TokenService( ProfileOAuth2TokenService::ProfileOAuth2TokenService(
std::unique_ptr<OAuth2TokenServiceDelegate> delegate) std::unique_ptr<OAuth2TokenServiceDelegate> delegate)
: OAuth2TokenService(std::move(delegate)) { : OAuth2TokenService(std::move(delegate)), all_credentials_loaded_(false) {
AddObserver(this); AddObserver(this);
} }
...@@ -24,6 +24,10 @@ void ProfileOAuth2TokenService::LoadCredentials( ...@@ -24,6 +24,10 @@ void ProfileOAuth2TokenService::LoadCredentials(
GetDelegate()->LoadCredentials(primary_account_id); GetDelegate()->LoadCredentials(primary_account_id);
} }
bool ProfileOAuth2TokenService::AreAllCredentialsLoaded() {
return all_credentials_loaded_;
}
void ProfileOAuth2TokenService::UpdateCredentials( void ProfileOAuth2TokenService::UpdateCredentials(
const std::string& account_id, const std::string& account_id,
const std::string& refresh_token) { const std::string& refresh_token) {
...@@ -50,3 +54,7 @@ void ProfileOAuth2TokenService::OnRefreshTokenRevoked( ...@@ -50,3 +54,7 @@ void ProfileOAuth2TokenService::OnRefreshTokenRevoked(
CancelRequestsForAccount(account_id); CancelRequestsForAccount(account_id);
ClearCacheForAccount(account_id); ClearCacheForAccount(account_id);
} }
void ProfileOAuth2TokenService::OnRefreshTokensLoaded() {
all_credentials_loaded_ = true;
}
...@@ -45,7 +45,10 @@ class ProfileOAuth2TokenService : public OAuth2TokenService, ...@@ -45,7 +45,10 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
// The primary account is specified with the |primary_account_id| argument. // The primary account is specified with the |primary_account_id| argument.
// For a regular profile, the primary account id comes from SigninManager. // For a regular profile, the primary account id comes from SigninManager.
// For a supervised user, the id comes from SupervisedUserService. // For a supervised user, the id comes from SupervisedUserService.
virtual void LoadCredentials(const std::string& primary_account_id); void LoadCredentials(const std::string& primary_account_id);
// Returns true iff all credentials have been loaded from disk.
bool AreAllCredentialsLoaded();
// Updates a |refresh_token| for an |account_id|. Credentials are persisted, // Updates a |refresh_token| for an |account_id|. Credentials are persisted,
// and available through |LoadCredentials| after service is restarted. // and available through |LoadCredentials| after service is restarted.
...@@ -61,6 +64,10 @@ class ProfileOAuth2TokenService : public OAuth2TokenService, ...@@ -61,6 +64,10 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
private: private:
void OnRefreshTokenAvailable(const std::string& account_id) override; void OnRefreshTokenAvailable(const std::string& account_id) override;
void OnRefreshTokenRevoked(const std::string& account_id) override; void OnRefreshTokenRevoked(const std::string& account_id) override;
void OnRefreshTokensLoaded() override;
// Whether all credentials have been loaded.
bool all_credentials_loaded_;
DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService); DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService);
}; };
......
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