Added UMA stats to overview mode

This patch:
* Brought back WindowSelector.CycleTime histogram with different name
  (WindowCycleController.CycleTime).
* Renamed WindowSelector.Selection to WindowCycleController.Cycle and fixed that it
  counted incorrectly overview mode selections.
* Fixed a bug in which the number of items in overview mode were not counted
  correctly.
* Added stats for:
** Number of closed items.
** Number of times the enter key is used to select a window.
** Number of arrow key presses per session.
** Ratio between arrow key presses and number of items.

BUG=364590
TEST=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276710 0039d316-1c4b-4281-b951-d872f2087c98
parent e70bdb7d
...@@ -368,9 +368,13 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) { ...@@ -368,9 +368,13 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("WindowSelector_Overview")); base::UserMetricsAction("WindowSelector_Overview"));
break; break;
case ash::UMA_WINDOW_SELECTION: case ash::UMA_WINDOW_OVERVIEW_ENTER_KEY:
base::RecordAction( base::RecordAction(
base::UserMetricsAction("WindowSelector_Selection")); base::UserMetricsAction("WindowSelector_OverviewEnterKey"));
break;
case ash::UMA_WINDOW_CYCLE:
base::RecordAction(
base::UserMetricsAction("WindowCycleController_Cycle"));
break; break;
} }
} }
...@@ -401,7 +405,7 @@ void UserMetricsRecorder::RecordPeriodicMetrics() { ...@@ -401,7 +405,7 @@ void UserMetricsRecorder::RecordPeriodicMetrics() {
ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW; ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW;
wm::WindowState* active_window_state = ash::wm::GetActiveWindowState(); wm::WindowState* active_window_state = ash::wm::GetActiveWindowState();
if (active_window_state) { if (active_window_state) {
switch(active_window_state->GetStateType()) { switch (active_window_state->GetStateType()) {
case wm::WINDOW_STATE_TYPE_MAXIMIZED: case wm::WINDOW_STATE_TYPE_MAXIMIZED:
active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED; active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED;
break; break;
......
...@@ -100,14 +100,15 @@ enum UserMetricsAction { ...@@ -100,14 +100,15 @@ enum UserMetricsAction {
UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT, UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT,
UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT, UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT,
// Thumbnail sized overview of windows triggered. This is a subset of // Thumbnail sized overview of windows triggered by pressing the overview key.
// UMA_WINDOW_SELECTION triggered by lingering during alt+tab cycles or
// pressing the overview key.
UMA_WINDOW_OVERVIEW, UMA_WINDOW_OVERVIEW,
// Window selection started by beginning an alt+tab cycle or pressing the // Selecting a window in overview mode by pressing the enter key.
// overview key. This does not count each step through an alt+tab cycle. UMA_WINDOW_OVERVIEW_ENTER_KEY,
UMA_WINDOW_SELECTION,
// Window selection started by beginning an alt+tab cycle. This does not count
// each step through an alt+tab cycle.
UMA_WINDOW_CYCLE,
}; };
// User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics) // User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics)
......
...@@ -95,8 +95,10 @@ WindowSelector::WindowSelector(const WindowList& windows, ...@@ -95,8 +95,10 @@ WindowSelector::WindowSelector(const WindowList& windows,
restore_focus_window_(aura::client::GetFocusClient( restore_focus_window_(aura::client::GetFocusClient(
Shell::GetPrimaryRootWindow())->GetFocusedWindow()), Shell::GetPrimaryRootWindow())->GetFocusedWindow()),
ignore_activations_(false), ignore_activations_(false),
selected_grid_index_(0),
overview_start_time_(base::Time::Now()), overview_start_time_(base::Time::Now()),
selected_grid_index_(0) { num_key_presses_(0),
num_items_(0) {
DCHECK(delegate_); DCHECK(delegate_);
Shell* shell = Shell::GetInstance(); Shell* shell = Shell::GetInstance();
shell->OnOverviewModeStarting(); shell->OnOverviewModeStarting();
...@@ -105,7 +107,6 @@ WindowSelector::WindowSelector(const WindowList& windows, ...@@ -105,7 +107,6 @@ WindowSelector::WindowSelector(const WindowList& windows,
restore_focus_window_->AddObserver(this); restore_focus_window_->AddObserver(this);
const aura::Window::Windows root_windows = Shell::GetAllRootWindows(); const aura::Window::Windows root_windows = Shell::GetAllRootWindows();
size_t items = 0;
for (aura::Window::Windows::const_iterator iter = root_windows.begin(); for (aura::Window::Windows::const_iterator iter = root_windows.begin();
iter != root_windows.end(); iter++) { iter != root_windows.end(); iter++) {
// Observed switchable containers for newly created windows on all root // Observed switchable containers for newly created windows on all root
...@@ -119,12 +120,12 @@ WindowSelector::WindowSelector(const WindowList& windows, ...@@ -119,12 +120,12 @@ WindowSelector::WindowSelector(const WindowList& windows,
scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this)); scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this));
if (grid->empty()) if (grid->empty())
continue; continue;
num_items_ += grid->size();
grid_list_.push_back(grid.release()); grid_list_.push_back(grid.release());
items += grid_list_.size();
} }
DCHECK(!grid_list_.empty()); DCHECK(!grid_list_.empty());
UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", items); UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_);
shell->activation_client()->AddObserver(this); shell->activation_client()->AddObserver(this);
...@@ -169,9 +170,18 @@ WindowSelector::~WindowSelector() { ...@@ -169,9 +170,18 @@ WindowSelector::~WindowSelector() {
shell->RemovePreTargetHandler(this); shell->RemovePreTargetHandler(this);
shell->GetScreen()->RemoveObserver(this); shell->GetScreen()->RemoveObserver(this);
UMA_HISTOGRAM_MEDIUM_TIMES(
"Ash.WindowSelector.TimeInOverview", size_t remaining_items = 0;
base::Time::Now() - overview_start_time_); for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin();
iter != grid_list_.end(); iter++) {
remaining_items += (*iter)->size();
}
DCHECK(num_items_ >= remaining_items);
UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.OverviewClosedItems",
num_items_ - remaining_items);
UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowSelector.TimeInOverview",
base::Time::Now() - overview_start_time_);
// TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when // TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when
// everything is done. // everything is done.
...@@ -206,21 +216,32 @@ void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { ...@@ -206,21 +216,32 @@ void WindowSelector::OnKeyEvent(ui::KeyEvent* event) {
CancelSelection(); CancelSelection();
break; break;
case ui::VKEY_UP: case ui::VKEY_UP:
num_key_presses_++;
Move(WindowSelector::UP); Move(WindowSelector::UP);
break; break;
case ui::VKEY_DOWN: case ui::VKEY_DOWN:
num_key_presses_++;
Move(WindowSelector::DOWN); Move(WindowSelector::DOWN);
break; break;
case ui::VKEY_RIGHT: case ui::VKEY_RIGHT:
num_key_presses_++;
Move(WindowSelector::RIGHT); Move(WindowSelector::RIGHT);
break; break;
case ui::VKEY_LEFT: case ui::VKEY_LEFT:
num_key_presses_++;
Move(WindowSelector::LEFT); Move(WindowSelector::LEFT);
break; break;
case ui::VKEY_RETURN: case ui::VKEY_RETURN:
// Ignore if no item is selected. // Ignore if no item is selected.
if (!grid_list_[selected_grid_index_]->is_selecting()) if (!grid_list_[selected_grid_index_]->is_selecting())
return; return;
UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses",
num_key_presses_);
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Ash.WindowSelector.KeyPressesOverItemsRatio",
(num_key_presses_ * 100) / num_items_, 1, 300, 30);
Shell::GetInstance()->metrics()->RecordUserMetricsAction(
UMA_WINDOW_OVERVIEW_ENTER_KEY);
wm::GetWindowState(grid_list_[selected_grid_index_]-> wm::GetWindowState(grid_list_[selected_grid_index_]->
SelectedWindow()->SelectionWindow())->Activate(); SelectedWindow()->SelectionWindow())->Activate();
break; break;
......
...@@ -124,9 +124,6 @@ class ASH_EXPORT WindowSelector ...@@ -124,9 +124,6 @@ class ASH_EXPORT WindowSelector
// List of all the window overview grids, one for each root window. // List of all the window overview grids, one for each root window.
ScopedVector<WindowGrid> grid_list_; ScopedVector<WindowGrid> grid_list_;
// The time when overview was started.
base::Time overview_start_time_;
// Tracks windows which were hidden because they were not part of the // Tracks windows which were hidden because they were not part of the
// overview. // overview.
aura::WindowTracker hidden_windows_; aura::WindowTracker hidden_windows_;
...@@ -134,6 +131,17 @@ class ASH_EXPORT WindowSelector ...@@ -134,6 +131,17 @@ class ASH_EXPORT WindowSelector
// Tracks the index of the root window the selection widget is in. // Tracks the index of the root window the selection widget is in.
size_t selected_grid_index_; size_t selected_grid_index_;
// The following variables are used for metric collection purposes. All of
// them refer to this particular overview session and are not cumulative:
// The time when overview was started.
base::Time overview_start_time_;
// The number of arrow key presses.
size_t num_key_presses_;
// The number of items in the overview.
size_t num_items_;
DISALLOW_COPY_AND_ASSIGN(WindowSelector); DISALLOW_COPY_AND_ASSIGN(WindowSelector);
}; };
......
...@@ -67,8 +67,6 @@ void WindowSelectorController::OnSelectionEnded() { ...@@ -67,8 +67,6 @@ void WindowSelectorController::OnSelectionEnded() {
} }
void WindowSelectorController::OnSelectionStarted() { void WindowSelectorController::OnSelectionStarted() {
Shell* shell = Shell::GetInstance();
shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_SELECTION);
if (!last_selection_time_.is_null()) { if (!last_selection_time_.is_null()) {
UMA_HISTOGRAM_LONG_TIMES( UMA_HISTOGRAM_LONG_TIMES(
"Ash.WindowSelector.TimeBetweenUse", "Ash.WindowSelector.TimeBetweenUse",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_cycle_list.h" #include "ash/wm/window_cycle_list.h"
#include "base/metrics/histogram.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_handler.h" #include "ui/events/event_handler.h"
...@@ -79,6 +80,8 @@ void WindowCycleController::StartCycling() { ...@@ -79,6 +80,8 @@ void WindowCycleController::StartCycling() {
window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()-> window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()->
mru_window_tracker()->BuildMruWindowList())); mru_window_tracker()->BuildMruWindowList()));
event_handler_.reset(new WindowCycleEventFilter()); event_handler_.reset(new WindowCycleEventFilter());
cycle_start_time_ = base::Time::Now();
Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -93,6 +96,8 @@ void WindowCycleController::StopCycling() { ...@@ -93,6 +96,8 @@ void WindowCycleController::StopCycling() {
window_cycle_list_.reset(); window_cycle_list_.reset();
// Remove our key event filter. // Remove our key event filter.
event_handler_.reset(); event_handler_.reset();
UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime",
base::Time::Now() - cycle_start_time_);
} }
} // namespace ash } // namespace ash
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
namespace ui { namespace ui {
class EventHandler; class EventHandler;
...@@ -65,6 +66,8 @@ class ASH_EXPORT WindowCycleController { ...@@ -65,6 +66,8 @@ class ASH_EXPORT WindowCycleController {
// Event handler to watch for release of alt key. // Event handler to watch for release of alt key.
scoped_ptr<ui::EventHandler> event_handler_; scoped_ptr<ui::EventHandler> event_handler_;
base::Time cycle_start_time_;
DISALLOW_COPY_AND_ASSIGN(WindowCycleController); DISALLOW_COPY_AND_ASSIGN(WindowCycleController);
}; };
......
...@@ -10986,6 +10986,14 @@ should be able to be added at any place in this file. ...@@ -10986,6 +10986,14 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
</action> </action>
<action name="WindowCycleController_Cycle">
<owner>tdanderson@chromium.org</owner>
<owner>flackr@chromium.org</owner>
<description>
Starting a window selection cycle by pressing alt-tab.
</description>
</action>
<action name="WindowDrag_MaximizeLeft"> <action name="WindowDrag_MaximizeLeft">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
...@@ -10997,13 +11005,26 @@ should be able to be added at any place in this file. ...@@ -10997,13 +11005,26 @@ should be able to be added at any place in this file.
</action> </action>
<action name="WindowSelector_Overview"> <action name="WindowSelector_Overview">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>tdanderson@chromium.org</owner>
<description>Please enter the description of this user action.</description> <owner>flackr@chromium.org</owner>
<description>Starting the window overview mode.</description>
</action>
<action name="WindowSelector_OverviewEnterKey">
<owner>tdanderson@chromium.org</owner>
<owner>flackr@chromium.org</owner>
<description>
Using the enter key to select a window in the overview.
</description>
</action> </action>
<action name="WindowSelector_Selection"> <action name="WindowSelector_Selection">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
<obsolete>
Deprecated as of 06/2014. No longer relevant since alt tab window switching
was separated from overview mode.
</obsolete>
</action> </action>
<action name="WorkerProcess_BadProcessToKill"> <action name="WorkerProcess_BadProcessToKill">
......
...@@ -682,7 +682,30 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -682,7 +682,30 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="Ash.WindowCycleController.CycleTime" units="milliseconds">
<owner>flackr@chromium.org</owner>
<owner>kuscher@google.com</owner>
<summary>
The amount of time the Alt key is held after pressing Alt+Tab to begin
cycling through windows.
</summary>
</histogram>
<histogram name="Ash.WindowSelector.ArrowKeyPresses">
<owner>flackr@chromium.org</owner>
<owner>tdanderson@chromium.org</owner>
<summary>
The number of times the arrow keys are pressed in overview mode per session,
i.e. between bringing up overview mode and ending it. This is only measured
for the sessions that end by selecting a window with the enter key.
</summary>
</histogram>
<histogram name="Ash.WindowSelector.CycleTime" units="milliseconds"> <histogram name="Ash.WindowSelector.CycleTime" units="milliseconds">
<obsolete>
Deprecated as of 06/2014. No longer relevant since alt-tab switching was
separated from WindowSelector.
</obsolete>
<owner>flackr@chromium.org</owner> <owner>flackr@chromium.org</owner>
<owner>kuscher@google.com</owner> <owner>kuscher@google.com</owner>
<summary> <summary>
...@@ -696,8 +719,24 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -696,8 +719,24 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<owner>kuscher@google.com</owner> <owner>kuscher@google.com</owner>
<summary> <summary>
The number of items (single windows or groups of windows such as panels) in The number of items (single windows or groups of windows such as panels) in
the window selection. Window selection occurs when a user begins alt-tabbing the overview mode, present at the start of each session.
or presses the overview button (F5 key). </summary>
</histogram>
<histogram name="Ash.WindowSelector.KeyPressesOverItemsRatio" units="%">
<owner>flackr@chromium.org</owner>
<owner>tdanderson@chromium.org</owner>
<summary>
The ratio between the arrow key presses and the number of overview items,
expressed as a percentage for a single session.
</summary>
</histogram>
<histogram name="Ash.WindowSelector.OverviewClosedItems">
<owner>flackr@chromium.org</owner>
<owner>tdanderson@chromium.org</owner>
<summary>
The number of items closed from the window overview for a single session.
</summary> </summary>
</histogram> </histogram>
...@@ -705,9 +744,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -705,9 +744,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<owner>flackr@chromium.org</owner> <owner>flackr@chromium.org</owner>
<owner>kuscher@google.com</owner> <owner>kuscher@google.com</owner>
<summary> <summary>
The amount of time between uses of window selection to switch between The amount of time between uses of overview mode to switch between windows.
windows. Window selection is entered by alt-tabbing or by pressing the
overview button (F5 key).
</summary> </summary>
</histogram> </histogram>
...@@ -715,11 +752,10 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -715,11 +752,10 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<owner>flackr@chromium.org</owner> <owner>flackr@chromium.org</owner>
<owner>kuscher@google.com</owner> <owner>kuscher@google.com</owner>
<summary> <summary>
The amount of time spent in overview mode. Overview mode is engaged when The amount of time spent in overview mode. Overview mode is engaged by
lingering on a window while alt-tabbing or by pressing the overview button. pressing the overview button. The time is measured from the moment the
The time is measured from the moment the windows begin animating to a windows begin animating to a thumbnail size preview to when a window is
thumbnail size preview to when a window is selected or selection is selected or selection is canceled.
canceled.
</summary> </summary>
</histogram> </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