Commit 3c29e40c authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Unify AccountInvestigator::On{Gaia}AccountsInCookieUpdated

Actual work has been done in https://crrev.com/c/1396240, but a method
named OnGaiaAccountsInCookieUpdated is still around (although it does
not override GSSM::Observer), which is confusing.

This CL unify both AccountInvestigator::OnAccountsInCookieUpdated
and AccountInvestigator::OnGaiaAccountsInCookieUpdated methods,
eliminating this confusion.

BUG=926884

Change-Id: Ifbe0eb301aae966cfbd04ee6cbfcb41f149eb0a0
Reviewed-on: https://chromium-review.googlesource.com/c/1454305
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629543}
parent 961d0cda
......@@ -84,21 +84,17 @@ void AccountInvestigator::OnAddAccountToCookieCompleted(
void AccountInvestigator::OnAccountsInCookieUpdated(
const identity::AccountsInCookieJarInfo& accounts_in_cookie_jar_info,
const GoogleServiceAuthError& error) {
OnGaiaAccountsInCookieUpdated(accounts_in_cookie_jar_info.signed_in_accounts,
accounts_in_cookie_jar_info.signed_out_accounts,
error);
}
void AccountInvestigator::OnGaiaAccountsInCookieUpdated(
const std::vector<ListedAccount>& signed_in_accounts,
const std::vector<ListedAccount>& signed_out_accounts,
const GoogleServiceAuthError& error) {
if (error != GoogleServiceAuthError::AuthErrorNone()) {
// If we are pending periodic reporting, leave the flag set, and we will
// continue next time the ListAccounts call succeeds.
return;
}
const std::vector<ListedAccount>& signed_in_accounts(
accounts_in_cookie_jar_info.signed_in_accounts);
const std::vector<ListedAccount>& signed_out_accounts(
accounts_in_cookie_jar_info.signed_out_accounts);
// Handling this is tricky. We could be here because there was a change. We
// could be here because we tried to do periodic reporting but there wasn't
// a valid cached ListAccounts response ready for us. Or even both of these
......
......@@ -62,13 +62,6 @@ class AccountInvestigator : public KeyedService,
const identity::AccountsInCookieJarInfo& accounts_in_cookie_jar_info,
const GoogleServiceAuthError& error) override;
// Internal implementation of OnAccountsInCookieUpdated. It is public given
// that it is called directly by unittests.
void OnGaiaAccountsInCookieUpdated(
const std::vector<gaia::ListedAccount>& signed_in_accounts,
const std::vector<gaia::ListedAccount>& signed_out_accounts,
const GoogleServiceAuthError& error);
private:
friend class AccountInvestigatorTest;
......
......@@ -263,30 +263,37 @@ TEST_F(AccountInvestigatorTest, SharedCookieJarReportWithAccount) {
TEST_F(AccountInvestigatorTest, OnGaiaAccountsInCookieUpdatedError) {
const HistogramTester histogram_tester;
identity::AccountsInCookieJarInfo accounts_in_cookie_jar_info = {
/*accounts_are_fresh=*/true, just_one, no_accounts};
GoogleServiceAuthError error(GoogleServiceAuthError::SERVICE_UNAVAILABLE);
investigator()->OnGaiaAccountsInCookieUpdated(just_one, no_accounts, error);
investigator()->OnAccountsInCookieUpdated(accounts_in_cookie_jar_info, error);
EXPECT_EQ(0u, histogram_tester.GetTotalCountsForPrefix("Signin.").size());
}
TEST_F(AccountInvestigatorTest, OnGaiaAccountsInCookieUpdatedOnChange) {
const HistogramTester histogram_tester;
investigator()->OnGaiaAccountsInCookieUpdated(
just_one, no_accounts, GoogleServiceAuthError::AuthErrorNone());
identity::AccountsInCookieJarInfo accounts_in_cookie_jar_info = {
/*accounts_are_fresh=*/true, just_one, no_accounts};
investigator()->OnAccountsInCookieUpdated(
accounts_in_cookie_jar_info, GoogleServiceAuthError::AuthErrorNone());
ExpectSharedReportHistograms(ReportingType::ON_CHANGE, histogram_tester,
nullptr, 1, 0, 1, nullptr, false);
}
TEST_F(AccountInvestigatorTest, OnGaiaAccountsInCookieUpdatedSigninOnly) {
// Initial update to simulate the update on first-time-run.
investigator()->OnGaiaAccountsInCookieUpdated(
no_accounts, no_accounts, GoogleServiceAuthError::AuthErrorNone());
investigator()->OnAccountsInCookieUpdated(
identity::AccountsInCookieJarInfo(),
GoogleServiceAuthError::AuthErrorNone());
const HistogramTester histogram_tester;
identity_test_env()->SetPrimaryAccount("1@mail.com");
pref_service()->SetString(prefs::kGaiaCookieHash,
Hash(just_one, no_accounts));
investigator()->OnGaiaAccountsInCookieUpdated(
just_one, no_accounts, GoogleServiceAuthError::AuthErrorNone());
identity::AccountsInCookieJarInfo accounts_in_cookie_jar_info = {
/*accounts_are_fresh=*/true, just_one, no_accounts};
investigator()->OnAccountsInCookieUpdated(
accounts_in_cookie_jar_info, GoogleServiceAuthError::AuthErrorNone());
EXPECT_EQ(1u, histogram_tester.GetTotalCountsForPrefix("Signin.").size());
ExpectRelationReport(ReportingType::ON_CHANGE, histogram_tester,
AccountRelation::SINGLE_SIGNED_IN_MATCH_NO_SIGNED_OUT);
......@@ -296,15 +303,19 @@ TEST_F(AccountInvestigatorTest,
OnGaiaAccountsInCookieUpdatedSigninSignOutOfContent) {
const HistogramTester histogram_tester;
identity_test_env()->SetPrimaryAccount("1@mail.com");
investigator()->OnGaiaAccountsInCookieUpdated(
just_one, no_accounts, GoogleServiceAuthError::AuthErrorNone());
identity::AccountsInCookieJarInfo accounts_in_cookie_jar_info = {
/*accounts_are_fresh=*/true, just_one, no_accounts};
investigator()->OnAccountsInCookieUpdated(
accounts_in_cookie_jar_info, GoogleServiceAuthError::AuthErrorNone());
ExpectRelationReport(ReportingType::ON_CHANGE, histogram_tester,
AccountRelation::SINGLE_SIGNED_IN_MATCH_NO_SIGNED_OUT);
// Simulate a sign out of the content area.
const HistogramTester histogram_tester2;
investigator()->OnGaiaAccountsInCookieUpdated(
no_accounts, just_one, GoogleServiceAuthError::AuthErrorNone());
accounts_in_cookie_jar_info = {/*accounts_are_fresh=*/true, no_accounts,
just_one};
investigator()->OnAccountsInCookieUpdated(
accounts_in_cookie_jar_info, GoogleServiceAuthError::AuthErrorNone());
const AccountRelation expected_relation =
AccountRelation::NO_SIGNED_IN_SINGLE_SIGNED_OUT_MATCH;
ExpectSharedReportHistograms(ReportingType::ON_CHANGE, histogram_tester2,
......
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