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