OLD | NEW |
(Empty) | |
| 1 // Copyright 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 #ifndef COMPONENTS_METRICS_EXPORT_HISTOGRAM_SAMPLE_H_ |
| 6 #define COMPONENTS_METRICS_EXPORT_HISTOGRAM_SAMPLE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/base_export.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "components/metrics/export/metric_sample.h" |
| 14 |
| 15 namespace metrics { |
| 16 |
| 17 // Represent a single histogram sample. |
| 18 // This class is meant to be used to serialize and deserialize samples to send |
| 19 // them from ChromeOS to Chrome. |
| 20 class BASE_EXPORT HistogramSample : public MetricSample { |
| 21 public: |
| 22 HistogramSample(const std::string& name, |
| 23 int sample, |
| 24 int min, |
| 25 int max, |
| 26 int nbucket); |
| 27 virtual ~HistogramSample(); |
| 28 |
| 29 int sample() const { return sample_; } |
| 30 int min() const { return min_; } |
| 31 int max() const { return max_; } |
| 32 int nbucket() const { return nbucket_; } |
| 33 |
| 34 // Return the sample serialized on the format: |
| 35 // histogram\0|name_| |sample_| |min_| |max_| |nbucket_|\0 |
| 36 virtual std::string ToString() const OVERRIDE; |
| 37 |
| 38 // Deserialize a histogram passed as a string. |
| 39 // Returns a HistogramSample if the deserialization is successful, otherwise |
| 40 // returns NULL. |
| 41 static scoped_ptr<HistogramSample> ReadHistogram( |
| 42 const std::string& serialized_histogram); |
| 43 |
| 44 private: |
| 45 const int sample_; |
| 46 const int min_; |
| 47 const int max_; |
| 48 const int nbucket_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(HistogramSample); |
| 51 }; |
| 52 |
| 53 } // namespace metrics |
| 54 |
| 55 #endif // COMPONENTS_METRICS_EXPORT_HISTOGRAM_SAMPLE_H_ |
OLD | NEW |