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

Unified 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 4. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/metrics/user_metrics_recorder.h ('k') | ash/metrics/user_metrics_recorder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/metrics/user_metrics_recorder.cc
diff --git a/ash/metrics/user_metrics_recorder.cc b/ash/metrics/user_metrics_recorder.cc
index c1c9e631aeaeff5ec581bd8a35b96c74bd6f5340..89a355f51b7b13d99cedc4be34c6fdf46078b901 100644
--- a/ash/metrics/user_metrics_recorder.cc
+++ b/ash/metrics/user_metrics_recorder.cc
@@ -4,11 +4,13 @@
#include "ash/metrics/user_metrics_recorder.h"
+#include "ash/session/session_state_delegate.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "ash/system/tray/system_tray_delegate.h"
#include "ash/wm/window_state.h"
#include "base/metrics/histogram.h"
#include "base/metrics/user_metrics.h"
@@ -64,6 +66,31 @@ ActiveWindowStateType GetActiveWindowState() {
return active_window_state_type;
}
+// Returns true if kiosk mode is active.
+bool IsKioskModeActive() {
+ return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() ==
+ user::LOGGED_IN_KIOSK_APP;
+}
+
+// Returns true if there is an active user and their session isn't currently
+// locked.
+bool IsUserActive() {
+ switch (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()) {
+ case user::LOGGED_IN_NONE:
+ case user::LOGGED_IN_LOCKED:
+ return false;
+ case user::LOGGED_IN_USER:
+ case user::LOGGED_IN_OWNER:
+ case user::LOGGED_IN_GUEST:
+ case user::LOGGED_IN_PUBLIC:
+ case user::LOGGED_IN_SUPERVISED:
+ case user::LOGGED_IN_KIOSK_APP:
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
// Array of window container ids that contain visible windows to be counted for
// UMA statistics. Note the containers are ordered from top most visible
// container to the lowest to allow the |GetNumVisibleWindows| method to short
@@ -124,10 +151,12 @@ int GetNumVisibleWindowsInPrimaryDisplay() {
} // namespace
UserMetricsRecorder::UserMetricsRecorder() {
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
- this,
- &UserMetricsRecorder::RecordPeriodicMetrics);
+ StartTimer();
+}
+
+UserMetricsRecorder::UserMetricsRecorder(bool record_periodic_metrics) {
+ if (record_periodic_metrics)
+ StartTimer();
}
UserMetricsRecorder::~UserMetricsRecorder() {
@@ -519,7 +548,10 @@ void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
void UserMetricsRecorder::RecordPeriodicMetrics() {
ShelfLayoutManager* manager =
ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
+ // TODO(bruthig): Investigating whether the check for |manager| is necessary
+ // and add tests if it is.
if (manager) {
+ // TODO(bruthig): Consider tracking the time spent in each alignment.
UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
manager->SelectValueForShelfAlignment(
SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
@@ -529,12 +561,28 @@ void UserMetricsRecorder::RecordPeriodicMetrics() {
SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
}
- UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
- GetNumVisibleWindowsInPrimaryDisplay());
+ if (IsUserInActiveDesktopEnvironment()) {
+ UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
+ GetNumVisibleWindowsInPrimaryDisplay());
+ }
+ // TODO(bruthig): Find out if this should only be logged when the user is
+ // active.
+ // TODO(bruthig): Consider tracking how long a particular type of window is
+ // active at a time.
UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
GetActiveWindowState(),
ACTIVE_WINDOW_STATE_TYPE_COUNT);
}
+bool UserMetricsRecorder::IsUserInActiveDesktopEnvironment() const {
+ return IsUserActive() && !IsKioskModeActive();
+}
+
+void UserMetricsRecorder::StartTimer() {
+ timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
+ this, &UserMetricsRecorder::RecordPeriodicMetrics);
+}
+
} // namespace ash
« no previous file with comments | « ash/metrics/user_metrics_recorder.h ('k') | ash/metrics/user_metrics_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698