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

Side by Side Diff: ash/wm/overview/window_selector.cc

Issue 320303002: Added UMA stats to overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Rob's comments. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « ash/wm/overview/window_selector.h ('k') | ash/wm/overview/window_selector_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/overview/window_selector.h" 5 #include "ash/wm/overview/window_selector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/accessibility_delegate.h" 9 #include "ash/accessibility_delegate.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 } // namespace 90 } // namespace
91 91
92 WindowSelector::WindowSelector(const WindowList& windows, 92 WindowSelector::WindowSelector(const WindowList& windows,
93 WindowSelectorDelegate* delegate) 93 WindowSelectorDelegate* delegate)
94 : delegate_(delegate), 94 : delegate_(delegate),
95 restore_focus_window_(aura::client::GetFocusClient( 95 restore_focus_window_(aura::client::GetFocusClient(
96 Shell::GetPrimaryRootWindow())->GetFocusedWindow()), 96 Shell::GetPrimaryRootWindow())->GetFocusedWindow()),
97 ignore_activations_(false), 97 ignore_activations_(false),
98 selected_grid_index_(0),
98 overview_start_time_(base::Time::Now()), 99 overview_start_time_(base::Time::Now()),
99 selected_grid_index_(0) { 100 num_key_presses_(0),
101 num_items_(0) {
100 DCHECK(delegate_); 102 DCHECK(delegate_);
101 Shell* shell = Shell::GetInstance(); 103 Shell* shell = Shell::GetInstance();
102 shell->OnOverviewModeStarting(); 104 shell->OnOverviewModeStarting();
103 105
104 if (restore_focus_window_) 106 if (restore_focus_window_)
105 restore_focus_window_->AddObserver(this); 107 restore_focus_window_->AddObserver(this);
106 108
107 const aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 109 const aura::Window::Windows root_windows = Shell::GetAllRootWindows();
108 size_t items = 0;
109 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); 110 for (aura::Window::Windows::const_iterator iter = root_windows.begin();
110 iter != root_windows.end(); iter++) { 111 iter != root_windows.end(); iter++) {
111 // Observed switchable containers for newly created windows on all root 112 // Observed switchable containers for newly created windows on all root
112 // windows. 113 // windows.
113 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { 114 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) {
114 aura::Window* container = Shell::GetContainer(*iter, 115 aura::Window* container = Shell::GetContainer(*iter,
115 kSwitchableWindowContainerIds[i]); 116 kSwitchableWindowContainerIds[i]);
116 container->AddObserver(this); 117 container->AddObserver(this);
117 observed_windows_.insert(container); 118 observed_windows_.insert(container);
118 } 119 }
119 scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this)); 120 scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this));
120 if (grid->empty()) 121 if (grid->empty())
121 continue; 122 continue;
123 num_items_ += grid->size();
122 grid_list_.push_back(grid.release()); 124 grid_list_.push_back(grid.release());
123 items += grid_list_.size();
124 } 125 }
125 126
126 DCHECK(!grid_list_.empty()); 127 DCHECK(!grid_list_.empty());
127 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", items); 128 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_);
128 129
129 shell->activation_client()->AddObserver(this); 130 shell->activation_client()->AddObserver(this);
130 131
131 // Remove focus from active window before entering overview. 132 // Remove focus from active window before entering overview.
132 aura::client::GetFocusClient( 133 aura::client::GetFocusClient(
133 Shell::GetPrimaryRootWindow())->FocusWindow(NULL); 134 Shell::GetPrimaryRootWindow())->FocusWindow(NULL);
134 135
135 shell->PrependPreTargetHandler(this); 136 shell->PrependPreTargetHandler(this);
136 shell->GetScreen()->AddObserver(this); 137 shell->GetScreen()->AddObserver(this);
137 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); 138 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW);
(...skipping 24 matching lines...) Expand all
162 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 163 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
163 ScopedTransformOverviewWindow::kTransitionMilliseconds)); 164 ScopedTransformOverviewWindow::kTransitionMilliseconds));
164 settings.SetPreemptionStrategy( 165 settings.SetPreemptionStrategy(
165 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 166 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
166 (*iter)->layer()->SetOpacity(1); 167 (*iter)->layer()->SetOpacity(1);
167 (*iter)->Show(); 168 (*iter)->Show();
168 } 169 }
169 170
170 shell->RemovePreTargetHandler(this); 171 shell->RemovePreTargetHandler(this);
171 shell->GetScreen()->RemoveObserver(this); 172 shell->GetScreen()->RemoveObserver(this);
172 UMA_HISTOGRAM_MEDIUM_TIMES( 173
173 "Ash.WindowSelector.TimeInOverview", 174 size_t remaining_items = 0;
174 base::Time::Now() - overview_start_time_); 175 for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin();
176 iter != grid_list_.end(); iter++) {
177 remaining_items += (*iter)->size();
178 }
179
180 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.OverviewClosedItems",
flackr 2014/06/10 17:08:06 nit: DCHECK(num_items_ > remaining_items) before t
Nina 2014/06/10 18:38:23 Changed to >= because it's legal not to close any
181 num_items_ - remaining_items);
182 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowSelector.TimeInOverview",
183 base::Time::Now() - overview_start_time_);
175 184
176 // TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when 185 // TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when
177 // everything is done. 186 // everything is done.
178 shell->OnOverviewModeEnding(); 187 shell->OnOverviewModeEnding();
179 188
180 // Clearing the window list resets the ignored_by_shelf flag on the windows. 189 // Clearing the window list resets the ignored_by_shelf flag on the windows.
181 grid_list_.clear(); 190 grid_list_.clear();
182 UpdateShelfVisibility(); 191 UpdateShelfVisibility();
183 } 192 }
184 193
(...skipping 14 matching lines...) Expand all
199 208
200 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { 209 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) {
201 if (event->type() != ui::ET_KEY_PRESSED) 210 if (event->type() != ui::ET_KEY_PRESSED)
202 return; 211 return;
203 212
204 switch (event->key_code()) { 213 switch (event->key_code()) {
205 case ui::VKEY_ESCAPE: 214 case ui::VKEY_ESCAPE:
206 CancelSelection(); 215 CancelSelection();
207 break; 216 break;
208 case ui::VKEY_UP: 217 case ui::VKEY_UP:
218 num_key_presses_++;
209 Move(WindowSelector::UP); 219 Move(WindowSelector::UP);
210 break; 220 break;
211 case ui::VKEY_DOWN: 221 case ui::VKEY_DOWN:
222 num_key_presses_++;
212 Move(WindowSelector::DOWN); 223 Move(WindowSelector::DOWN);
213 break; 224 break;
214 case ui::VKEY_RIGHT: 225 case ui::VKEY_RIGHT:
226 num_key_presses_++;
215 Move(WindowSelector::RIGHT); 227 Move(WindowSelector::RIGHT);
216 break; 228 break;
217 case ui::VKEY_LEFT: 229 case ui::VKEY_LEFT:
230 num_key_presses_++;
218 Move(WindowSelector::LEFT); 231 Move(WindowSelector::LEFT);
219 break; 232 break;
220 case ui::VKEY_RETURN: 233 case ui::VKEY_RETURN:
221 // Ignore if no item is selected. 234 // Ignore if no item is selected.
222 if (!grid_list_[selected_grid_index_]->is_selecting()) 235 if (!grid_list_[selected_grid_index_]->is_selecting())
223 return; 236 return;
237 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses",
238 num_key_presses_);
239 UMA_HISTOGRAM_CUSTOM_COUNTS(
240 "Ash.WindowSelector.KeyPressesOverItemsRatio",
241 (num_key_presses_ * 100) / num_items_, 1, 300, 30);
242 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
243 UMA_WINDOW_OVERVIEW_ENTER_KEY);
224 wm::GetWindowState(grid_list_[selected_grid_index_]-> 244 wm::GetWindowState(grid_list_[selected_grid_index_]->
225 SelectedWindow()->SelectionWindow())->Activate(); 245 SelectedWindow()->SelectionWindow())->Activate();
226 break; 246 break;
227 default: 247 default:
228 // Not a key we are interested in. 248 // Not a key we are interested in.
229 return; 249 return;
230 } 250 }
231 event->StopPropagation(); 251 event->StopPropagation();
232 } 252 }
233 253
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // root window, identify it and call Move() on it to initialize the 385 // root window, identify it and call Move() on it to initialize the
366 // selection widget. 386 // selection widget.
367 // TODO(nsatragno): If there are more than two monitors, move between grids 387 // TODO(nsatragno): If there are more than two monitors, move between grids
368 // in the requested direction. 388 // in the requested direction.
369 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); 389 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size();
370 grid_list_[selected_grid_index_]->Move(direction); 390 grid_list_[selected_grid_index_]->Move(direction);
371 } 391 }
372 } 392 }
373 393
374 } // namespace ash 394 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector.h ('k') | ash/wm/overview/window_selector_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698