Commit 8f1112c1 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[GCM] Clean up AccountTracker public API

This CL restricts the AccountTracker public API to what's actually
used by GCMAccountTracker, its only client. This helps to clarify what
the purpose of AccountTracker is.

The CL also removes an AccountTracker unittest that was calling into a
now-private API. That test checks that a token revocation doesn't
cause any AccountTracker event to fire if the token was never made
available in the first place. That sequence of events (token revocation
being fired by OAuth2TokenService without the token first being made
available) doesn't reflect reality, so there is no purpose in testing
for it.

Change-Id: Ic3085897b87895faa6cf0c3d5d5d9f6520d0c808
Reviewed-on: https://chromium-review.googlesource.com/1046832
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561013}
parent 94d9e60a
...@@ -113,22 +113,6 @@ void AccountTracker::GoogleSignedOut(const std::string& account_id, ...@@ -113,22 +113,6 @@ void AccountTracker::GoogleSignedOut(const std::string& account_id,
StopTrackingAllAccounts(); StopTrackingAllAccounts();
} }
void AccountTracker::SetAccountStateForTest(AccountIds ids, bool is_signed_in) {
accounts_[ids.account_key].ids = ids;
accounts_[ids.account_key].is_signed_in = is_signed_in;
DVLOG(1) << "SetAccountStateForTest " << ids.account_key << ":"
<< is_signed_in;
if (VLOG_IS_ON(1)) {
for (std::map<std::string, AccountState>::const_iterator it =
accounts_.begin();
it != accounts_.end(); ++it) {
DVLOG(1) << it->first << ":" << it->second.is_signed_in;
}
}
}
void AccountTracker::NotifySignInChanged(const AccountState& account) { void AccountTracker::NotifySignInChanged(const AccountState& account) {
DCHECK(!account.ids.gaia.empty()); DCHECK(!account.ids.gaia.empty());
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
......
...@@ -65,6 +65,18 @@ class AccountTracker : public OAuth2TokenService::Observer, ...@@ -65,6 +65,18 @@ class AccountTracker : public OAuth2TokenService::Observer,
// in the vector. Additional accounts will be in order of their gaia IDs. // in the vector. Additional accounts will be in order of their gaia IDs.
std::vector<AccountIds> GetAccounts() const; std::vector<AccountIds> GetAccounts() const;
// Indicates if all user information has been fetched. If the result is false,
// there are still unfinished fetchers.
virtual bool IsAllUserInfoFetched() const;
private:
friend class AccountIdFetcher;
struct AccountState {
AccountIds ids;
bool is_signed_in;
};
// OAuth2TokenService::Observer implementation. // OAuth2TokenService::Observer implementation.
void OnRefreshTokenAvailable(const std::string& account_key) override; void OnRefreshTokenAvailable(const std::string& account_key) override;
void OnRefreshTokenRevoked(const std::string& account_key) override; void OnRefreshTokenRevoked(const std::string& account_key) override;
...@@ -79,19 +91,6 @@ class AccountTracker : public OAuth2TokenService::Observer, ...@@ -79,19 +91,6 @@ class AccountTracker : public OAuth2TokenService::Observer,
void GoogleSignedOut(const std::string& account_id, void GoogleSignedOut(const std::string& account_id,
const std::string& username) override; const std::string& username) override;
// Sets the state of an account. Does not fire notifications.
void SetAccountStateForTest(AccountIds ids, bool is_signed_in);
// Indicates if all user information has been fetched. If the result is false,
// there are still unfinished fetchers.
virtual bool IsAllUserInfoFetched() const;
private:
struct AccountState {
AccountIds ids;
bool is_signed_in;
};
void NotifySignInChanged(const AccountState& account); void NotifySignInChanged(const AccountState& account);
void UpdateSignInState(const std::string& account_key, bool is_signed_in); void UpdateSignInState(const std::string& account_key, bool is_signed_in);
......
...@@ -518,13 +518,6 @@ TEST_F(AccountTrackerTest, Available) { ...@@ -518,13 +518,6 @@ TEST_F(AccountTrackerTest, Available) {
observer()->CheckEvents(TrackingEvent(SIGN_IN, "user@example.com"))); observer()->CheckEvents(TrackingEvent(SIGN_IN, "user@example.com")));
} }
TEST_F(AccountTrackerTest, Revoke) {
SetupPrimaryLogin();
account_tracker()->OnRefreshTokenRevoked("user@example.com");
EXPECT_TRUE(observer()->CheckEvents());
}
TEST_F(AccountTrackerTest, AvailableRevokeAvailable) { TEST_F(AccountTrackerTest, AvailableRevokeAvailable) {
SetupPrimaryLogin(); SetupPrimaryLogin();
......
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