Commit ccb4217d authored by Salvador Guerrero's avatar Salvador Guerrero Committed by Commit Bot

Revert "metrics: Remove CachedMetrics"

This reverts commit 1231840e.

Reason for revert: Causing build failures in android-internal-chromium-tot
https://ci.chromium.org/p/chrome/builders/ci/android-internal-chromium-tot

Original change's description:
> metrics: Remove CachedMetrics
> 
> Bug: 1048429
> Change-Id: Ib5b5ee1d07492eb30b754320f6527acd5cda60f4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079255
> Commit-Queue: bttk <bttk@chromium.org>
> Reviewed-by: Filip Gorski <fgorski@chromium.org>
> Reviewed-by: Pavel Yatsuk <pavely@chromium.org>
> Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#752614}

TBR=yfriedman@chromium.org,fgorski@chromium.org,pavely@chromium.org,bttk@chromium.org

Change-Id: I3af9a0200e42e332c647ccb3d73f2cd756b0dc04
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1048429
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2117153Reviewed-by: default avatarSalvador Guerrero <salg@google.com>
Commit-Queue: Salvador Guerrero <salg@google.com>
Cr-Commit-Position: refs/heads/master@{#752641}
parent 023dd772
......@@ -3352,6 +3352,7 @@ if (is_android) {
"android/java/src/org/chromium/base/memory/MemoryPressureCallback.java",
"android/java/src/org/chromium/base/memory/MemoryPressureMonitor.java",
"android/java/src/org/chromium/base/memory/MemoryPressureUma.java",
"android/java/src/org/chromium/base/metrics/CachedMetrics.java",
"android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java",
"android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
"android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java",
......
......@@ -30,11 +30,13 @@ import org.chromium.base.NativeLibraryLoadedStatus.NativeLibraryLoadedStatusProv
import org.chromium.base.StreamUtil;
import org.chromium.base.StrictModeContext;
import org.chromium.base.TraceEvent;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.annotations.RemovableInRelease;
import org.chromium.base.compat.ApiHelperForM;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.UmaRecorderHolder;
......@@ -735,6 +737,11 @@ public class LibraryLoader {
}
}
@CalledByNative
public static void onUmaRecordingReadyInRenderer() {
CachedMetrics.commitCachedMetrics();
}
// Android system sometimes fails to extract libraries from APK (https://crbug.com/806998).
// This function manually extract libraries as a fallback.
@SuppressLint({"SetWorldReadable"})
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.base.metrics;
import org.chromium.base.library_loader.LibraryLoader;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.concurrent.GuardedBy;
/**
* Utility classes for recording UMA metrics before the native library
* may have been loaded. Metrics are cached until the library is known
* to be loaded, then committed to the MetricsService all at once.
*
* NOTE: Currently supports recording metrics only in Browser/Webview/Renderer processes.
*/
public class CachedMetrics {
/**
* Base class for cached metric objects. Subclasses are expected to call
* addToCache() when some metric state gets recorded that requires a later
* commit operation when the native library is loaded.
*/
private abstract static class CachedMetric {
@GuardedBy("sMetrics")
private static final List<CachedMetric> sMetrics = new ArrayList<CachedMetric>();
/**
* Randomly choose whether to always immediately invoke {@link RecordHistogram}. This value
* is recorded using a synthetic field trial.
*/
protected static final boolean HISTOGRAMS_BYPASS_CACHE = Math.random() < 0.5;
protected final String mName;
protected boolean mCached;
/**
* @param name Name of the metric to record.
*/
protected CachedMetric(String name) {
mName = name;
}
/**
* Adds this object to the sMetrics cache, if it hasn't been added already.
* Must be called while holding the synchronized(sMetrics) lock.
* Note: The synchronization is not done inside this function because subclasses
* need to increment their held values under lock to ensure thread-safety.
*/
@GuardedBy("sMetrics")
protected final void addToCache() {
assert Thread.holdsLock(sMetrics);
if (mCached) return;
sMetrics.add(this);
mCached = true;
}
/**
* Commits the metric. Expects the native library to be loaded.
* Must be called while holding the synchronized(sMetrics) lock.
*/
@GuardedBy("sMetrics")
protected abstract void commitAndClear();
/**
* Returns {@code true} if histogram samples should be immediately recorded.
* <p>
* Handles two cases:
* <ul>
* <li>Cache is not needed, because {@link LibraryLoader} is already initialized.
* <li>Cache is disabled to validate caching present in {@link RecordHistogram}.
* </ul>
*/
protected static boolean shouldHistogramBypassCache() {
return HISTOGRAMS_BYPASS_CACHE || LibraryLoader.getInstance().isInitialized();
}
}
/**
* Caches an action that will be recorded after native side is loaded.
*/
public static class ActionEvent extends CachedMetric {
@GuardedBy("CachedMetric.sMetrics")
private int mCount;
public ActionEvent(String actionName) {
super(actionName);
}
public void record() {
synchronized (CachedMetric.sMetrics) {
if (LibraryLoader.getInstance().isInitialized()) {
recordWithNative();
} else {
mCount++;
addToCache();
}
}
}
private void recordWithNative() {
RecordUserAction.record(mName);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
while (mCount > 0) {
recordWithNative();
mCount--;
}
}
}
/**
* Caches a set of integer histogram samples.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class SparseHistogramSample extends CachedMetric {
@GuardedBy("CachedMetric.sMetrics")
private final List<Integer> mSamples = new ArrayList<Integer>();
public SparseHistogramSample(String histogramName) {
super(histogramName);
}
public void record(int sample) {
synchronized (CachedMetric.sMetrics) {
if (shouldHistogramBypassCache()) {
recordWithNative(sample);
} else {
mSamples.add(sample);
addToCache();
}
}
}
private void recordWithNative(int sample) {
RecordHistogram.recordSparseHistogram(mName, sample);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
for (Integer sample : mSamples) {
recordWithNative(sample);
}
mSamples.clear();
}
}
/**
* Caches a set of enumerated histogram samples.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class EnumeratedHistogramSample extends CachedMetric {
private final List<Integer> mSamples = new ArrayList<Integer>();
private final int mMaxValue;
public EnumeratedHistogramSample(String histogramName, int maxValue) {
super(histogramName);
mMaxValue = maxValue;
}
public void record(int sample) {
synchronized (CachedMetric.sMetrics) {
if (shouldHistogramBypassCache()) {
recordWithNative(sample);
} else {
mSamples.add(sample);
addToCache();
}
}
}
private void recordWithNative(int sample) {
RecordHistogram.recordEnumeratedHistogram(mName, sample, mMaxValue);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
for (Integer sample : mSamples) {
recordWithNative(sample);
}
mSamples.clear();
}
}
/**
* Caches a set of times histogram samples.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class TimesHistogramSample extends CachedMetric {
@GuardedBy("CachedMetric.sMetrics")
private final List<Long> mSamples = new ArrayList<Long>();
public TimesHistogramSample(String histogramName) {
super(histogramName);
}
public void record(long sample) {
synchronized (CachedMetric.sMetrics) {
if (shouldHistogramBypassCache()) {
recordWithNative(sample);
} else {
mSamples.add(sample);
addToCache();
}
}
}
protected void recordWithNative(long sample) {
RecordHistogram.recordTimesHistogram(mName, sample);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
for (Long sample : mSamples) {
recordWithNative(sample);
}
mSamples.clear();
}
}
/**
* Caches a set of times histogram samples, calls
* {@link RecordHistogram#recordMediumTimesHistogram(String, long)}.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class MediumTimesHistogramSample extends TimesHistogramSample {
public MediumTimesHistogramSample(String histogramName) {
super(histogramName);
}
@Override
protected void recordWithNative(long sample) {
RecordHistogram.recordMediumTimesHistogram(mName, sample);
}
}
/**
* Caches a set of boolean histogram samples.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class BooleanHistogramSample extends CachedMetric {
@GuardedBy("CachedMetric.sMetrics")
private final List<Boolean> mSamples = new ArrayList<Boolean>();
public BooleanHistogramSample(String histogramName) {
super(histogramName);
}
public void record(boolean sample) {
synchronized (CachedMetric.sMetrics) {
if (shouldHistogramBypassCache()) {
recordWithNative(sample);
} else {
mSamples.add(sample);
addToCache();
}
}
}
private void recordWithNative(boolean sample) {
RecordHistogram.recordBooleanHistogram(mName, sample);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
for (Boolean sample : mSamples) {
recordWithNative(sample);
}
mSamples.clear();
}
}
/**
* Caches a set of custom count histogram samples.
* Corresponds to UMA_HISTOGRAM_CUSTOM_COUNTS C++ macro.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class CustomCountHistogramSample extends CachedMetric {
@GuardedBy("CachedMetric.sMetrics")
private final List<Integer> mSamples = new ArrayList<Integer>();
protected final int mMin;
protected final int mMax;
protected final int mNumBuckets;
public CustomCountHistogramSample(String histogramName, int min, int max, int numBuckets) {
super(histogramName);
mMin = min;
mMax = max;
mNumBuckets = numBuckets;
}
public void record(int sample) {
synchronized (CachedMetric.sMetrics) {
if (shouldHistogramBypassCache()) {
recordWithNative(sample);
} else {
mSamples.add(sample);
addToCache();
}
}
}
protected void recordWithNative(int sample) {
RecordHistogram.recordCustomCountHistogram(mName, sample, mMin, mMax, mNumBuckets);
}
@Override
@GuardedBy("CachedMetric.sMetrics")
protected void commitAndClear() {
for (Integer sample : mSamples) {
recordWithNative(sample);
}
mSamples.clear();
}
}
/**
* Caches a set of count histogram samples in range [1, 100).
* Corresponds to UMA_HISTOGRAM_COUNTS_100 C++ macro.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class Count100HistogramSample extends CustomCountHistogramSample {
public Count100HistogramSample(String histogramName) {
super(histogramName, 1, 100, 50);
}
}
/**
* Caches a set of count histogram samples in range [1, 1000).
* Corresponds to UMA_HISTOGRAM_COUNTS_1000 C++ macro.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class Count1000HistogramSample extends CustomCountHistogramSample {
public Count1000HistogramSample(String histogramName) {
super(histogramName, 1, 1000, 50);
}
}
/**
* Caches a set of count histogram samples in range [1, 1000000).
* Corresponds to UMA_HISTOGRAM_COUNTS_1M C++ macro.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class Count1MHistogramSample extends CustomCountHistogramSample {
public Count1MHistogramSample(String histogramName) {
super(histogramName, 1, 1000000, 50);
}
}
/**
* Caches a set of linear count histogram samples.
*
* @deprecated Use {@link RecordHistogram} instead.
*/
@Deprecated
public static class LinearCountHistogramSample extends CustomCountHistogramSample {
public LinearCountHistogramSample(String histogramName, int min, int max, int numBuckets) {
super(histogramName, min, max, numBuckets);
}
@Override
protected void recordWithNative(int sample) {
RecordHistogram.recordLinearCountHistogram(mName, sample, mMin, mMax, mNumBuckets);
}
}
/**
* Calls out to native code to commit any cached histograms and events.
* Should be called once the native library has been initialized.
*/
public static void commitCachedMetrics() {
synchronized (CachedMetric.sMetrics) {
for (CachedMetric metric : CachedMetric.sMetrics) {
metric.commitAndClear();
}
}
}
/** Returns true if histograms are immediately recorded with {@link UmaRecorder}. */
public static boolean histogramsBypassCache() {
return CachedMetric.HISTOGRAMS_BYPASS_CACHE;
}
}
......@@ -10,6 +10,7 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.metrics.RecordHistogram;
import java.util.HashMap;
......@@ -69,12 +70,14 @@ public class ShadowRecordHistogram {
@Implementation
public static int getHistogramValueCountForTesting(String name, int sample) {
CachedMetrics.commitCachedMetrics();
Integer i = sSamples.get(Pair.create(name, sample));
return (i != null) ? i : 0;
}
@Implementation
public static int getHistogramTotalCountForTesting(String name) {
CachedMetrics.commitCachedMetrics();
Integer i = sTotals.get(name);
return (i != null) ? i : 0;
}
......
......@@ -70,6 +70,9 @@ void RecordLibraryLoaderRendererHistograms() {
UMA_HISTOGRAM_TIMES(
"ChromiumAndroidLinker.RendererLoadTime",
base::TimeDelta::FromMilliseconds(g_renderer_library_load_time_ms));
Java_LibraryLoader_onUmaRecordingReadyInRenderer(
base::android::AttachCurrentThread());
}
void SetLibraryLoadedHook(LibraryLoadedHook* func) {
......
......@@ -21,7 +21,7 @@ import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
import org.chromium.base.Log;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider;
......@@ -45,6 +45,10 @@ import javax.inject.Inject;
@ActivityScope
public class CustomTabBottomBarDelegate implements FullscreenListener {
private static final String TAG = "CustomTab";
private static final CachedMetrics.ActionEvent REMOTE_VIEWS_SHOWN =
new CachedMetrics.ActionEvent("CustomTabsRemoteViewsShown");
private static final CachedMetrics.ActionEvent REMOTE_VIEWS_UPDATED =
new CachedMetrics.ActionEvent("CustomTabsRemoteViewsUpdated");
private static final int SLIDE_ANIMATION_DURATION_MS = 400;
private final ChromeActivity<?> mActivity;
......@@ -117,7 +121,7 @@ public class CustomTabBottomBarDelegate implements FullscreenListener {
RemoteViews remoteViews = mDataProvider.getBottomBarRemoteViews();
if (remoteViews != null) {
RecordUserAction.record("CustomTabsRemoteViewsShown");
REMOTE_VIEWS_SHOWN.record();
mClickableIDs = mDataProvider.getClickableViewIDs();
mClickPendingIntent = mDataProvider.getRemoteViewsPendingIntent();
showRemoteViews(remoteViews);
......@@ -162,7 +166,7 @@ public class CustomTabBottomBarDelegate implements FullscreenListener {
*/
public boolean updateRemoteViews(RemoteViews remoteViews, int[] clickableIDs,
PendingIntent pendingIntent) {
RecordUserAction.record("CustomTabsRemoteViewsUpdated");
REMOTE_VIEWS_UPDATED.record();
if (remoteViews == null) {
if (mBottomBarView == null) return false;
hideBottomBar();
......
......@@ -10,7 +10,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import org.chromium.base.Callback;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.supplier.Supplier;
import java.util.LinkedHashSet;
......@@ -27,6 +27,15 @@ import java.util.function.Consumer;
*/
@TargetApi(29)
public abstract class DirectActionCoordinator {
/**
* Tracks calls to {@link #onGetDirectActions}.
*
* <p>This corresponds to a user triggering the assist app while a Chrome activity is in the
* foreground.
*/
private static final CachedMetrics.ActionEvent LIST_ACTION_EVENT =
new CachedMetrics.ActionEvent("Android.DirectAction.List");
private final Set<DirectActionHandler> mHandlers = new LinkedHashSet<>();
/**
......@@ -55,7 +64,7 @@ public abstract class DirectActionCoordinator {
}
}
reporter.report();
RecordUserAction.record("Android.DirectAction.List");
LIST_ACTION_EVENT.record();
}
/** Performs an action and reports the result to the callback. */
......
......@@ -12,7 +12,7 @@ import android.content.DialogInterface;
import com.google.android.gms.common.GoogleApiAvailability;
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.metrics.CachedMetrics.ActionEvent;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -40,6 +40,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
* subclassing this class.
*/
public abstract class UserRecoverableErrorHandler {
private static final ActionEvent sModalDialogShownActionEvent =
new ActionEvent("Signin_Android_GmsUserRecoverableDialogShown");
private static final ActionEvent sModalDialogAcceptedActionEvent =
new ActionEvent("Signin_Android_GmsUserRecoverableDialogAccepted");
/**
* Handles the specified error code from Google Play Services.
* This method must only be called on the UI thread.
......@@ -123,7 +130,7 @@ public abstract class UserRecoverableErrorHandler {
public void onDismiss(DialogInterface dialogInterface) {
if (mCancelled) return;
// Dialog is being dismissed without being cancelled - user accepted dialog action.
RecordUserAction.record("Signin_Android_GmsUserRecoverableDialogAccepted");
sModalDialogAcceptedActionEvent.record();
}
public static void createAndAttachToDialog(Dialog dialog) {
......@@ -193,7 +200,7 @@ public abstract class UserRecoverableErrorHandler {
if (mDialog != null && !mDialog.isShowing()) {
mDialog.setCancelable(mCancelable);
mDialog.show();
RecordUserAction.record("Signin_Android_GmsUserRecoverableDialogShown");
sModalDialogShownActionEvent.record();
}
}
......
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.metrics;
import org.chromium.base.StrictModeContext;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.chrome.browser.ShortcutSource;
import org.chromium.chrome.browser.webapps.WebApkInfo;
import org.chromium.chrome.browser.webapps.WebApkUkmRecorder;
......@@ -93,6 +94,13 @@ public class LaunchMetrics {
}
}
sHomeScreenLaunches.clear();
String cachedMetricsGroup =
CachedMetrics.histogramsBypassCache() ? "HistogramsBypassCache" : "Control";
UmaSessionStats.registerSyntheticFieldTrial("AndroidCachedMetrics", cachedMetricsGroup);
// Record generic cached events.
CachedMetrics.commitCachedMetrics();
}
/**
......
......@@ -40,7 +40,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log;
import org.chromium.base.SysUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.metrics.CachedMetrics.ActionEvent;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.ui.KeyboardVisibilityDelegate;
......@@ -55,6 +55,13 @@ public abstract class UrlBar extends AutocompleteEditText {
private static final boolean DEBUG = false;
private static final ActionEvent ACTION_LONG_PRESS_COPY =
new ActionEvent("Omnibox.LongPress.Copy");
private static final ActionEvent ACTION_LONG_PRESS_CUT =
new ActionEvent("Omnibox.LongPress.Cut");
private static final ActionEvent ACTION_LONG_PRESS_SHARE =
new ActionEvent("Omnibox.LongPress.Share");
// TextView becomes very slow on long strings, so we limit maximum length
// of what is displayed to the user, see limitDisplayableLength().
private static final int MAX_DISPLAYABLE_LENGTH = 4000;
......@@ -593,9 +600,9 @@ public abstract class UrlBar extends AutocompleteEditText {
if ((id == android.R.id.cut || id == android.R.id.copy)
&& !mUrlBarDelegate.shouldCutCopyVerbatim()) {
if (id == android.R.id.cut) {
RecordUserAction.record("Omnibox.LongPress.Cut");
ACTION_LONG_PRESS_CUT.record();
} else {
RecordUserAction.record("Omnibox.LongPress.Copy");
ACTION_LONG_PRESS_COPY.record();
}
String currentText = getText().toString();
String replacementCutCopyText = mTextContextMenuDelegate.getReplacementCutCopyText(
......@@ -623,7 +630,7 @@ public abstract class UrlBar extends AutocompleteEditText {
}
if (id == android.R.id.shareText) {
RecordUserAction.record("Omnibox.LongPress.Share");
ACTION_LONG_PRESS_SHARE.record();
}
return super.onTextContextMenuItem(id);
......
......@@ -14,8 +14,8 @@ import android.view.ViewGroup;
import androidx.annotation.IntDef;
import org.chromium.base.metrics.CachedMetrics.ActionEvent;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
......@@ -66,6 +66,15 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
int NUM_ENTRIES = 4;
}
private static final ActionEvent ACTION_EDIT_URL_SUGGESTION_TAP =
new ActionEvent("Omnibox.EditUrlSuggestion.Tap");
private static final ActionEvent ACTION_EDIT_URL_SUGGESTION_COPY =
new ActionEvent("Omnibox.EditUrlSuggestion.Copy");
private static final ActionEvent ACTION_EDIT_URL_SUGGESTION_EDIT =
new ActionEvent("Omnibox.EditUrlSuggestion.Edit");
private static final ActionEvent ACTION_EDIT_URL_SUGGESTION_SHARE =
new ActionEvent("Omnibox.EditUrlSuggestion.Share");
/** The delegate for accessing the location bar for observation and modification. */
private final LocationBarDelegate mLocationBarDelegate;
......@@ -227,11 +236,11 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
if (R.id.url_copy_icon == view.getId()) {
recordSuggestionAction(SuggestionAction.COPY);
RecordUserAction.record("Omnibox.EditUrlSuggestion.Copy");
ACTION_EDIT_URL_SUGGESTION_COPY.record();
Clipboard.getInstance().copyUrlToClipboard(mLastProcessedSuggestion.getUrl());
} else if (R.id.url_share_icon == view.getId()) {
recordSuggestionAction(SuggestionAction.SHARE);
RecordUserAction.record("Omnibox.EditUrlSuggestion.Share");
ACTION_EDIT_URL_SUGGESTION_SHARE.record();
mLocationBarDelegate.clearOmniboxFocus();
// TODO(mdjones): This should only share the displayed URL instead of the background
// tab.
......@@ -242,7 +251,7 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
.share(activityTab, false);
} else if (R.id.url_edit_icon == view.getId()) {
recordSuggestionAction(SuggestionAction.EDIT);
RecordUserAction.record("Omnibox.EditUrlSuggestion.Edit");
ACTION_EDIT_URL_SUGGESTION_EDIT.record();
mLocationBarDelegate.setOmniboxEditingText(mLastProcessedSuggestion.getUrl());
}
}
......@@ -258,7 +267,7 @@ public class EditUrlSuggestionProcessor implements OnClickListener, SuggestionPr
*/
private void onSuggestionSelected(SuggestionViewDelegate delegate) {
recordSuggestionAction(SuggestionAction.TAP);
RecordUserAction.record("Omnibox.EditUrlSuggestion.Tap");
ACTION_EDIT_URL_SUGGESTION_TAP.record();
// If the event wasn't on any of the buttons, treat is as a tap on the general
// suggestion.
assert delegate != null : "EditURL suggestion delegate not available";
......
......@@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.view.ViewStub;
import org.chromium.base.Callback;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.ObservableSupplierImpl;
......@@ -38,6 +39,9 @@ import org.chromium.components.feature_engagement.Tracker;
* toolbar and the tab switcher mode bottom toolbar.
*/
class BottomToolbarCoordinator {
private static final CachedMetrics.ActionEvent ACCELERATOR_BUTTON_TAP_ACTION =
new CachedMetrics.ActionEvent("MobileToolbarOmniboxAcceleratorTap");
/** The browsing mode bottom toolbar component */
private final BrowsingModeBottomToolbarCoordinator mBrowsingModeCoordinator;
......@@ -90,7 +94,7 @@ class BottomToolbarCoordinator {
final OnClickListener searchAcceleratorListener = v -> {
recordBottomToolbarUseForIPH();
RecordUserAction.record("MobileToolbarOmniboxAcceleratorTap");
ACCELERATOR_BUTTON_TAP_ACTION.record();
// Only switch to HomePage when overview is showing.
if (mOverviewModeBehavior != null && mOverviewModeBehavior.overviewVisible()) {
......
......@@ -667,6 +667,7 @@ _jar_excluded_patterns = [
"*/multidex/*.class",
"*/process_launcher/*.class",
"*/SysUtils*.class",
"*/CachedMetrics*.class",
"org/chromium/base/memory/MemoryPressureMonitor*.class",
]
......
......@@ -16,6 +16,7 @@
# Generated for chrome apk and not included into cronet.
-dontwarn org.chromium.base.library_loader.NativeLibraries
-dontwarn org.chromium.base.multidex.ChromiumMultiDexInstaller
-dontwarn org.chromium.base.metrics.CachedMetrics
-dontwarn org.chromium.base.library_loader.LibraryLoader
-dontwarn org.chromium.base.SysUtils
......
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