diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc index b9d8cf0c4..1f20699ac 100644 --- a/metrics/metrics_daemon.cc +++ b/metrics/metrics_daemon.cc @@ -421,6 +421,7 @@ void MetricsDaemon::ReportStats(int64 active_use_seconds, Time now) { daily_cycle_->Set(day); // Daily stats. + ReportDailyUse(active_use_seconds); SendCrashFrequencySample(any_crashes_daily_count_); SendCrashFrequencySample(user_crashes_daily_count_); SendCrashFrequencySample(kernel_crashes_daily_count_); @@ -1125,18 +1126,16 @@ bool MetricsDaemon::ProcessMemuse(const string& meminfo_raw) { return true; } -// static -void MetricsDaemon::ReportDailyUse(void* handle, int count) { - if (count <= 0) +void MetricsDaemon::ReportDailyUse(int use_seconds) { + if (use_seconds <= 0) return; - MetricsDaemon* daemon = static_cast(handle); - int minutes = (count + kSecondsPerMinute / 2) / kSecondsPerMinute; - daemon->SendSample("Logging.DailyUseTime", - minutes, - 1, - kMinutesPerDay, - 50); + int minutes = (use_seconds + kSecondsPerMinute / 2) / kSecondsPerMinute; + SendSample("Logging.DailyUseTime", + minutes, + 1, + kMinutesPerDay * 30 * 2, // cumulative---two months worth + 50); } void MetricsDaemon::SendSample(const string& name, int sample, diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h index 2805cb758..de9fd740a 100644 --- a/metrics/metrics_daemon.h +++ b/metrics/metrics_daemon.h @@ -231,7 +231,7 @@ class MetricsDaemon { void UnscheduleUseMonitor(); // Report daily use through UMA. - static void ReportDailyUse(void* handle, int count); + void ReportDailyUse(int use_seconds); // Sends a regular (exponential) histogram sample to Chrome for // transport to UMA. See MetricsLibrary::SendToUMA in diff --git a/metrics/metrics_daemon_test.cc b/metrics/metrics_daemon_test.cc index aea0f4bd6..e83ad4d75 100644 --- a/metrics/metrics_daemon_test.cc +++ b/metrics/metrics_daemon_test.cc @@ -230,14 +230,14 @@ TEST_F(MetricsDaemonTest, CheckSystemCrash) { TEST_F(MetricsDaemonTest, ReportDailyUse) { ExpectDailyUseTimeSample(/* sample */ 2); - MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 90); + daemon_.ReportDailyUse(/* count */ 90); ExpectDailyUseTimeSample(/* sample */ 1); - MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 89); + daemon_.ReportDailyUse(/* count */ 89); // There should be no metrics generated for the calls below. - MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 0); - MetricsDaemon::ReportDailyUse(&daemon_, /* count */ -5); + daemon_.ReportDailyUse(/* count */ 0); + daemon_.ReportDailyUse(/* count */ -5); } TEST_F(MetricsDaemonTest, LookupPowerState) {