| Index: components/metrics/export/metric_sample.h
|
| diff --git a/components/metrics/export/metric_sample.h b/components/metrics/export/metric_sample.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ec75c7b73c459cf2751a35c3495e30de0418d9a5
|
| --- /dev/null
|
| +++ b/components/metrics/export/metric_sample.h
|
| @@ -0,0 +1,62 @@
|
| +// 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_EXPORT_METRIC_SAMPLE_H_
|
| +#define COMPONENTS_METRICS_EXPORT_METRIC_SAMPLE_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/base_export.h"
|
| +#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 BASE_EXPORT 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).
|
| + //
|
| + // This function should be used to filter bad samples before serializing them
|
| + // to disk.
|
| + 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
|
| + // 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_EXPORT_METRIC_SAMPLE_H_
|
|
|