Commit 8a07a4a8 authored by bttk's avatar bttk Committed by Commit Bot

metrics: Remove deprecated uses of CachedMetrics from TabbedActivity

Bug: 1046181
Change-Id: Ide50b7bf6332e2c162a2aba1e255498ab986bf68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067721Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarGang Wu <gangwu@chromium.org>
Commit-Queue: bttk <bttk@chromium.org>
Auto-Submit: bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748859}
parent 55c84fe6
...@@ -28,6 +28,7 @@ import android.view.ViewGroup; ...@@ -28,6 +28,7 @@ import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -41,8 +42,6 @@ import org.chromium.base.ObserverList; ...@@ -41,8 +42,6 @@ import org.chromium.base.ObserverList;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import org.chromium.base.library_loader.LibraryLoader; import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.metrics.CachedMetrics.BooleanHistogramSample;
import org.chromium.base.metrics.CachedMetrics.EnumeratedHistogramSample;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.ObservableSupplier; import org.chromium.base.supplier.ObservableSupplier;
...@@ -167,6 +166,8 @@ import org.chromium.ui.base.PageTransition; ...@@ -167,6 +166,8 @@ import org.chromium.ui.base.PageTransition;
import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.widget.Toast; import org.chromium.ui.widget.Toast;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
...@@ -211,17 +212,15 @@ public class ChromeTabbedActivity ...@@ -211,17 +212,15 @@ public class ChromeTabbedActivity
// Name of the ChromeTabbedActivity alias that handles MAIN intents. // Name of the ChromeTabbedActivity alias that handles MAIN intents.
public static final String MAIN_LAUNCHER_ACTIVITY_NAME = "com.google.android.apps.chrome.Main"; public static final String MAIN_LAUNCHER_ACTIVITY_NAME = "com.google.android.apps.chrome.Main";
// Boolean histograms used with maybeDispatchExplicitMainViewIntent(). /**
private static final BooleanHistogramSample sExplicitMainViewIntentDispatchedOnCreate = * Identifies a histogram to use in {@link #maybeDispatchExplicitMainViewIntent(Intent, int)}.
new BooleanHistogramSample( */
"Android.MainActivity.ExplicitMainViewIntentDispatched.OnCreate"); @IntDef({DispatchedBy.ON_CREATE, DispatchedBy.ON_NEW_INTENT})
private static final BooleanHistogramSample sExplicitMainViewIntentDispatchedOnNewIntent = @Retention(RetentionPolicy.SOURCE)
new BooleanHistogramSample( private @interface DispatchedBy {
"Android.MainActivity.ExplicitMainViewIntentDispatched.OnNewIntent"); int ON_CREATE = 1;
private static final EnumeratedHistogramSample sUndispatchedExplicitMainViewIntentSource = int ON_NEW_INTENT = 2;
new EnumeratedHistogramSample( }
"Android.MainActivity.UndispatchedExplicitMainViewIntentSource",
IntentHandler.ExternalAppId.NUM_ENTRIES);
// Count histogram used to track number of tabs when we show the Overview on Return to Chrome. // Count histogram used to track number of tabs when we show the Overview on Return to Chrome.
private static final String TAB_COUNT_ON_RETURN = "Tabs.TabCountOnStartScreenShown"; private static final String TAB_COUNT_ON_RETURN = "Tabs.TabCountOnStartScreenShown";
...@@ -476,8 +475,7 @@ public class ChromeTabbedActivity ...@@ -476,8 +475,7 @@ public class ChromeTabbedActivity
return LaunchIntentDispatcher.dispatchToTabbedActivity(this, intent); return LaunchIntentDispatcher.dispatchToTabbedActivity(this, intent);
} }
@LaunchIntentDispatcher.Action @LaunchIntentDispatcher.Action
int action = maybeDispatchExplicitMainViewIntent( int action = maybeDispatchExplicitMainViewIntent(intent, DispatchedBy.ON_CREATE);
intent, sExplicitMainViewIntentDispatchedOnCreate);
if (action != LaunchIntentDispatcher.Action.CONTINUE) { if (action != LaunchIntentDispatcher.Action.CONTINUE) {
return action; return action;
} }
...@@ -492,10 +490,10 @@ public class ChromeTabbedActivity ...@@ -492,10 +490,10 @@ public class ChromeTabbedActivity
// intents, and dispatch them accordingly. If the intent was not dispatched, the method // intents, and dispatch them accordingly. If the intent was not dispatched, the method
// returns Action.CONTINUE. // returns Action.CONTINUE.
// //
// The method also updates the supplied binary histogram with the dispatching result, // The method also updates the supplied boolean histogram with the dispatching result,
// but only if the intent is a VIEW intent sent explicitly to .Main activity. // but only if the intent is a VIEW intent sent explicitly to .Main activity.
private @LaunchIntentDispatcher.Action int maybeDispatchExplicitMainViewIntent( private @LaunchIntentDispatcher.Action int maybeDispatchExplicitMainViewIntent(
Intent intent, BooleanHistogramSample dispatchedHistogram) { Intent intent, @DispatchedBy int dispatchedBy) {
// The first check ensures that this is .Main activity alias (we can't check exactly, but // The first check ensures that this is .Main activity alias (we can't check exactly, but
// this gets us sufficiently close). // this gets us sufficiently close).
if (getClass().equals(ChromeTabbedActivity.class) if (getClass().equals(ChromeTabbedActivity.class)
...@@ -503,12 +501,28 @@ public class ChromeTabbedActivity ...@@ -503,12 +501,28 @@ public class ChromeTabbedActivity
&& MAIN_LAUNCHER_ACTIVITY_NAME.equals(intent.getComponent().getClassName())) { && MAIN_LAUNCHER_ACTIVITY_NAME.equals(intent.getComponent().getClassName())) {
@LaunchIntentDispatcher.Action @LaunchIntentDispatcher.Action
int action = LaunchIntentDispatcher.dispatchToCustomTabActivity(this, intent); int action = LaunchIntentDispatcher.dispatchToCustomTabActivity(this, intent);
dispatchedHistogram.record(action != LaunchIntentDispatcher.Action.CONTINUE); switch (dispatchedBy) {
case DispatchedBy.ON_CREATE:
RecordHistogram.recordBooleanHistogram(
"Android.MainActivity.ExplicitMainViewIntentDispatched.OnCreate",
action != LaunchIntentDispatcher.Action.CONTINUE);
break;
case DispatchedBy.ON_NEW_INTENT:
RecordHistogram.recordBooleanHistogram(
"Android.MainActivity.ExplicitMainViewIntentDispatched.OnNewIntent",
action != LaunchIntentDispatcher.Action.CONTINUE);
break;
default:
assert false : "Unknown dispatchedBy value " + dispatchedBy;
}
if (action == LaunchIntentDispatcher.Action.CONTINUE) { if (action == LaunchIntentDispatcher.Action.CONTINUE) {
// Intent was not dispatched, record its source. // Intent was not dispatched, record its source.
@IntentHandler.ExternalAppId @IntentHandler.ExternalAppId
int externalId = IntentHandler.determineExternalIntentSource(intent); int externalId = IntentHandler.determineExternalIntentSource(intent);
sUndispatchedExplicitMainViewIntentSource.record(externalId); RecordHistogram.recordEnumeratedHistogram(
"Android.MainActivity.UndispatchedExplicitMainViewIntentSource", externalId,
IntentHandler.ExternalAppId.NUM_ENTRIES);
// Crash if intent came from us, but only in debug builds and only if we weren't // Crash if intent came from us, but only in debug builds and only if we weren't
// explicitly told not to. Hopefully we'll get enough reports to find where // explicitly told not to. Hopefully we'll get enough reports to find where
...@@ -790,7 +804,7 @@ public class ChromeTabbedActivity ...@@ -790,7 +804,7 @@ public class ChromeTabbedActivity
intentForDispatching.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentForDispatching.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@LaunchIntentDispatcher.Action @LaunchIntentDispatcher.Action
int action = maybeDispatchExplicitMainViewIntent( int action = maybeDispatchExplicitMainViewIntent(
intentForDispatching, sExplicitMainViewIntentDispatchedOnNewIntent); intentForDispatching, DispatchedBy.ON_NEW_INTENT);
if (action != LaunchIntentDispatcher.Action.CONTINUE) { if (action != LaunchIntentDispatcher.Action.CONTINUE) {
// Pressing back button in CCT should bring user to the caller activity. // Pressing back button in CCT should bring user to the caller activity.
moveTaskToBack(true); moveTaskToBack(true);
......
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