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

Unified Diff: metrics_daemon.cc

Issue 6541007: Find device-dependent disk stats file, and skip disk stats if not available. (Closed) Base URL: http://git.chromium.org/git/metrics.git@master
Patch Set: More small changes Created 9 years, 10 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 | « metrics_daemon.h ('k') | metrics_daemon_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: metrics_daemon.cc
diff --git a/metrics_daemon.cc b/metrics_daemon.cc
index 1e15e1dde7396490d42a473d4f94074583197350..4820590d1b035af0355d1d19701309df8d35bfe4 100644
--- a/metrics_daemon.cc
+++ b/metrics_daemon.cc
@@ -146,8 +146,7 @@ MetricsDaemon::MetricsDaemon()
session_state_(kUnknownSessionState),
user_active_(false),
usemon_interval_(0),
- usemon_source_(NULL),
- diskstats_path_(NULL) {}
+ usemon_source_(NULL) {}
MetricsDaemon::~MetricsDaemon() {
DeleteFrequencyCounters();
@@ -215,7 +214,7 @@ void MetricsDaemon::ConfigureCrashFrequencyReporter(
}
void MetricsDaemon::Init(bool testing, MetricsLibraryInterface* metrics_lib,
- const char* diskstats_path) {
+ string diskstats_path) {
testing_ = testing;
DCHECK(metrics_lib != NULL);
metrics_lib_ = metrics_lib;
@@ -243,8 +242,11 @@ void MetricsDaemon::Init(bool testing, MetricsLibraryInterface* metrics_lib,
ConfigureCrashFrequencyReporter(kMetricUserCrashesDailyName);
ConfigureCrashFrequencyReporter(kMetricUserCrashesWeeklyName);
- diskstats_path_ = diskstats_path;
- DiskStatsReporterInit();
+ // Don't attempt to collect disk stats if there is no disk stats file.
+ if (!diskstats_path.empty()) {
+ diskstats_path_ = diskstats_path;
+ DiskStatsReporterInit();
+ }
// Don't setup D-Bus and GLib in test mode.
if (testing)
@@ -541,7 +543,7 @@ void MetricsDaemon::DiskStatsReadStats(long int* read_sectors,
int nchars;
int nitems;
char line[200];
- int file = HANDLE_EINTR(open(diskstats_path_, O_RDONLY));
+ int file = HANDLE_EINTR(open(diskstats_path_.c_str(), O_RDONLY));
if (file < 0) {
PLOG(WARNING) << "cannot open " << diskstats_path_;
return;
« no previous file with comments | « metrics_daemon.h ('k') | metrics_daemon_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698