Chromium Code Reviews| Index: components/metrics/chromeos/linearhistogram_sample.h |
| diff --git a/components/metrics/chromeos/linearhistogram_sample.h b/components/metrics/chromeos/linearhistogram_sample.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7bc8a3e944f06aff87a63f41d1bcbd4780763024 |
| --- /dev/null |
| +++ b/components/metrics/chromeos/linearhistogram_sample.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_METRICS_CHROMEOS_LINEARHISTOGRAM_SAMPLE_H_ |
| +#define COMPONENTS_METRICS_CHROMEOS_LINEARHISTOGRAM_SAMPLE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "components/metrics/chromeos/metric_sample.h" |
| + |
| +namespace metrics { |
| + |
| +// 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
|
| +// This class is meant to be used to serialize and deserialize samples to send |
| +// them from ChromeOS to Chrome. |
| +class LinearHistogramSample : public MetricSample { |
| + public: |
| + LinearHistogramSample(const std::string& name, int sample, int max); |
| + virtual ~LinearHistogramSample(); |
| + |
| + int sample() const { return sample_; } |
| + int max() const { return max_; } |
| + |
| + // Return the serialized version of the sample in the format: |
| + // linearhistogram\0|name_| |sample_| |max_|\0 |
| + virtual std::string ToString() const OVERRIDE; |
| + |
| + // Deserialize a sample passed as a string. |
| + // Returns a LinearHistogram if the deserialization is successful. |
| + // Returns NULL if the deserialization fails. |
| + // The serialized format is a list of |name|, |sample|, |max| |
| + // separated by space. |
| + static scoped_ptr<LinearHistogramSample> ReadLinearHistogram( |
| + const std::string& serialized_histogram); |
| + |
| + private: |
| + const int sample_; |
| + const int max_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(LinearHistogramSample); |
| +}; |
| + |
| +} // namespace metrics |
| + |
| +#endif // COMPONENTS_METRICS_CHROMEOS_LINEARHISTOGRAM_SAMPLE_H_ |