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

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

Issue 1093483002: Changed when the UMA metric Ash.NumberOfVisibleWindowsInPrimaryDisplay is recorded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from patch set 2. Created 5 years, 8 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
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/session/session_state_delegate.h"
7 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_view.h" 9 #include "ash/shelf/shelf_view.h"
9 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/system/tray/system_tray_delegate.h"
12 #include "ash/wm/window_state.h" 14 #include "ash/wm/window_state.h"
13 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
14 #include "base/metrics/user_metrics.h" 16 #include "base/metrics/user_metrics.h"
15 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
16 18
17 namespace ash { 19 namespace ash {
18 20
19 namespace { 21 namespace {
20 22
21 // Time in seconds between calls to "RecordPeriodicMetrics". 23 // Time in seconds between calls to "RecordPeriodicMetrics".
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 case wm::WINDOW_STATE_TYPE_INACTIVE: 59 case wm::WINDOW_STATE_TYPE_INACTIVE:
58 case wm::WINDOW_STATE_TYPE_END: 60 case wm::WINDOW_STATE_TYPE_END:
59 case wm::WINDOW_STATE_TYPE_AUTO_POSITIONED: 61 case wm::WINDOW_STATE_TYPE_AUTO_POSITIONED:
60 active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_OTHER; 62 active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_OTHER;
61 break; 63 break;
62 } 64 }
63 } 65 }
64 return active_window_state_type; 66 return active_window_state_type;
65 } 67 }
66 68
69 // Returns true if Kiosk mode is active.
pkotwicz 2015/04/21 16:15:17 Nit: "Kiosk mode" -> "kiosk mode"
bruthig 2015/04/24 20:00:11 Done.
70 bool IsKioskModeActive() {
71 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() ==
72 user::LOGGED_IN_KIOSK_APP;
73 }
74
75 // Returns true if there is an active user and their session isn't currently
76 // locked.
77 bool IsUserActive() {
78 switch (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()) {
79 case user::LOGGED_IN_NONE:
80 case user::LOGGED_IN_LOCKED:
81 return false;
82 case user::LOGGED_IN_USER:
83 case user::LOGGED_IN_OWNER:
84 case user::LOGGED_IN_GUEST:
85 case user::LOGGED_IN_PUBLIC:
86 case user::LOGGED_IN_SUPERVISED:
87 case user::LOGGED_IN_KIOSK_APP:
88 return true;
89 }
90 NOTREACHED();
91 return false;
92 }
93
67 // Array of window container ids that contain visible windows to be counted for 94 // Array of window container ids that contain visible windows to be counted for
68 // UMA statistics. Note the containers are ordered from top most visible 95 // UMA statistics. Note the containers are ordered from top most visible
69 // container to the lowest to allow the |GetNumVisibleWindows| method to short 96 // container to the lowest to allow the |GetNumVisibleWindows| method to short
70 // circuit when processing a maximized or fullscreen window. 97 // circuit when processing a maximized or fullscreen window.
71 int kVisibleWindowContainerIds[] = {kShellWindowId_PanelContainer, 98 int kVisibleWindowContainerIds[] = {kShellWindowId_PanelContainer,
72 kShellWindowId_DockedContainer, 99 kShellWindowId_DockedContainer,
73 kShellWindowId_AlwaysOnTopContainer, 100 kShellWindowId_AlwaysOnTopContainer,
74 kShellWindowId_DefaultContainer}; 101 kShellWindowId_DefaultContainer};
75 102
76 // Returns an approximate count of how many windows are currently visible in the 103 // Returns an approximate count of how many windows are currently visible in the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 break; 144 break;
118 } 145 }
119 } 146 }
120 } 147 }
121 return visible_window_count; 148 return visible_window_count;
122 } 149 }
123 150
124 } // namespace 151 } // namespace
125 152
126 UserMetricsRecorder::UserMetricsRecorder() { 153 UserMetricsRecorder::UserMetricsRecorder() {
127 timer_.Start(FROM_HERE, 154 StartTimer();
128 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), 155 }
129 this, 156
130 &UserMetricsRecorder::RecordPeriodicMetrics); 157 UserMetricsRecorder::UserMetricsRecorder(bool record_periodic_metrics) {
158 if (record_periodic_metrics)
159 StartTimer();
131 } 160 }
132 161
133 UserMetricsRecorder::~UserMetricsRecorder() { 162 UserMetricsRecorder::~UserMetricsRecorder() {
134 timer_.Stop(); 163 timer_.Stop();
135 } 164 }
136 165
137 void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) { 166 void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
138 switch (action) { 167 switch (action) {
139 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6: 168 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6:
140 base::RecordAction( 169 base::RecordAction(
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 base::RecordAction( 542 base::RecordAction(
514 base::UserMetricsAction("WindowCycleController_Cycle")); 543 base::UserMetricsAction("WindowCycleController_Cycle"));
515 break; 544 break;
516 } 545 }
517 } 546 }
518 547
519 void UserMetricsRecorder::RecordPeriodicMetrics() { 548 void UserMetricsRecorder::RecordPeriodicMetrics() {
520 ShelfLayoutManager* manager = 549 ShelfLayoutManager* manager =
521 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()); 550 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
522 if (manager) { 551 if (manager) {
552 // TODO(bruthig): Consider tracking the time spent in each alignment.
523 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime", 553 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
524 manager->SelectValueForShelfAlignment( 554 manager->SelectValueForShelfAlignment(
525 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, 555 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
526 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, 556 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
527 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, 557 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT,
528 -1), 558 -1),
529 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); 559 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
530 } 560 }
531 561
532 UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay", 562 if (IsUserActiveInMultiWindowEnvironment()) {
533 GetNumVisibleWindowsInPrimaryDisplay()); 563 UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
564 GetNumVisibleWindowsInPrimaryDisplay());
565 }
534 566
567 // TODO(bruthig): Find out if this should only be logged when the user is
568 // active.
569 // TODO(bruthig): Consider tracking how long a particular type of window is
570 // active at a time.
535 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime", 571 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
536 GetActiveWindowState(), 572 GetActiveWindowState(),
537 ACTIVE_WINDOW_STATE_TYPE_COUNT); 573 ACTIVE_WINDOW_STATE_TYPE_COUNT);
538 } 574 }
539 575
576 bool UserMetricsRecorder::IsUserActiveInMultiWindowEnvironment() const {
577 return IsUserActive() && !IsKioskModeActive();
578 }
579
580 void UserMetricsRecorder::StartTimer() {
581 timer_.Start(FROM_HERE,
582 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
583 this, &UserMetricsRecorder::RecordPeriodicMetrics);
584 }
585
540 } // namespace ash 586 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698