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_LINEARHISTOGRAM_SAMPLE_H_ | |
6 #define COMPONENTS_METRICS_EXPORT_LINEARHISTOGRAM_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 linear histogram sample (called Enum too). | |
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 LinearHistogramSample : public MetricSample { | |
21 public: | |
22 LinearHistogramSample(const std::string& name, int sample, int max); | |
23 virtual ~LinearHistogramSample(); | |
24 | |
25 int sample() const { return sample_; } | |
26 int max() const { return max_; } | |
27 | |
28 // Return the serialized version of the sample in the format: | |
29 // linearhistogram\0|name_| |sample_| |max_|\0 | |
30 virtual std::string ToString() const OVERRIDE; | |
31 | |
32 // Deserialize a sample passed as a string. | |
33 // Returns a LinearHistogram if the deserialization is successful. | |
34 // Returns NULL if the deserialization fails. | |
35 static scoped_ptr<LinearHistogramSample> ReadLinearHistogram( | |
36 const std::string& serialized_histogram); | |
37 | |
38 private: | |
39 const int sample_, max_; | |
Alexei Svitkine (slow)
2014/05/01 15:57:09
Nit: 1 per line.
bsimonnet
2014/05/01 20:34:21
Done.
| |
40 | |
41 DISALLOW_COPY_AND_ASSIGN(LinearHistogramSample); | |
42 }; | |
43 | |
44 } // namespace metrics | |
45 | |
46 #endif // COMPONENTS_METRICS_EXPORT_LINEARHISTOGRAM_SAMPLE_H_ | |
OLD | NEW |