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

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

Issue 2049007: Start transition the metrics library to non-static API. Use gmock in tests. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Break down tests to avoid explicit metrics lib mock checkpoints. 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_test.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 da96dc2c62ccb5534f094ca22ec1dcfbcedfe918..a66b570ca65c314a37ca81416b6ade2afeae6f5f 100644
--- a/src/platform/metrics/metrics_daemon.cc
+++ b/src/platform/metrics/metrics_daemon.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "metrics_daemon.h"
-#include "metrics_library.h"
#include <dbus/dbus-glib-lowlevel.h>
#include <sys/file.h>
@@ -101,14 +100,18 @@ const char* MetricsDaemon::kSessionStates_[] = {
};
void MetricsDaemon::Run(bool run_as_daemon) {
- Init(false);
+ MetricsLibrary metrics_lib;
+ metrics_lib.Init();
+ Init(false, &metrics_lib);
if (!run_as_daemon || daemon(0, 0) == 0) {
Loop();
}
}
-void MetricsDaemon::Init(bool testing) {
+void MetricsDaemon::Init(bool testing, MetricsLibraryInterface* metrics_lib) {
testing_ = testing;
+ DCHECK(metrics_lib != NULL);
+ metrics_lib_ = metrics_lib;
daily_use_record_file_ = kDailyUseRecordFile;
// Don't setup D-Bus and GLib in test mode.
@@ -444,9 +447,7 @@ void MetricsDaemon::UnscheduleUseMonitor() {
void MetricsDaemon::PublishMetric(const char* name, int sample,
int min, int max, int nbuckets) {
- LOG(INFO) << "received metric: " << name << " " << sample << " "
- << min << " " << max << " " << nbuckets;
- if (!testing_) {
- MetricsLibrary::SendToChrome(name, sample, min, max, 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_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698