Commit a1c6deb1 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Add Android UMA histogram Tabs.TabOffsetOfSwitch

This CL adds logging for a sparse UMA histogram Tabs.TabOffsetOfSwitch to record
how many tabs forward or backward users move when switching tabs in the Android
tab switcher. This will help us measure usability in experiments.

Bug: 828224
Change-Id: Id7e5bb2431b30408688dbfeb02ee762e8c3facf5
Reviewed-on: https://chromium-review.googlesource.com/1050936
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557335}
parent 24bf48ae
...@@ -109,7 +109,7 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene ...@@ -109,7 +109,7 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
private boolean mIsHiding; private boolean mIsHiding;
// The next id to show when the layout is hidden, or TabBase#INVALID_TAB_ID if no change. // The next id to show when the layout is hidden, or TabBase#INVALID_TAB_ID if no change.
private int mNextTabId = Tab.INVALID_TAB_ID; protected int mNextTabId = Tab.INVALID_TAB_ID;
// The ratio of dp to px. // The ratio of dp to px.
protected final float mDpToPx; protected final float mDpToPx;
......
...@@ -14,6 +14,7 @@ import android.view.ViewGroup.LayoutParams; ...@@ -14,6 +14,7 @@ import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.compositor.LayerTitleCache; import org.chromium.chrome.browser.compositor.LayerTitleCache;
...@@ -100,6 +101,12 @@ public abstract class StackLayoutBase ...@@ -100,6 +101,12 @@ public abstract class StackLayoutBase
*/ */
protected boolean mIsActiveLayout; protected boolean mIsActiveLayout;
/**
* This is true if a new tab was just created and we're in the process of hiding this layout as
* a result and false otherwise.
*/
private boolean mIsHidingBecauseOfNewTabCreation;
/** The list of potentially visible stacks. */ /** The list of potentially visible stacks. */
protected final ArrayList<Stack> mStacks; protected final ArrayList<Stack> mStacks;
...@@ -543,6 +550,9 @@ public abstract class StackLayoutBase ...@@ -543,6 +550,9 @@ public abstract class StackLayoutBase
boolean background, float originX, float originY) { boolean background, float originX, float originY) {
super.onTabCreated( super.onTabCreated(
time, id, tabIndex, sourceId, newIsIncognito, background, originX, originY); time, id, tabIndex, sourceId, newIsIncognito, background, originX, originY);
// Suppress startHiding()'s logging to the Tabs.TabOffsetOfSwitch histogram.
mIsHidingBecauseOfNewTabCreation = true;
startHiding(id, false); startHiding(id, false);
mStacks.get(getTabStackIndex(id)).tabCreated(time, id); mStacks.get(getTabStackIndex(id)).tabCreated(time, id);
...@@ -1225,15 +1235,37 @@ public abstract class StackLayoutBase ...@@ -1225,15 +1235,37 @@ public abstract class StackLayoutBase
@Override @Override
public void startHiding(int nextTabId, boolean hintAtTabSelection) { public void startHiding(int nextTabId, boolean hintAtTabSelection) {
super.startHiding(nextTabId, hintAtTabSelection);
// Reset mIsActiveLayout here instead of in doneHiding() so if a user hits the tab switcher // Reset mIsActiveLayout here instead of in doneHiding() so if a user hits the tab switcher
// button on the toolbar to re-open it while we're still in the process of hiding the tab // button on the toolbar to re-open it while we're still in the process of hiding the tab
// switcher, we don't skip the logging. // switcher, we don't skip the logging.
super.startHiding(nextTabId, hintAtTabSelection);
mIsActiveLayout = false; mIsActiveLayout = false;
} }
@Override @Override
public void doneHiding() { public void doneHiding() {
// Log offset between newly-selected and previously-active tabs. A positive offset means the
// user switched to a tab earlier in the stack. A negative offset means the user switched to
// a tab later in the stack. 0 means they stayed on the same tab. We do not log anything if
// the user switched between stacks (normal to incognito or vice-versa). We also do not log
// anything if the tab switch was the result of a new tab being created (we do log for
// presses of the tab switcher button on the toolbar).
// Note: we log this in doneHiding() instead of startHiding() because Layout#doneHiding() is
// where the new tab actually gets selected. If the user immediately reopens the tab
// switcher before the close animation finishes, the new tab doesn't actually get selected.
if (!mIsHidingBecauseOfNewTabCreation
&& mModelIndexWhenOpened == mTabModelSelector.getCurrentModelIndex()) {
final int currentIndex = mTabModelSelector.getCurrentModel().index();
final Tab newTab = mTabModelSelector.getTabById(mNextTabId);
final int newIndex = mTabModelSelector.getCurrentModel().indexOf(newTab);
assert newIndex != TabList.INVALID_TAB_INDEX;
RecordHistogram.recordSparseSlowlyHistogram(
"Tabs.TabOffsetOfSwitch", currentIndex - newIndex);
}
mIsHidingBecauseOfNewTabCreation = false;
super.doneHiding(); super.doneHiding();
mInnerMarginPercent = 0.0f; mInnerMarginPercent = 0.0f;
......
...@@ -96433,6 +96433,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -96433,6 +96433,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</details> </details>
</histogram> </histogram>
<histogram name="Tabs.TabOffsetOfSwitch">
<owner>rlanday@chromium.org</owner>
<summary>
How many tabs a user moved forward or backward in the Android tab switcher.
</summary>
<details>
Logged by the Android tab switcher when a user switches tabs (other than by
opening a new tab). If the user switches to an earlier tab in the stack, we
log a positive offset value indicating how many tabs back they moved. If the
user switches to a later tab, we log a negative offset value. If the user
stays on the same tab, we log 0. If the user switches to a tab in a
different stack (i.e. they switch from normal to incognito or vice-versa),
we don't log a value.
</details>
</histogram>
<histogram name="Tabs.TabsStatsDailyEventInterval" <histogram name="Tabs.TabsStatsDailyEventInterval"
enum="DailyEventIntervalType"> enum="DailyEventIntervalType">
<owner>sebmarchand@chromium.org</owner> <owner>sebmarchand@chromium.org</owner>
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