Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <string> | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/metrics/chromeos_metrics.h" | |
| 9 #include "base/metrics/linearhistogram_sample.h" | |
| 10 #include "base/metrics/metric_sample.h" | |
| 11 | |
| 12 using std::string; | |
| 13 | |
| 14 namespace base { | |
| 15 LinearHistogramSample::LinearHistogramSample(const std::string& histname, | |
| 16 int sample, int max): | |
| 17 MetricSample(MetricSample::LINEAR_HISTOGRAM) { | |
| 18 name_ = histname; | |
| 19 sample_ = sample; | |
| 20 max_ = max; | |
| 21 } | |
| 22 | |
| 23 std::string LinearHistogramSample::name() { | |
| 24 return name_; | |
| 25 } | |
| 26 | |
| 27 int LinearHistogramSample::sample() { | |
| 28 return sample_; | |
| 29 } | |
| 30 | |
| 31 int LinearHistogramSample::max() { | |
| 32 return max_; | |
| 33 } | |
| 34 | |
| 35 LinearHistogramSample* LinearHistogramSample::ReadLinearHistogram( | |
| 36 const std::string& hist_repr) { | |
| 37 int sample, max; | |
| 38 char name[128]; | |
| 39 sscanf(hist_repr.c_str(), "%127s %d %d", name, &sample, &max); | |
|
achaulk
2014/04/07 22:16:00
Need to check return. Might want to note that spac
| |
| 40 return new LinearHistogramSample(name, sample, max); | |
| 41 } | |
| 42 | |
| 43 LinearHistogramSample::~LinearHistogramSample() {} | |
| 44 | |
| 45 int LinearHistogramSample::Write(int buffer_size, char* buffer) { | |
| 46 return ChromeOSMetrics::FormatSample(buffer_size, buffer, | |
| 47 "linearhistogram%c%s %d %d", '\0', name_.c_str(), | |
|
achaulk
2014/04/07 22:16:00
Why not inline \0? Also indentation
bsimonnet
2014/04/08 23:00:09
the compiler complains when I embed the \0 in a fo
| |
| 48 sample_, max_); | |
| 49 } | |
| 50 } // namespace base | |
| OLD | NEW |