Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1906)

Unified Diff: ash/wm/window_cycle_controller.cc

Issue 1126333005: Added metrics to track the time between task switches done via Alt+Tab and Alt+Shift+Tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed kAcceleratorWindowCycle_histogram to kAcceleratorWindowCycleHistogramName. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_cycle_controller.cc
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index 42f866e38e0ab17e7ba7cb39ea2e47d6b41e68a0..98f93391c27b009d25e92cb65095bab72bc69fdc 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -4,11 +4,13 @@
#include "ash/wm/window_cycle_controller.h"
+#include "ash/metrics/user_metrics_recorder.h"
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_cycle_list.h"
#include "base/metrics/histogram.h"
+#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
@@ -16,6 +18,12 @@ namespace ash {
namespace {
+// Returns the most recently active window from the |window_list| or nullptr
+// if the list is empty.
+aura::Window* GetActiveWindow(const MruWindowTracker::WindowList& window_list) {
+ return window_list.size() > 0 ? window_list[0] : nullptr;
Alexei Svitkine (slow) 2015/05/14 20:42:14 Nit: .size() > 0 -> !.empty()
bruthig 2015/05/14 22:06:40 Done.
+}
+
// Filter to watch for the termination of a keyboard gesture to cycle through
// multiple windows.
class WindowCycleEventFilter : public ui::EventHandler {
@@ -77,8 +85,12 @@ void WindowCycleController::HandleCycleWindow(Direction direction) {
}
void WindowCycleController::StartCycling() {
- window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()->
- mru_window_tracker()->BuildMruWindowList()));
+ MruWindowTracker::WindowList window_list =
+ Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList();
+
+ active_window_before_window_cycle_ = GetActiveWindow(window_list);
oshima 2015/05/14 17:12:36 doesn't GetActiveWindow work here?
bruthig 2015/05/14 17:49:44 Summary of discussion offline. wm::GetActiveWindo
oshima 2015/05/14 18:13:00 Acknowledged.
+
+ window_cycle_list_.reset(new WindowCycleList(window_list));
event_handler_.reset(new WindowCycleEventFilter());
cycle_start_time_ = base::Time::Now();
Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_WINDOW_CYCLE);
@@ -94,10 +106,23 @@ void WindowCycleController::Step(Direction direction) {
void WindowCycleController::StopCycling() {
window_cycle_list_.reset();
+
+ aura::Window* active_window_after_window_cycle = GetActiveWindow(
+ Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList());
+
// Remove our key event filter.
event_handler_.reset();
UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime",
base::Time::Now() - cycle_start_time_);
+
+ if (active_window_after_window_cycle != nullptr &&
+ active_window_before_window_cycle_ != active_window_after_window_cycle) {
+ Shell::GetInstance()
+ ->metrics()
+ ->task_switch_metrics_recorder()
+ .OnTaskSwitch(TaskSwitchMetricsRecorder::kWindowCycleController);
+ }
+ active_window_before_window_cycle_ = nullptr;
}
} // namespace ash
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698