Chromium Code Reviews| 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_LINEARHISTOGRAM_SAMPLE_H_ | |
| 6 #define COMPONENTS_METRICS_CHROMEOS_LINEARHISTOGRAM_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 linear histogram sample (called Enum too). | |
|
Luigi Semenzato
2014/05/08 17:19:37
Is this really correct? It is possible that the i
bsimonnet
2014/05/12 22:45:37
I remove that comment. The README recommends not t
| |
| 17 // This class is meant to be used to serialize and deserialize samples to send | |
| 18 // them from ChromeOS to Chrome. | |
| 19 class LinearHistogramSample : public MetricSample { | |
| 20 public: | |
| 21 LinearHistogramSample(const std::string& name, int sample, int max); | |
| 22 virtual ~LinearHistogramSample(); | |
| 23 | |
| 24 int sample() const { return sample_; } | |
| 25 int max() const { return max_; } | |
| 26 | |
| 27 // Return the serialized version of the sample in the format: | |
| 28 // linearhistogram\0|name_| |sample_| |max_|\0 | |
| 29 virtual std::string ToString() const OVERRIDE; | |
| 30 | |
| 31 // Deserialize a sample passed as a string. | |
| 32 // Returns a LinearHistogram if the deserialization is successful. | |
| 33 // Returns NULL if the deserialization fails. | |
| 34 // The serialized format is a list of |name|, |sample|, |max| | |
| 35 // separated by space. | |
| 36 static scoped_ptr<LinearHistogramSample> ReadLinearHistogram( | |
| 37 const std::string& serialized_histogram); | |
| 38 | |
| 39 private: | |
| 40 const int sample_; | |
| 41 const int max_; | |
| 42 | |
| 43 DISALLOW_COPY_AND_ASSIGN(LinearHistogramSample); | |
| 44 }; | |
| 45 | |
| 46 } // namespace metrics | |
| 47 | |
| 48 #endif // COMPONENTS_METRICS_CHROMEOS_LINEARHISTOGRAM_SAMPLE_H_ | |
| OLD | NEW |