Skip to content

Commit

Permalink
[Android] Use native account info source in FRE and record fetch time
Browse files Browse the repository at this point in the history
This CL replaces the GmsProfileDataSource usage in FRE |Turn on Sync?|
screen with the native account info source and records the account info
fetch time.

Bug: 1181226
Change-Id: I743f39cb58016389537d148e6e10e86086efb6e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2734654
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#861561}
  • Loading branch information
Alice Wang authored and Chromium LUCI CQ committed Mar 10, 2021
1 parent 6f2114a commit 707d212
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.consent_auditor.ConsentAuditorFeature;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.services.DisplayableProfileData;
Expand Down Expand Up @@ -242,6 +243,12 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
? ProfileDataCache.createWithDefaultImageSize(
requireContext(), R.drawable.ic_account_child_20dp)
: ProfileDataCache.createWithDefaultImageSizeAndNoBadge(requireContext());

if (ChromeFeatureList.isEnabled(ChromeFeatureList.DEPRECATE_MENAGERIE_API)
&& mSigninAccessPoint == SigninAccessPoint.START_PAGE) {
mProfileDataCache.disableGmsProfileDataSource();
}

// By default this is set to true so that when system back button is pressed user action
// is recorded in onDestroy().
mRecordUndoSignin = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.chromium.components.signin.identitymanager;

import android.accounts.Account;
import android.os.SystemClock;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
Expand All @@ -13,10 +14,14 @@
import org.chromium.base.ObserverList;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.components.signin.base.AccountInfo;
import org.chromium.components.signin.base.CoreAccountId;
import org.chromium.components.signin.base.CoreAccountInfo;

import java.util.HashMap;
import java.util.Map;

/**
* IdentityManager provides access to native IdentityManager's public API to java components.
*/
Expand Down Expand Up @@ -56,6 +61,9 @@ public interface GetAccessTokenCallback
private ProfileOAuth2TokenServiceDelegate mProfileOAuth2TokenServiceDelegate;

private final ObserverList<Observer> mObservers = new ObserverList<>();
// Account id and the corresponding fetch start time, this is only used to record the
// account information fetch duration.
private final Map<CoreAccountId, Long> mAccountAndFetchStartTimes = new HashMap<>();

/**
* Called by native to create an instance of IdentityManager.
Expand Down Expand Up @@ -122,6 +130,14 @@ public void onAccountsCookieDeletedByUserAction() {
@CalledByNative
@VisibleForTesting
public void onExtendedAccountInfoUpdated(AccountInfo accountInfo) {
final CoreAccountId accountId = accountInfo.getId();
if (accountInfo.getAccountImage() != null
&& mAccountAndFetchStartTimes.containsKey(accountId)) {
long startTime = mAccountAndFetchStartTimes.get(accountId);
RecordHistogram.recordTimesHistogram("Signin.AndroidAccountInfoFetchTime",
SystemClock.elapsedRealtime() - startTime);
mAccountAndFetchStartTimes.remove(accountId);
}
for (Observer observer : mObservers) {
observer.onExtendedAccountInfoUpdated(accountInfo);
}
Expand Down Expand Up @@ -174,6 +190,7 @@ public CoreAccountInfo[] getAccountsWithRefreshTokens() {
*/
public void forceRefreshOfExtendedAccountInfo(CoreAccountId coreAccountId) {
assert coreAccountId != null : "coreAccountId shouldn't be null!";
mAccountAndFetchStartTimes.put(coreAccountId, SystemClock.elapsedRealtime());
IdentityManagerJni.get().forceRefreshOfExtendedAccountInfo(
mNativeIdentityManager, coreAccountId);
}
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/histograms_xml/signin/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ prefs when the profile is loaded. -->
</summary>
</histogram>

<histogram name="Signin.AndroidAccountInfoFetchTime" units="ms"
expires_after="2021-08-16">
<owner>aliceywang@chromium.org</owner>
<owner>chrome-signin-team@google.com</owner>
<summary>
The time it takes to fetch the account information (user names, avatar) for
one account on Android. This is recorded when account information is
downloaded in FRE or when there is an accounts change event.
</summary>
</histogram>

<histogram name="Signin.AndroidAccountSigninViewSeedingTime" units="ms"
expires_after="M89">
<owner>bsazonov@chromium.org</owner>
Expand Down

0 comments on commit 707d212

Please sign in to comment.