Commit 49072647 authored by bruthig's avatar bruthig Committed by Commit bot

Added Ash.TimeBetweenTaskSwitches to record time deltas between all recorded task switches.

TEST=TaskSwitchMetricsRecorderTest.VerifyTaskSwitchesRecordInAllTaskSwitchHistogram

BUG=487745

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

Cr-Commit-Position: refs/heads/master@{#333658}
parent ec4a2e23
...@@ -10,6 +10,8 @@ namespace ash { ...@@ -10,6 +10,8 @@ namespace ash {
namespace { namespace {
const char kAshTaskSwitchHistogramName[] = "Ash.TimeBetweenTaskSwitches";
const char kDesktopHistogramName[] = const char kDesktopHistogramName[] =
"Ash.Desktop.TimeBetweenNavigateToTaskSwitches"; "Ash.Desktop.TimeBetweenNavigateToTaskSwitches";
...@@ -31,6 +33,8 @@ const char kOverviewModeHistogramName[] = ...@@ -31,6 +33,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::kAny:
return kAshTaskSwitchHistogramName;
case TaskSwitchMetricsRecorder::kAppList: case TaskSwitchMetricsRecorder::kAppList:
return kAppListHistogramName; return kAppListHistogramName;
case TaskSwitchMetricsRecorder::kDesktop: case TaskSwitchMetricsRecorder::kDesktop:
...@@ -58,6 +62,15 @@ TaskSwitchMetricsRecorder::~TaskSwitchMetricsRecorder() { ...@@ -58,6 +62,15 @@ TaskSwitchMetricsRecorder::~TaskSwitchMetricsRecorder() {
void TaskSwitchMetricsRecorder::OnTaskSwitch( void TaskSwitchMetricsRecorder::OnTaskSwitch(
TaskSwitchSource task_switch_source) { TaskSwitchSource task_switch_source) {
DCHECK_NE(task_switch_source, kAny);
if (task_switch_source != kAny) {
OnTaskSwitchInternal(task_switch_source);
OnTaskSwitchInternal(kAny);
}
}
void TaskSwitchMetricsRecorder::OnTaskSwitchInternal(
TaskSwitchSource task_switch_source) {
TaskSwitchTimeTracker* task_switch_time_tracker = TaskSwitchTimeTracker* task_switch_time_tracker =
FindTaskSwitchTimeTracker(task_switch_source); FindTaskSwitchTimeTracker(task_switch_source);
if (!task_switch_time_tracker) if (!task_switch_time_tracker)
......
...@@ -27,6 +27,9 @@ class ASH_EXPORT TaskSwitchMetricsRecorder { ...@@ -27,6 +27,9 @@ class ASH_EXPORT TaskSwitchMetricsRecorder {
// a task switch. Note this is not necessarily comprehensive of all sources. // a task switch. Note this is not necessarily comprehensive of all sources.
// TODO(bruthig): Convert enum format from kValue to VALUE. // TODO(bruthig): Convert enum format from kValue to VALUE.
enum TaskSwitchSource { enum TaskSwitchSource {
// Task switches caused by any two sources in this enum. NOTE: This value
// should NOT be used outside of this class.
kAny,
// Task switches from selecting items in the app list. // Task switches from selecting items in the app list.
kAppList, kAppList,
// Task switches caused by the user activating a task window by clicking or // Task switches caused by the user activating a task window by clicking or
...@@ -46,19 +49,30 @@ class ASH_EXPORT TaskSwitchMetricsRecorder { ...@@ -46,19 +49,30 @@ class ASH_EXPORT TaskSwitchMetricsRecorder {
TaskSwitchMetricsRecorder(); TaskSwitchMetricsRecorder();
virtual ~TaskSwitchMetricsRecorder(); virtual ~TaskSwitchMetricsRecorder();
// Notifies |this| that a "navigate to" task switch has occurred. A // Notifies |this| that a "navigate to" task switch has occurred from the
// "navigate to" operation is defined by a task switch where the specific task // specified |task_switch_source|. The metrics associated with
// that becomes active is user-predictable (ie Alt+Tab accelerator, launching // TaskSwitchSource::kAny source will be updated as well.
// a new window via the shelf, etc). Contrast to a "navigate away" operation //
// which is defined as a user interaction that navigates away from a specified // NOTE: A |task_switch_source| value of TaskSwitchSource::kAny should not be
// task and the next task that becomes active is likely not user-predictable // used and behavior is undefined if it is.
// (ie. closing or minimizing a window, closing a tab, etc). //
// A "navigate to" operation is defined by a task switch where the specific
// task that becomes active is user-predictable (e.g., Alt+Tab accelerator,
// launching a new window via the shelf, etc). Contrast to a "navigate away"
// operation which is defined as a user interaction that navigates away from a
// specified task and the next task that becomes active is likely not
// user-predictable (e.g., closing or minimizing a window, closing a tab,
// etc).
// //
// Will add an entry to |histogram_map_| when called for the first time for // Will add an entry to |histogram_map_| when called for the first time for
// each |task_switch_source| value. // each |task_switch_source| value.
void OnTaskSwitch(TaskSwitchSource task_switch_source); void OnTaskSwitch(TaskSwitchSource task_switch_source);
private: private:
// Internal implementation of OnTaskSwitch(TaskSwitchSource) that will accept
// the TaskSwitchSource::kAny value.
void OnTaskSwitchInternal(TaskSwitchSource task_switch_source);
// Returns the TaskSwitchTimeTracker associated with the specified // Returns the TaskSwitchTimeTracker associated with the specified
// |task_switch_source|. May return nullptr if mapping does not exist yet. // |task_switch_source|. May return nullptr if mapping does not exist yet.
TaskSwitchTimeTracker* FindTaskSwitchTimeTracker( TaskSwitchTimeTracker* FindTaskSwitchTimeTracker(
......
...@@ -62,6 +62,17 @@ void TaskSwitchMetricsRecorderTest::TearDown() { ...@@ -62,6 +62,17 @@ void TaskSwitchMetricsRecorderTest::TearDown() {
} // namespace } // namespace
// Verifies that task switches from a non kAny source also add data to the
// Ash.TimeBetweenTaskSwitches histogram.
TEST_F(TaskSwitchMetricsRecorderTest,
VerifyTaskSwitchesRecordInAllTaskSwitchHistogram) {
const std::string kHistogramName = "Ash.TimeBetweenTaskSwitches";
OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
OnTaskSwitch(TaskSwitchMetricsRecorder::kShelf);
histogram_tester_->ExpectTotalCount(kHistogramName, 1);
}
// Verifies that the TaskSwitchMetricsRecorder::kDesktop source adds data to the // Verifies that the TaskSwitchMetricsRecorder::kDesktop source adds data to the
// Ash.Desktop.TimeBetweenNavigateToTaskSwitches histogram. // Ash.Desktop.TimeBetweenNavigateToTaskSwitches histogram.
TEST_F(TaskSwitchMetricsRecorderTest, VerifyTaskSwitchesForDesktopAreRecorded) { TEST_F(TaskSwitchMetricsRecorderTest, VerifyTaskSwitchesForDesktopAreRecorded) {
......
...@@ -860,6 +860,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -860,6 +860,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Ash.TimeBetweenTaskSwitches" units="seconds">
<owner>bruthig@google.com</owner>
<owner>tdanderson@google.com</owner>
<summary>
The number of seconds between contiguous task switch user actions triggered
by any of the other task switch actions that are tracked. (e.g.,
Ash.Shelf.TimeBetweenNavigateToTaskSwitches,
Ash.Tab.TimeBetweenSwitchToExistingTabUserActions,
Ash.WindowCycleController.TimeBetweenTaskSwitches,
Ash.AppList.TimeBetweenTaskSwitches,
Ash.WindowSelector.TimeBetweenActiveWindowChanges, etc).
</summary>
</histogram>
<histogram name="Ash.TouchDuration" units="milliseconds"> <histogram name="Ash.TouchDuration" units="milliseconds">
<obsolete> <obsolete>
Deprecated 12/2013 in r239809, and replaced by Ash.TouchDuration2. Deprecated 12/2013 in r239809, and replaced by Ash.TouchDuration2.
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