Skip to content

Commit

Permalink
[Merge-90][SH-Andriod] Add UMA histograms for preemptive link generat…
Browse files Browse the repository at this point in the history
…ion.

Add UMA histograms for preemptive link generation for Shared Highlights.

(cherry picked from commit d97934a)

Bug: 1183568
Change-Id: I06b41f6d12b6619edc5f24298c74bc5779b7204a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2727074
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#859591}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2739077
Reviewed-by: sebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/branch-heads/4430@{#233}
Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
  • Loading branch information
Gayane Petrosyan authored and Chromium LUCI CQ committed Mar 8, 2021
1 parent 9dd84f3 commit 041e3ad
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.chromium.base.CollectionUtil;
import org.chromium.base.Consumer;
import org.chromium.base.PackageManagerUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
Expand Down Expand Up @@ -99,6 +100,9 @@ static class ActionModeCallback implements ActionMode.Callback {
private final Callback<String> mSearchCallback;
private final Supplier<ShareDelegate> mShareDelegateSupplier;

// Used for recording UMA histograms.
private long mContextMenuStartTime;

ActionModeCallback(Tab tab, WebContents webContents, Consumer<Boolean> observer,
Callback<String> searchCallback, Supplier<ShareDelegate> shareDelegateSupplier) {
mTab = tab;
Expand All @@ -116,6 +120,7 @@ protected ActionModeCallbackHelper getActionModeCallbackHelper(WebContents webCo

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mContextMenuStartTime = System.currentTimeMillis();
notifyContextualActionBarVisibilityChanged(true);

int allowedActionModes = ActionModeCallbackHelper.MENU_ITEM_PROCESS_TEXT
Expand Down Expand Up @@ -168,6 +173,8 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
} else if (mShareDelegateSupplier.get().isSharingHubV15Enabled()
&& item.getItemId() == R.id.select_action_menu_share) {
RecordUserAction.record(SelectionPopupController.UMA_MOBILE_ACTION_MODE_SHARE);
RecordHistogram.recordMediumTimesHistogram("ContextMenu.TimeToSelectShare",
System.currentTimeMillis() - mContextMenuStartTime);
mShareDelegateSupplier.get().share(
new ShareParams.Builder(mTab.getWindowAndroid(), /*url=*/"", /*title=*/"")
.setText(sanitizeTextForShare(mHelper.getSelectedText()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import androidx.annotation.IntDef;

import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.PostTask;
import org.chromium.blink.mojom.TextFragmentSelectorProducer;
import org.chromium.chrome.R;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class LinkToTextCoordinator extends EmptyTabObserver {
private final ChromeShareExtras mChromeShareExtras;
private final long mShareStartTime;
private final ShareParams mShareTextParams;
private final long mRequestSelectorStartTime;

private ShareParams mShareLinkParams;
private TextFragmentSelectorProducer mProducer;
Expand All @@ -64,6 +66,7 @@ public LinkToTextCoordinator(Context context, Tab tab,
mChromeShareExtras = null;
mShareStartTime = 0;
mShareTextParams = null;
mRequestSelectorStartTime = System.currentTimeMillis();

requestSelector();
}
Expand All @@ -83,6 +86,7 @@ public LinkToTextCoordinator(ShareParams shareParams, Tab tab,
mCancelRequest = false;
mContext = null;

mRequestSelectorStartTime = System.currentTimeMillis();
requestSelector();
PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, () -> timeout(), TIMEOUT_MS);
}
Expand All @@ -97,6 +101,9 @@ public ShareParams getShareParams(@LinkGeneration int linkGeneration) {
}

public void onSelectorReady(String selector) {
RecordHistogram.recordTimesHistogram(
"Sharing.SharingHubAndroid.SharedHighlights.TimeToGetLinkToText",
System.currentTimeMillis() - mRequestSelectorStartTime);
if (mCancelRequest) return;

if (ChromeFeatureList.isEnabled(ChromeFeatureList.PREEMPTIVE_LINK_TO_TEXT_GENERATION)) {
Expand Down
10 changes: 10 additions & 0 deletions tools/metrics/histograms/histograms_xml/others/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3271,6 +3271,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>

<histogram name="ContextMenu.TimeToSelectShare" units="ms"
expires_after="2021-07-11">
<owner>gayane@chromium.org</owner>
<owner>chrome-shared-highlighting@google.com</owner>
<summary>
Records how long it takes to press on &quot;Share&quot; from the time
context menu is shown. Android only.
</summary>
</histogram>

<histogram name="ContextMenu.TimeToTakeAction.Abandoned" units="ms"
expires_after="2021-08-01">
<owner>twellington@chromium.org</owner>
Expand Down
12 changes: 12 additions & 0 deletions tools/metrics/histograms/histograms_xml/sharing/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>

<histogram
name="Sharing.SharingHubAndroid.SharedHighlights.TimeToGetLinkToText"
units="ms" expires_after="2021-07-11">
<owner>gayane@chromium.org</owner>
<owner>chrome-shared-highlighting@google.com</owner>
<summary>
Records time it takes to fulfill a link-to-text request. Recorded even if
request fails. Corresponds to how long is Sharing Hub delayed because of
link-to-text.
</summary>
</histogram>

<histogram name="Sharing.SharingHubAndroid.ThirdPartyAppUsage"
enum="SharingHubBottomRowIndex" expires_after="M97">
<owner>kmilka@chromium.org</owner>
Expand Down

0 comments on commit 041e3ad

Please sign in to comment.