OLD | NEW |
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/metrics/user_metrics_recorder.h" | 5 #include "ash/metrics/user_metrics_recorder.h" |
6 | 6 |
7 #include "ash/metrics/desktop_task_switch_metric_recorder.h" | |
8 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
9 #include "ash/shelf/shelf_delegate.h" | 8 #include "ash/shelf/shelf_delegate.h" |
10 #include "ash/shelf/shelf_item_types.h" | 9 #include "ash/shelf/shelf_item_types.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_model.h" | 11 #include "ash/shelf/shelf_model.h" |
13 #include "ash/shelf/shelf_view.h" | 12 #include "ash/shelf/shelf_view.h" |
14 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shell.h" | 14 #include "ash/shell.h" |
16 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
17 #include "ash/system/tray/system_tray_delegate.h" | 16 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 base::RecordAction( | 229 base::RecordAction( |
231 base::UserMetricsAction("Accel_Restart_PowerButton")); | 230 base::UserMetricsAction("Accel_Restart_PowerButton")); |
232 break; | 231 break; |
233 case ash::UMA_ACCEL_SHUT_DOWN_POWER_BUTTON: | 232 case ash::UMA_ACCEL_SHUT_DOWN_POWER_BUTTON: |
234 base::RecordAction( | 233 base::RecordAction( |
235 base::UserMetricsAction("Accel_ShutDown_PowerButton")); | 234 base::UserMetricsAction("Accel_ShutDown_PowerButton")); |
236 break; | 235 break; |
237 case ash::UMA_CLOSE_THROUGH_CONTEXT_MENU: | 236 case ash::UMA_CLOSE_THROUGH_CONTEXT_MENU: |
238 base::RecordAction(base::UserMetricsAction("CloseFromContextMenu")); | 237 base::RecordAction(base::UserMetricsAction("CloseFromContextMenu")); |
239 break; | 238 break; |
240 case ash::UMA_DESKTOP_SWITCH_TASK: | |
241 base::RecordAction(base::UserMetricsAction("Desktop_SwitchTask")); | |
242 task_switch_metrics_recorder_.OnTaskSwitch( | |
243 TaskSwitchMetricsRecorder::kDesktop); | |
244 break; | |
245 case ash::UMA_DRAG_MAXIMIZE_LEFT: | 239 case ash::UMA_DRAG_MAXIMIZE_LEFT: |
246 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeLeft")); | 240 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeLeft")); |
247 break; | 241 break; |
248 case ash::UMA_DRAG_MAXIMIZE_RIGHT: | 242 case ash::UMA_DRAG_MAXIMIZE_RIGHT: |
249 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeRight")); | 243 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeRight")); |
250 break; | 244 break; |
251 case ash::UMA_GESTURE_OVERVIEW: | 245 case ash::UMA_GESTURE_OVERVIEW: |
252 base::RecordAction(base::UserMetricsAction("Gesture_Overview")); | 246 base::RecordAction(base::UserMetricsAction("Gesture_Overview")); |
253 break; | 247 break; |
254 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE: | 248 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE: |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 base::RecordAction( | 591 base::RecordAction( |
598 base::UserMetricsAction("WindowSelector_OverviewEnterKey")); | 592 base::UserMetricsAction("WindowSelector_OverviewEnterKey")); |
599 break; | 593 break; |
600 case ash::UMA_WINDOW_CYCLE: | 594 case ash::UMA_WINDOW_CYCLE: |
601 base::RecordAction( | 595 base::RecordAction( |
602 base::UserMetricsAction("WindowCycleController_Cycle")); | 596 base::UserMetricsAction("WindowCycleController_Cycle")); |
603 break; | 597 break; |
604 } | 598 } |
605 } | 599 } |
606 | 600 |
607 void UserMetricsRecorder::OnShellInitialized() { | |
608 // Lazy creation of the DesktopTaskSwitchMetricRecorder because it accesses | |
609 // Shell::GetInstance() which is not available when |this| is instantiated. | |
610 if (!desktop_task_switch_metric_recorder_) { | |
611 desktop_task_switch_metric_recorder_.reset( | |
612 new DesktopTaskSwitchMetricRecorder()); | |
613 } | |
614 } | |
615 | |
616 void UserMetricsRecorder::OnShellShuttingDown() { | |
617 desktop_task_switch_metric_recorder_.reset(); | |
618 } | |
619 | |
620 void UserMetricsRecorder::RecordPeriodicMetrics() { | 601 void UserMetricsRecorder::RecordPeriodicMetrics() { |
621 ShelfLayoutManager* manager = | 602 ShelfLayoutManager* manager = |
622 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()); | 603 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()); |
623 // TODO(bruthig): Investigating whether the check for |manager| is necessary | 604 // TODO(bruthig): Investigating whether the check for |manager| is necessary |
624 // and add tests if it is. | 605 // and add tests if it is. |
625 if (manager) { | 606 if (manager) { |
626 // TODO(bruthig): Consider tracking the time spent in each alignment. | 607 // TODO(bruthig): Consider tracking the time spent in each alignment. |
627 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", | 608 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", |
628 manager->SelectValueForShelfAlignment( | 609 manager->SelectValueForShelfAlignment( |
629 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, | 610 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, |
(...skipping 22 matching lines...) Expand all Loading... |
652 return IsUserActive() && !IsKioskModeActive(); | 633 return IsUserActive() && !IsKioskModeActive(); |
653 } | 634 } |
654 | 635 |
655 void UserMetricsRecorder::StartTimer() { | 636 void UserMetricsRecorder::StartTimer() { |
656 timer_.Start(FROM_HERE, | 637 timer_.Start(FROM_HERE, |
657 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), | 638 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), |
658 this, &UserMetricsRecorder::RecordPeriodicMetrics); | 639 this, &UserMetricsRecorder::RecordPeriodicMetrics); |
659 } | 640 } |
660 | 641 |
661 } // namespace ash | 642 } // namespace ash |
OLD | NEW |