[ash-md] Adds UMA items count and selection depth for Alt+Tab

Adds Ash.WindowCycleController.Items UMA histogram that records how
many windows are included in Alt+Tab enumeration. The count is captured
when Alt+Tab is pressed.

Adds Ash.WindowCycleController.SelectionDepth UMA histogram that records
how often users finish Alt+Tab selection on a window that is N-th in MRU
order. Selecting a window that is already currently active (top in MRU
order) records 1.

BUG=621562

Review-Url: https://codereview.chromium.org/2096063002
Cr-Commit-Position: refs/heads/master@{#402365}
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index a0d951c8..c497235 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -94,6 +94,8 @@
   event_handler_.reset(new WindowCycleEventFilter());
   cycle_start_time_ = base::Time::Now();
   WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
+  UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items",
+                           window_list.size());
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -105,6 +107,8 @@
 }
 
 void WindowCycleController::StopCycling() {
+  UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.SelectionDepth",
+                           window_cycle_list_->current_index() + 1);
   window_cycle_list_.reset();
 
   WmWindow* active_window_after_window_cycle = GetActiveWindow(
diff --git a/ash/wm/window_cycle_list.h b/ash/wm/window_cycle_list.h
index 722f8ac5..9420a29b 100644
--- a/ash/wm/window_cycle_list.h
+++ b/ash/wm/window_cycle_list.h
@@ -31,6 +31,8 @@
   // Cycles to the next or previous window based on |direction|.
   void Step(WindowCycleController::Direction direction);
 
+  int current_index() const { return current_index_; }
+
  private:
   friend class WindowCycleControllerTest;
   const WindowList& windows() const { return windows_; }
@@ -47,7 +49,8 @@
   // alt key).
   WindowList windows_;
 
-  // Current position in the |windows_|
+  // Current position in the |windows_|. Can be used to query selection depth,
+  // i.e., the position of an active window in a global MRU ordering.
   int current_index_;
 
   // Wrapper for the window brought to the front.
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 199f927..0a82798 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -1516,18 +1516,38 @@
 </histogram>
 
 <histogram name="Ash.WindowCycleController.CycleTime" units="ms">
-  <owner>flackr@chromium.org</owner>
-  <owner>kuscher@google.com</owner>
+  <owner>varkha@chromium.org</owner>
+  <owner>tbuckley@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.WindowCycleController.Items" units="items">
+  <owner>varkha@chromium.org</owner>
+  <owner>tbuckley@google.com</owner>
+  <summary>
+    The number of windows in the Alt+Tab selector. Only recorded once when
+    cycling starts, not every time when Tab is pressed without releasing Alt.
+  </summary>
+</histogram>
+
+<histogram name="Ash.WindowCycleController.SelectionDepth" units="items">
+  <owner>varkha@chromium.org</owner>
+  <owner>tbuckley@google.com</owner>
+  <summary>
+    When a window is selected after pressing Alt+Tab, records that window's
+    position in the global MRU ordering. 1 represents the most-recently used
+    window, 2 represents the next most-recently used window, and so on. Recorded
+    when Alt+Tab cycling stops, i.e., when Alt key is released.
+  </summary>
+</histogram>
+
 <histogram name="Ash.WindowCycleController.TimeBetweenTaskSwitches"
     units="seconds">
-  <owner>tdanderson@google.com</owner>
-  <owner>bruthig@google.com</owner>
+  <owner>varkha@chromium.org</owner>
+  <owner>tbuckley@google.com</owner>
   <summary>
     The number of seconds between task switches triggered by the next window and
     previous window accelerator keys (ie Alt+Tab, Alt+Shift+Tab).