Commit 563b9b34 authored by dominickn's avatar dominickn Committed by Commit bot

Add a metric measuring how many times an infobar hid other infobars on Android.

This CL adds a new UMA metric to record the identifier of an infobar
which was visible to the user and hid another infobar behind it. This CL
also updates the visible/hidden check to simply query whether or not
another infobar exists. This is to correct an overcounting issue that
recorded infobars which appeared after another infobar was dismissed
as being hidden.

BUG=589163

Review-Url: https://codereview.chromium.org/2321923002
Cr-Commit-Position: refs/heads/master@{#417496}
parent 0d64c146
......@@ -99,9 +99,6 @@ public abstract class SwipableOverlayView extends FrameLayout {
// The ContentViewCore to which the overlay is added.
private ContentViewCore mContentViewCore;
// True if the View is visible, false otherwise.
private boolean mWillBeVisible;
/**
* Creates a SwipableOverlayView.
* @param context Context for acquiring resources.
......@@ -114,7 +111,6 @@ public abstract class SwipableOverlayView extends FrameLayout {
mLayoutChangeListener = createLayoutChangeListener();
mAnimatorListener = createAnimatorListener();
mInterpolator = new DecelerateInterpolator(1.0f);
mWillBeVisible = true;
// We make this view 'draw' to provide a placeholder for its animations.
setWillNotDraw(false);
......@@ -141,13 +137,6 @@ public abstract class SwipableOverlayView extends FrameLayout {
return mContentViewCore;
}
/**
* @return true if this View is or will shortly be visible, false otherwise.
*/
protected boolean willBeVisible() {
return mWillBeVisible;
}
protected void addToParentView(TabContentViewParent parentView) {
if (getParent() == null) {
parentView.addInfobarView(this, createLayoutParams());
......@@ -321,7 +310,6 @@ public abstract class SwipableOverlayView extends FrameLayout {
float yDifference = Math.abs(translationY - getTranslationY()) / mTotalHeight;
long duration = Math.max(0, (long) (ANIMATION_DURATION_MS * yDifference));
mWillBeVisible = visible;
mCurrentAnimation = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, translationY);
mCurrentAnimation.setDuration(duration);
mCurrentAnimation.addListener(mAnimatorListener);
......
......@@ -136,6 +136,10 @@ public abstract class InfoBar implements InfoBarView {
return false;
}
long getNativeInfoBarPtr() {
return mNativeInfoBarPtr;
}
void setInfoBarContainer(InfoBarContainer container) {
mContainer = container;
}
......
......@@ -293,18 +293,19 @@ public class InfoBarContainer extends SwipableOverlayView {
/**
* @return True if the container has any InfoBars.
*/
@CalledByNative
public boolean hasInfoBars() {
return !mInfoBars.isEmpty();
}
/**
* @return True if the next infobar added to this container will be visible, false otherwise.
* @return Pointer to the native InfoBarAndroid object which is currently at the top of the
* infobar stack, or 0 if there are no infobars.
*/
@CalledByNative
public boolean nextInfoBarWillBeVisible() {
if (hasInfoBars()) return false;
return willBeVisible();
private long getTopNativeInfoBarPtr() {
if (!hasInfoBars()) return 0;
return mInfoBars.get(0).getNativeInfoBarPtr();
}
/**
......
......@@ -64,12 +64,20 @@ void InfoBarContainerAndroid::AttachJavaInfoBar(InfoBarAndroid* android_bar) {
return;
JNIEnv* env = base::android::AttachCurrentThread();
if (Java_InfoBarContainer_nextInfoBarWillBeVisible(
if (Java_InfoBarContainer_hasInfoBars(
env, weak_java_infobar_container_.get(env))) {
UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Shown.Visible",
UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Shown.Hidden",
android_bar->delegate()->GetIdentifier());
uintptr_t native_ptr = Java_InfoBarContainer_getTopNativeInfoBarPtr(
env, weak_java_infobar_container_.get(env));
if (native_ptr) {
UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Shown.Hiding",
reinterpret_cast<InfoBarAndroid*>(native_ptr)
->delegate()
->GetIdentifier());
}
} else {
UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Shown.Hidden",
UMA_HISTOGRAM_SPARSE_SLOWLY("InfoBar.Shown.Visible",
android_bar->delegate()->GetIdentifier());
}
......
......@@ -19433,8 +19433,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<owner>dominickn@chromium.org</owner>
<summary>
Records how many times a particular infobar was displayed in a hidden state
due to at least one other infobar existing or because it was auto-hidden.
Only recorded on Android.
due to at least one other infobar existing. If there are no existing
infobars, but the user scrolls at the exact moment a new infobar is added,
the infobar may be hidden, but not recorded in this metric. Reliably
triggering and detecting this combination is tricky so it isn't done. Only
recorded on Android.
</summary>
</histogram>
<histogram name="InfoBar.Shown.Hiding" enum="InfoBarIdentifier">
<owner>dfalcantara@chromium.org</owner>
<owner>dominickn@chromium.org</owner>
<summary>
Records how many times a particular infobar was visible and hiding a new
infobar behind it. Only recorded on Android.
</summary>
</histogram>
......@@ -19443,8 +19455,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<owner>dominickn@chromium.org</owner>
<summary>
Records how many times a particular infobar was displayed in a visible state
due to no other infobars existing and no auto-hiding. Only recorded on
Android.
due to no other infobars existing. If there are no existing infobars, but
the user scrolls at the exact moment a new infobar is added, the infobar may
be hidden, but recorded here as visible. Reliably triggering and detecting
this combination is tricky so it isn't done. Only recorded on Android.
</summary>
</histogram>
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