Commit 15ddc12e authored by tdanderson's avatar tdanderson Committed by Commit bot

Record time between selecting items from the Ash app list

Add the histogram Ash.AppList.TimeBetweenTaskSwitches
to record the time between selecting items from
the app list (launcher) in Ash.

BUG=478933
TEST=TaskSwitchMetricsRecorderTest.VerifyTaskSwitchesFromAppListAreRecorded

Review URL: https://codereview.chromium.org/1145453003

Cr-Commit-Position: refs/heads/master@{#330276}
parent e3bb10f7
...@@ -19,6 +19,8 @@ const char kTabStripHistogramName[] = ...@@ -19,6 +19,8 @@ const char kTabStripHistogramName[] =
const char kAcceleratorWindowCycleHistogramName[] = const char kAcceleratorWindowCycleHistogramName[] =
"Ash.WindowCycleController.TimeBetweenTaskSwitches"; "Ash.WindowCycleController.TimeBetweenTaskSwitches";
const char kAppListHistogramName[] = "Ash.AppList.TimeBetweenTaskSwitches";
const char kOverviewModeHistogramName[] = const char kOverviewModeHistogramName[] =
"Ash.WindowSelector.TimeBetweenActiveWindowChanges"; "Ash.WindowSelector.TimeBetweenActiveWindowChanges";
...@@ -26,6 +28,8 @@ const char kOverviewModeHistogramName[] = ...@@ -26,6 +28,8 @@ const char kOverviewModeHistogramName[] =
const char* GetHistogramName( const char* GetHistogramName(
TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) { TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
switch (task_switch_source) { switch (task_switch_source) {
case TaskSwitchMetricsRecorder::kAppList:
return kAppListHistogramName;
case TaskSwitchMetricsRecorder::kOverviewMode: case TaskSwitchMetricsRecorder::kOverviewMode:
return kOverviewModeHistogramName; return kOverviewModeHistogramName;
case TaskSwitchMetricsRecorder::kShelf: case TaskSwitchMetricsRecorder::kShelf:
......
...@@ -22,6 +22,8 @@ class ASH_EXPORT TaskSwitchMetricsRecorder { ...@@ -22,6 +22,8 @@ class ASH_EXPORT TaskSwitchMetricsRecorder {
// Enumeration of the different user interfaces that could be the source of // Enumeration of the different user interfaces that could be the source of
// a task switch. Note this is not necessarily comprehensive of all sources. // a task switch. Note this is not necessarily comprehensive of all sources.
enum TaskSwitchSource { enum TaskSwitchSource {
// Task switches from selecting items in the app list.
kAppList,
// Task switches caused by selecting a window from overview mode which is // Task switches caused by selecting a window from overview mode which is
// different from the previously-active window. // different from the previously-active window.
kOverviewMode, kOverviewMode,
......
...@@ -122,4 +122,18 @@ TEST_F(TaskSwitchMetricsRecorderTest, ...@@ -122,4 +122,18 @@ TEST_F(TaskSwitchMetricsRecorderTest,
histogram_tester_->ExpectTotalCount(kHistogramName, 2); histogram_tester_->ExpectTotalCount(kHistogramName, 2);
} }
// Verifies that the TaskSwitchMetricsRecorder::kAppList source adds data to the
// Ash.AppList.TimeBetweenTaskSwitches histogram.
TEST_F(TaskSwitchMetricsRecorderTest,
VerifyTaskSwitchesFromApplistAreRecorded) {
const std::string kHistogramName = "Ash.AppList.TimeBetweenTaskSwitches";
OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
histogram_tester_->ExpectTotalCount(kHistogramName, 1);
OnTaskSwitch(TaskSwitchMetricsRecorder::kAppList);
histogram_tester_->ExpectTotalCount(kHistogramName, 2);
}
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h"
#include "ash/metrics/task_switch_metrics_recorder.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
...@@ -101,6 +102,11 @@ void AppListControllerDelegateAsh::ActivateApp( ...@@ -101,6 +102,11 @@ void AppListControllerDelegateAsh::ActivateApp(
const extensions::Extension* extension, const extensions::Extension* extension,
AppListSource source, AppListSource source,
int event_flags) { int event_flags) {
ash::Shell::GetInstance()
->metrics()
->task_switch_metrics_recorder()
.OnTaskSwitch(ash::TaskSwitchMetricsRecorder::kAppList);
// Platform apps treat activations as a launch. The app can decide whether to // Platform apps treat activations as a launch. The app can decide whether to
// show a new window or focus an existing window as it sees fit. // show a new window or focus an existing window as it sees fit.
if (extension->is_platform_app()) { if (extension->is_platform_app()) {
......
...@@ -605,6 +605,16 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -605,6 +605,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="Ash.AppList.TimeBetweenTaskSwitches" units="seconds">
<owner>bruthig@chromium.org</owner>
<owner>tdanderson@chromium.org</owner>
<summary>
The amount of time between selecting an item from the Ash app list. Not
recorded on the first time an item is selected from the app list after
startup.
</summary>
</histogram>
<histogram name="Ash.Dock.Action" enum="DockedAction"> <histogram name="Ash.Dock.Action" enum="DockedAction">
<owner>kuscher@google.com</owner> <owner>kuscher@google.com</owner>
<owner>varkha@chromium.org</owner> <owner>varkha@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