Commit 383bb87c authored by bzanotti's avatar bzanotti Committed by Commit bot

Actually mark list accounts as stale while they're being fetched.

GCMS::OnCookieChanged needs to always mark the list accounts as stale,
even when they're being fetched. Otherwise, a call to
GCMS::ListAccounts could return an invalid list if called right after
GCMS::OnCookieChanged.

BUG=558367

Review URL: https://codereview.chromium.org/1448983002

Cr-Commit-Position: refs/heads/master@{#361312}
parent 1a79db29
......@@ -448,6 +448,7 @@ void GaiaCookieManagerService::OnCookieChanged(
bool removed) {
DCHECK_EQ(kGaiaCookieName, cookie.Name());
DCHECK_EQ(GaiaUrls::GetInstance()->google_url().host(), cookie.Domain());
list_accounts_stale_ = true;
// Ignore changes to the cookie while requests are pending. These changes
// are caused by the service itself as it adds accounts. A side effects is
// that any changes to the gaia cookie outside of this class, while requests
......@@ -459,8 +460,6 @@ void GaiaCookieManagerService::OnCookieChanged(
signin_client_->DelayNetworkCall(
base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts,
base::Unretained(this)));
} else {
list_accounts_stale_ = true;
}
}
......
......@@ -556,6 +556,35 @@ TEST_F(GaiaCookieManagerServiceTest, ListAccountsFindsOneAccount) {
"[\"f\", [[\"b\", 0, \"n\", \"a@b.com\", \"p\", 0, 0, 0, 0, 1, \"8\"]]]");
}
TEST_F(GaiaCookieManagerServiceTest, ListAccountsAfterOnCookieChanged) {
InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
MockObserver observer(&helper);
std::vector<gaia::ListedAccount> list_accounts;
std::vector<gaia::ListedAccount> empty_list_accounts;
EXPECT_CALL(helper, StartFetchingListAccounts());
EXPECT_CALL(observer,
OnGaiaAccountsInCookieUpdated(empty_list_accounts, no_error()));
ASSERT_FALSE(helper.ListAccounts(&list_accounts));
ASSERT_TRUE(list_accounts.empty());
SimulateListAccountsSuccess(&helper, "[\"f\",[]]");
// ListAccounts returns cached data.
ASSERT_TRUE(helper.ListAccounts(&list_accounts));
ASSERT_TRUE(list_accounts.empty());
EXPECT_CALL(helper, StartFetchingListAccounts());
EXPECT_CALL(observer,
OnGaiaAccountsInCookieUpdated(empty_list_accounts, no_error()));
helper.ForceOnCookieChangedProcessing();
// OnCookieChanged should invalidate cached data.
ASSERT_FALSE(helper.ListAccounts(&list_accounts));
ASSERT_TRUE(list_accounts.empty());
SimulateListAccountsSuccess(&helper, "[\"f\",[]]");
}
TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcher) {
InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
GaiaCookieManagerService::ExternalCcResultFetcher result_fetcher(&helper);
......
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