Commit e9bf0d10 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

Change IdentityManager API to take in account ID

We've made the decision that IdentityManager APIs that query account
information should take in account IDs, with those that *return*
information continuing to return full AccountInfo structs. This CL
changes the one remaining API that takes in an AccountInfo
(RemoveAccessTokenFromCache()) to take in the account ID instead.

Bug: 796544
Change-Id: I1d6894fa40045fa54956f777723e1e2d3383098d
Reviewed-on: https://chromium-review.googlesource.com/1110224
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569642}
parent 847ca33d
...@@ -701,7 +701,7 @@ void PaymentsClient::StartTokenFetch(bool invalidate_old) { ...@@ -701,7 +701,7 @@ void PaymentsClient::StartTokenFetch(bool invalidate_old) {
if (invalidate_old) { if (invalidate_old) {
DCHECK(!access_token_.empty()); DCHECK(!access_token_.empty());
identity_manager_->RemoveAccessTokenFromCache( identity_manager_->RemoveAccessTokenFromCache(
identity_manager_->GetPrimaryAccountInfo(), payments_scopes, identity_manager_->GetPrimaryAccountInfo().account_id, payments_scopes,
access_token_); access_token_);
} }
access_token_.clear(); access_token_.clear();
......
...@@ -278,8 +278,8 @@ void SyncAuthManager::RequestAccessToken() { ...@@ -278,8 +278,8 @@ void SyncAuthManager::RequestAccessToken() {
// Invalidate previous token, otherwise token service will return the same // Invalidate previous token, otherwise token service will return the same
// token again. // token again.
if (!access_token_.empty()) { if (!access_token_.empty()) {
identity_manager_->RemoveAccessTokenFromCache(GetAuthenticatedAccountInfo(), identity_manager_->RemoveAccessTokenFromCache(
oauth2_scopes, access_token_); GetAuthenticatedAccountInfo().account_id, oauth2_scopes, access_token_);
access_token_.clear(); access_token_.clear();
credentials_changed_callback_.Run(); credentials_changed_callback_.Run();
......
...@@ -199,7 +199,7 @@ class RequestImpl : public WebHistoryService::Request { ...@@ -199,7 +199,7 @@ class RequestImpl : public WebHistoryService::Request {
OAuth2TokenService::ScopeSet oauth_scopes; OAuth2TokenService::ScopeSet oauth_scopes;
oauth_scopes.insert(kHistoryOAuthScope); oauth_scopes.insert(kHistoryOAuthScope);
identity_manager_->RemoveAccessTokenFromCache( identity_manager_->RemoveAccessTokenFromCache(
identity_manager_->GetPrimaryAccountInfo(), oauth_scopes, identity_manager_->GetPrimaryAccountInfo().account_id, oauth_scopes,
access_token_); access_token_);
access_token_.clear(); access_token_.clear();
......
...@@ -106,7 +106,7 @@ IdentityManager::CreateAccessTokenFetcherForPrimaryAccount( ...@@ -106,7 +106,7 @@ IdentityManager::CreateAccessTokenFetcherForPrimaryAccount(
} }
void IdentityManager::RemoveAccessTokenFromCache( void IdentityManager::RemoveAccessTokenFromCache(
const AccountInfo& account_info, const std::string& account_id,
const OAuth2TokenService::ScopeSet& scopes, const OAuth2TokenService::ScopeSet& scopes,
const std::string& access_token) { const std::string& access_token) {
// TODO(843510): Consider making the request to ProfileOAuth2TokenService // TODO(843510): Consider making the request to ProfileOAuth2TokenService
...@@ -115,8 +115,7 @@ void IdentityManager::RemoveAccessTokenFromCache( ...@@ -115,8 +115,7 @@ void IdentityManager::RemoveAccessTokenFromCache(
// ProfileOAuth2TokenService::RequestAccessToken() to be made asynchronously // ProfileOAuth2TokenService::RequestAccessToken() to be made asynchronously
// as well (to maintain ordering in the case where a client removes an access // as well (to maintain ordering in the case where a client removes an access
// token from the cache and then immediately requests an access token). // token from the cache and then immediately requests an access token).
token_service_->InvalidateAccessToken(account_info.account_id, scopes, token_service_->InvalidateAccessToken(account_id, scopes, access_token);
access_token);
} }
void IdentityManager::AddObserver(Observer* observer) { void IdentityManager::AddObserver(Observer* observer) {
......
...@@ -139,7 +139,7 @@ class IdentityManager : public SigninManagerBase::Observer, ...@@ -139,7 +139,7 @@ class IdentityManager : public SigninManagerBase::Observer,
// given information, removes that entry; in this case, the next access token // given information, removes that entry; in this case, the next access token
// request for |account_id| and |scopes| will fetch a new token from the // request for |account_id| and |scopes| will fetch a new token from the
// network. Otherwise, is a no-op. // network. Otherwise, is a no-op.
void RemoveAccessTokenFromCache(const AccountInfo& account_info, void RemoveAccessTokenFromCache(const std::string& account_id,
const OAuth2TokenService::ScopeSet& scopes, const OAuth2TokenService::ScopeSet& scopes,
const std::string& access_token); const std::string& access_token);
......
...@@ -491,11 +491,7 @@ TEST_F(IdentityManagerTest, RemoveAccessTokenFromCache) { ...@@ -491,11 +491,7 @@ TEST_F(IdentityManagerTest, RemoveAccessTokenFromCache) {
token_service()->set_on_access_token_invalidated_info( token_service()->set_on_access_token_invalidated_info(
account_id, scopes, access_token, run_loop.QuitClosure()); account_id, scopes, access_token, run_loop.QuitClosure());
AccountInfo account_info; identity_manager()->RemoveAccessTokenFromCache(account_id, scopes,
account_info.account_id = account_id;
account_info.gaia = kTestGaiaId;
account_info.email = kTestEmail;
identity_manager()->RemoveAccessTokenFromCache(account_info, scopes,
access_token); access_token);
run_loop.Run(); run_loop.Run();
......
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