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

Unified Diff: src/platform/metrics/metrics_daemon.cc

Issue 2079007: Add metrics library tests. Some metrics daemon API cleanup. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: A bit more cleanup. Created 10 years, 7 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 | « src/platform/metrics/metrics_daemon.h ('k') | src/platform/metrics/metrics_daemon_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/metrics/metrics_daemon.cc
diff --git a/src/platform/metrics/metrics_daemon.cc b/src/platform/metrics/metrics_daemon.cc
index a66b570ca65c314a37ca81416b6ade2afeae6f5f..6e01932431a1bdceca399505fed1934454eb36ef 100644
--- a/src/platform/metrics/metrics_daemon.cc
+++ b/src/platform/metrics/metrics_daemon.cc
@@ -100,9 +100,6 @@ const char* MetricsDaemon::kSessionStates_[] = {
};
void MetricsDaemon::Run(bool run_as_daemon) {
- MetricsLibrary metrics_lib;
- metrics_lib.Init();
- Init(false, &metrics_lib);
if (!run_as_daemon || daemon(0, 0) == 0) {
Loop();
}
@@ -223,10 +220,10 @@ void MetricsDaemon::NetStateChanged(const char* state_name, time_t now) {
network_state_ == kNetworkStateOnline &&
power_state_ != kPowerStateMem) {
int online_time = static_cast<int>(now - network_state_last_);
- PublishMetric(kMetricTimeToNetworkDropName, online_time,
- kMetricTimeToNetworkDropMin,
- kMetricTimeToNetworkDropMax,
- kMetricTimeToNetworkDropBuckets);
+ SendMetric(kMetricTimeToNetworkDropName, online_time,
+ kMetricTimeToNetworkDropMin,
+ kMetricTimeToNetworkDropMax,
+ kMetricTimeToNetworkDropBuckets);
}
network_state_ = state;
@@ -349,10 +346,10 @@ void MetricsDaemon::LogDailyUseRecord(int day, int seconds) {
// the usage to the nearest minute and sends it to UMA.
int minutes =
(record.seconds_ + kSecondsPerMinute / 2) / kSecondsPerMinute;
- PublishMetric(kMetricDailyUseTimeName, minutes,
- kMetricDailyUseTimeMin,
- kMetricDailyUseTimeMax,
- kMetricDailyUseTimeBuckets);
+ SendMetric(kMetricDailyUseTimeName, minutes,
+ kMetricDailyUseTimeMin,
+ kMetricDailyUseTimeMax,
+ kMetricDailyUseTimeBuckets);
// Truncates the usage file to ensure that no duplicate usage is
// sent to UMA.
@@ -445,8 +442,8 @@ void MetricsDaemon::UnscheduleUseMonitor() {
usemon_interval_ = 0;
}
-void MetricsDaemon::PublishMetric(const char* name, int sample,
- int min, int max, int nbuckets) {
+void MetricsDaemon::SendMetric(const std::string& name, int sample,
+ int min, int max, int nbuckets) {
DLOG(INFO) << "received metric: " << name << " " << sample << " "
<< min << " " << max << " " << nbuckets;
metrics_lib_->SendToUMA(name, sample, min, max, nbuckets);
« no previous file with comments | « src/platform/metrics/metrics_daemon.h ('k') | src/platform/metrics/metrics_daemon_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698