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_EXPORT_METRIC_SAMPLE_H_ | |
6 #define COMPONENTS_METRICS_EXPORT_METRIC_SAMPLE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/base_export.h" | |
11 #include "base/macros.h" | |
12 | |
13 namespace metrics { | |
14 | |
15 // Abstract class representing a metric sample (single measures). | |
16 // This class and its subclasses are used by libmetrics (ChromeOS) to serialize | |
17 // and deserialize measurements to send them to a metrics sending service. | |
18 // It is meant to be a simple container with serialization functions. | |
19 class BASE_EXPORT MetricSample { | |
20 public: | |
21 // Types of metric sample used. | |
22 enum SampleType { | |
23 CRASH, | |
24 HISTOGRAM, | |
25 LINEAR_HISTOGRAM, | |
26 SPARSE_HISTOGRAM, | |
27 USER_ACTION | |
28 }; | |
Alexei Svitkine (slow)
2014/04/30 15:25:24
Nit: Add a blank line after this.
bsimonnet
2014/04/30 20:28:40
Done.
| |
29 MetricSample(SampleType sample_type, const std::string& metric_name); | |
30 virtual ~MetricSample(); | |
31 | |
32 // Return true if the sample is valid (can be serialized without ambiguity). | |
33 // | |
34 // This function should be used to filter bad samples before serializing them | |
35 // to disk. | |
36 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.
| |
37 SampleType type() const { return type_; } | |
38 const std::string& name() const { return name_; } | |
39 | |
40 // Return a serialized version of the sample. | |
41 // | |
42 // This function should be overriden by subclasses to define their own | |
43 // serialization format. | |
44 // The general serialized message is: | |
45 // |sampletype|,\0,<sample type specific serialized data>,\0 | |
46 // | |
47 // The format is akward but it is implemented independently in both chrome os | |
48 // and chrome. We will keep it for now. | |
49 virtual std::string ToString() const; | |
50 | |
51 private: | |
52 const SampleType type_; | |
53 const std::string name_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(MetricSample); | |
56 }; | |
57 | |
58 } // namespace metrics | |
59 | |
60 #endif // COMPONENTS_METRICS_EXPORT_METRIC_SAMPLE_H_ | |
OLD | NEW |