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..0d12bfda6c6fa6691bb70fdf43b976ca11c73c3a |
--- /dev/null |
+++ b/components/metrics/export/metric_sample.h |
@@ -0,0 +1,60 @@ |
+// 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 |
+ }; |
Alexei Svitkine (slow)
2014/04/30 15:25:24
Nit: Add a blank line after this.
bsimonnet
2014/04/30 20:28:40
Done.
|
+ 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; |
Alexei Svitkine (slow)
2014/04/30 15:25:24
Add a blank line after this.
bsimonnet
2014/04/30 20:28:40
Done.
|
+ 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_ |