OAuth2TokenServiceDelegateAndroid::ValidateAccounts does the following:
// Clear accounts no longer exist on device from AccountTrackerService.
std::vector<AccountInfo> accounts_info =
account_tracker_service_->GetAccounts();
for (const AccountInfo& info : accounts_info) {
if (!base::ContainsValue(curr_ids, info.account_id))
account_tracker_service_->RemoveAccount(info.account_id);
}
I think this is redundant with code in SigninManager::OnRefreshTokensLoaded():
// Remove account information from the account tracker service if needed.
if (token_service_->HasLoadCredentialsFinishedWithNoErrors()) {
std::vector<AccountInfo> accounts_in_tracker_service =
account_tracker_service()->GetAccounts();
for (const auto& account : accounts_in_tracker_service) {
if (GetAuthenticatedAccountId() != account.account_id &&
!token_service_->RefreshTokenIsAvailable(account.account_id)) {
DVLOG(0) << "Removed account from account tracker service: "
<< account.account_id;
account_tracker_service()->RemoveAccount(account.account_id);
}
}
}
If this is duplicated, then code should be removed from OAuth2TokenServiceDelegateAndroid. If not (possibly because OAuth2TokenServiceDelegateAndroid does not fire OnRefreshTokensLoaded), then the code should probably be fixed so that SigninManager::OnRefreshTokensLoaded() is properly invoked and code is a duplicate.
Comment 1 Deleted