IdentityManager::GetPrimaryAccountInfo() and HasPrimaryAccountInfo()

14 views
Skip to first unread message

Chris Cunningham

unread,
Jul 23, 2018, 11:13:03 AM7/23/18
to identity-s...@chromium.org
Random thoughts about these APIs.

HasPrimaryAccountInfo is implemted as

bool IdentityManager::HasPrimaryAccount() const {
  return !primary_account_info_.account_id.empty();
}

But AccountInfo has a first-calls IsEmpty() method. Should we use that instead?

My other thought is, we might make this more self documenting by changing GetPrimaryAccountInfo() to return a base::Optional<AccountInfo>. All calls to HasPrimaryAccount() could be replaced with GetPrimaryAccountInfo().has_value() (or even better, you can just drop the has_value() since base::Optional implements the bool operator).

Chris

Sylvain Defresne

unread,
Jul 23, 2018, 11:24:42 AM7/23/18
to Chrome Cunningham, identity-service-dev
It is possible to have no information for the primary account besides account_id. This mean that we should eventually track the primary account id independently from the AccountInfo.

We discussed offline a possible refactoring were we change GetPrimaryAccountInfo() to GetPrimaryAccountId() and add a GetAccountInfoForAccountId() once we've refactored IdentityManager to track the primary account id only, and keep a map of account_id to AccountInfo for all accounts known to AccountTrackerService.
-- Sylvain

--
You received this message because you are subscribed to the Google Groups "identity-service-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to identity-service...@chromium.org.
To post to this group, send email to identity-s...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/identity-service-dev/CALG6eSqWZkYM5h%3DT_F5K--GfNbGE_28dULd5Dg6kh1q5JM%3DVqQ%40mail.gmail.com.

Colin Blundell

unread,
Jul 24, 2018, 10:32:22 AM7/24/18
to Sylvain Defresne, Chrome Cunningham, identity-service-dev
Good observations, Chris! As Sylvain mentioned, we are going to be changing how IdentityManager stores this information to clarify the relationship between having the account ID and having other elements of the AccountInfo. This will all be part of the work of extending IdentityManager to fully encompass the current functionality and use cases of AccountTrackerService.

Best,

Colin

Reply all
Reply to author
Forward
0 new messages