Chromium Code Reviews| Index: components/metrics/chromeos/metric_sample.h |
| diff --git a/components/metrics/chromeos/metric_sample.h b/components/metrics/chromeos/metric_sample.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bbf80a928bd1b095ab57f41221d77a6eed68b20a |
| --- /dev/null |
| +++ b/components/metrics/chromeos/metric_sample.h |
| @@ -0,0 +1,61 @@ |
| +// 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_METRIC_SAMPLE_H_ |
| +#define COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| + |
| +namespace metrics { |
| + |
| +// Abstract class representing a metric sample (single measures). |
| +// This class and its subclasses are used by libmetrics (ChromeOS) to serialize |
| +// and deserialize measurements to send them to a metrics sending service. |
| +// It is meant to be a simple container with serialization functions. |
| +class MetricSample { |
| + public: |
| + // Types of metric sample used. |
| + enum SampleType { |
| + CRASH, |
| + HISTOGRAM, |
| + LINEAR_HISTOGRAM, |
| + SPARSE_HISTOGRAM, |
| + USER_ACTION |
| + }; |
| + |
| + MetricSample(SampleType sample_type, const std::string& metric_name); |
| + virtual ~MetricSample(); |
| + |
| + // Return true if the sample is valid (can be serialized without ambiguity). |
|
Luigi Semenzato
2014/05/08 17:19:37
What does this mean?
bsimonnet
2014/05/08 20:02:58
As the fields are separated by spaces, we do not w
|
| + // |
| + // This function should be used to filter bad samples before serializing them |
| + // to disk. |
|
Luigi Semenzato
2014/05/08 17:19:37
Maybe "to disk" is assuming too much here?
|
| + virtual bool IsValid() const; |
| + |
| + SampleType type() const { return type_; } |
| + const std::string& name() const { return name_; } |
| + |
| + // Return a serialized version of the sample. |
| + // |
| + // This function should be overriden by subclasses to define their own |
| + // serialization format. |
| + // The general serialized message is: |
| + // |sampletype|,\0,<sample type specific serialized data>,\0 |
| + // |
| + // The format is akward but it is implemented independently in both chrome os |
|
Luigi Semenzato
2014/05/08 17:19:37
typo: awkward
What does "implemented independentl
bsimonnet
2014/05/08 20:02:58
Two different piece of code that are not synchroni
|
| + // and chrome. We will keep it for now. |
| + virtual std::string ToString() const; |
| + |
| + private: |
| + const SampleType type_; |
| + const std::string name_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MetricSample); |
| +}; |
| + |
| +} // namespace metrics |
| + |
| +#endif // COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ |