OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/window_cycle_controller.h" | 5 #include "ash/wm/window_cycle_controller.h" |
6 | 6 |
7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/mru_window_tracker.h" | 9 #include "ash/wm/mru_window_tracker.h" |
10 #include "ash/wm/window_cycle_list.h" | 10 #include "ash/wm/window_cycle_list.h" |
| 11 #include "base/metrics/histogram.h" |
11 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
12 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
13 | 14 |
14 namespace ash { | 15 namespace ash { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Filter to watch for the termination of a keyboard gesture to cycle through | 19 // Filter to watch for the termination of a keyboard gesture to cycle through |
19 // multiple windows. | 20 // multiple windows. |
20 class WindowCycleEventFilter : public ui::EventHandler { | 21 class WindowCycleEventFilter : public ui::EventHandler { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (!IsCycling()) | 73 if (!IsCycling()) |
73 StartCycling(); | 74 StartCycling(); |
74 | 75 |
75 Step(direction); | 76 Step(direction); |
76 } | 77 } |
77 | 78 |
78 void WindowCycleController::StartCycling() { | 79 void WindowCycleController::StartCycling() { |
79 window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()-> | 80 window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()-> |
80 mru_window_tracker()->BuildMruWindowList())); | 81 mru_window_tracker()->BuildMruWindowList())); |
81 event_handler_.reset(new WindowCycleEventFilter()); | 82 event_handler_.reset(new WindowCycleEventFilter()); |
| 83 cycle_start_time_ = base::Time::Now(); |
| 84 Shell::GetInstance()->metrics()->RecordUserMetricsAction(UMA_WINDOW_CYCLE); |
82 } | 85 } |
83 | 86 |
84 ////////////////////////////////////////////////////////////////////////////// | 87 ////////////////////////////////////////////////////////////////////////////// |
85 // WindowCycleController, private: | 88 // WindowCycleController, private: |
86 | 89 |
87 void WindowCycleController::Step(Direction direction) { | 90 void WindowCycleController::Step(Direction direction) { |
88 DCHECK(window_cycle_list_.get()); | 91 DCHECK(window_cycle_list_.get()); |
89 window_cycle_list_->Step(direction); | 92 window_cycle_list_->Step(direction); |
90 } | 93 } |
91 | 94 |
92 void WindowCycleController::StopCycling() { | 95 void WindowCycleController::StopCycling() { |
93 window_cycle_list_.reset(); | 96 window_cycle_list_.reset(); |
94 // Remove our key event filter. | 97 // Remove our key event filter. |
95 event_handler_.reset(); | 98 event_handler_.reset(); |
| 99 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime", |
| 100 base::Time::Now() - cycle_start_time_); |
96 } | 101 } |
97 | 102 |
98 } // namespace ash | 103 } // namespace ash |
OLD | NEW |