Chromium Code Reviews| Index: metrics_daemon.cc |
| diff --git a/metrics_daemon.cc b/metrics_daemon.cc |
| index 1e15e1dde7396490d42a473d4f94074583197350..06a8bb0cd6930bf271c532ab17e1b3519229f45c 100644 |
| --- a/metrics_daemon.cc |
| +++ b/metrics_daemon.cc |
| @@ -147,7 +147,7 @@ MetricsDaemon::MetricsDaemon() |
| user_active_(false), |
| usemon_interval_(0), |
| usemon_source_(NULL), |
| - diskstats_path_(NULL) {} |
| + diskstats_path_("") {} |
|
petkov
2011/02/18 04:52:00
no need to initialize std::string to "" -- it will
|
| MetricsDaemon::~MetricsDaemon() { |
| DeleteFrequencyCounters(); |
| @@ -215,7 +215,7 @@ void MetricsDaemon::ConfigureCrashFrequencyReporter( |
| } |
| void MetricsDaemon::Init(bool testing, MetricsLibraryInterface* metrics_lib, |
| - const char* diskstats_path) { |
| + std::string diskstats_path) { |
|
petkov
2011/02/18 04:52:00
s/std::string/string/
|
| testing_ = testing; |
| DCHECK(metrics_lib != NULL); |
| metrics_lib_ = metrics_lib; |
| @@ -243,8 +243,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 +544,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; |