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

Side by Side Diff: ash/metrics/user_metrics_recorder.cc

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 9 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/focus_cycler_unittest.cc ('k') | ash/root_window_controller.h » ('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/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" 7 #include "ash/metrics/desktop_task_switch_metric_recorder.h"
8 #include "ash/session/session_state_delegate.h" 8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_delegate.h" 10 #include "ash/shelf/shelf_delegate.h"
10 #include "ash/shelf/shelf_item_types.h" 11 #include "ash/shelf/shelf_item_types.h"
11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_model.h" 12 #include "ash/shelf/shelf_model.h"
13 #include "ash/shelf/shelf_view.h" 13 #include "ash/shelf/shelf_view.h"
14 #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"
18 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
19 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
20 #include "base/metrics/user_metrics.h" 19 #include "base/metrics/user_metrics.h"
21 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
22 21
23 namespace ash { 22 namespace ash {
24 23
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 desktop_task_switch_metric_recorder_.reset( 614 desktop_task_switch_metric_recorder_.reset(
616 new DesktopTaskSwitchMetricRecorder()); 615 new DesktopTaskSwitchMetricRecorder());
617 } 616 }
618 } 617 }
619 618
620 void UserMetricsRecorder::OnShellShuttingDown() { 619 void UserMetricsRecorder::OnShellShuttingDown() {
621 desktop_task_switch_metric_recorder_.reset(); 620 desktop_task_switch_metric_recorder_.reset();
622 } 621 }
623 622
624 void UserMetricsRecorder::RecordPeriodicMetrics() { 623 void UserMetricsRecorder::RecordPeriodicMetrics() {
625 ShelfLayoutManager* manager = 624 Shelf* shelf = Shelf::ForPrimaryDisplay();
626 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
627 // TODO(bruthig): Investigating whether the check for |manager| is necessary 625 // TODO(bruthig): Investigating whether the check for |manager| is necessary
628 // and add tests if it is. 626 // and add tests if it is.
629 if (manager) { 627 if (shelf) {
630 // TODO(bruthig): Consider tracking the time spent in each alignment. 628 // TODO(bruthig): Consider tracking the time spent in each alignment.
631 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", 629 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
632 manager->SelectValueForShelfAlignment( 630 shelf->SelectValueForShelfAlignment(
633 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, 631 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
634 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, 632 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
635 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, 633 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, -1),
636 -1),
637 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); 634 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
638 } 635 }
639 636
640 if (IsUserInActiveDesktopEnvironment()) { 637 if (IsUserInActiveDesktopEnvironment()) {
641 RecordShelfItemCounts(); 638 RecordShelfItemCounts();
642 UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay", 639 UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
643 GetNumVisibleWindowsInPrimaryDisplay()); 640 GetNumVisibleWindowsInPrimaryDisplay());
644 } 641 }
645 642
646 // TODO(bruthig): Find out if this should only be logged when the user is 643 // TODO(bruthig): Find out if this should only be logged when the user is
647 // active. 644 // active.
648 // TODO(bruthig): Consider tracking how long a particular type of window is 645 // TODO(bruthig): Consider tracking how long a particular type of window is
649 // active at a time. 646 // active at a time.
650 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime", 647 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
651 GetActiveWindowState(), 648 GetActiveWindowState(),
652 ACTIVE_WINDOW_STATE_TYPE_COUNT); 649 ACTIVE_WINDOW_STATE_TYPE_COUNT);
653 } 650 }
654 651
655 bool UserMetricsRecorder::IsUserInActiveDesktopEnvironment() const { 652 bool UserMetricsRecorder::IsUserInActiveDesktopEnvironment() const {
656 return IsUserActive() && !IsKioskModeActive(); 653 return IsUserActive() && !IsKioskModeActive();
657 } 654 }
658 655
659 void UserMetricsRecorder::StartTimer() { 656 void UserMetricsRecorder::StartTimer() {
660 timer_.Start(FROM_HERE, 657 timer_.Start(FROM_HERE,
661 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), 658 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
662 this, &UserMetricsRecorder::RecordPeriodicMetrics); 659 this, &UserMetricsRecorder::RecordPeriodicMetrics);
663 } 660 }
664 661
665 } // namespace ash 662 } // namespace ash
OLDNEW
« no previous file with comments | « ash/focus_cycler_unittest.cc ('k') | ash/root_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698