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 <stdio.h> |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/metrics/chromeos_metrics.h" |
| 11 #include "base/metrics/linearhistogram_sample.h" |
| 12 #include "base/metrics/metric_sample.h" |
| 13 #include "base/strings/stringprintf.h" |
| 14 |
| 15 using std::string; |
| 16 |
| 17 namespace base { |
| 18 LinearHistogramSample::LinearHistogramSample(const std::string& histname, |
| 19 int sample, |
| 20 int max) |
| 21 : MetricSample(MetricSample::LINEAR_HISTOGRAM) { |
| 22 name_ = histname; |
| 23 sample_ = sample; |
| 24 max_ = max; |
| 25 } |
| 26 |
| 27 int LinearHistogramSample::sample() { return sample_; } |
| 28 |
| 29 int LinearHistogramSample::max() { return max_; } |
| 30 |
| 31 LinearHistogramSample* LinearHistogramSample::ReadLinearHistogram( |
| 32 const std::string& hist_repr) { |
| 33 int sample, max; |
| 34 char name[128]; |
| 35 int result = sscanf(hist_repr.c_str(), "%127s %d %d", name, &sample, &max); |
| 36 if (result != 3) { |
| 37 return NULL; |
| 38 } |
| 39 return new LinearHistogramSample(name, sample, max); |
| 40 } |
| 41 |
| 42 LinearHistogramSample::~LinearHistogramSample() {} |
| 43 |
| 44 string LinearHistogramSample::toString() const { |
| 45 return StringPrintf( |
| 46 "linearhistogram%c%s %d %d%c", '\0', name_.c_str(), sample_, max_, '\0'); |
| 47 } |
| 48 } // namespace base |
OLD | NEW |