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..a1ff9b321fa7aa007bde7bf9ed189993b3e2c57b 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" |
@@ -124,10 +126,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() { |
@@ -529,12 +533,30 @@ void UserMetricsRecorder::RecordPeriodicMetrics() { |
SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); |
} |
- UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay", |
- GetNumVisibleWindowsInPrimaryDisplay()); |
+ if (UserIsActive()) { |
pkotwicz
2015/04/17 13:45:38
Should we also ignore kiosk mode? In kiosk mode, a
bruthig
2015/04/17 14:41:23
Good point, I agree it should probably not be logg
tdanderson
2015/04/17 17:59:57
Agreed, let's ignore kiosk mode.
bruthig
2015/04/21 14:34:05
Done.
|
+ UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay", |
+ GetNumVisibleWindowsInPrimaryDisplay()); |
+ } |
+ // TODO(bruthig): Find out if this should only be logged when the user is |
+ // active. |
UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime", |
tdanderson
2015/04/17 17:59:57
IMO, we should only be collecting periodic metrics
bruthig
2015/04/21 14:34:05
I will check with the owner's on these and will ma
|
GetActiveWindowState(), |
ACTIVE_WINDOW_STATE_TYPE_COUNT); |
} |
sadrul
2015/04/17 22:55:39
This function is ... interesting. What are the val
bruthig
2015/04/21 14:34:05
I've added some TODO's to consider these suggestio
sadrul
2015/04/21 17:24:56
The only concern I have is that this data is not u
oshima
2015/04/25 01:06:58
You can listen to activation change plus login sta
|
+bool UserMetricsRecorder::UserIsActive() { |
+ return Shell::GetInstance() |
+ ->session_state_delegate() |
+ ->IsActiveUserSessionStarted() && |
+ Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() != |
+ user::LOGGED_IN_LOCKED; |
tdanderson
2015/04/17 17:59:57
Is the first clause necessary here?
bruthig
2015/04/21 14:34:05
Removed.
|
+} |
+ |
+void UserMetricsRecorder::StartTimer() { |
+ timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), |
+ this, &UserMetricsRecorder::RecordPeriodicMetrics); |
+} |
+ |
} // namespace ash |