Chromium Code Reviews| 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_CHROMEOS_METRIC_SAMPLE_H_ | |
| 6 #define COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 namespace metrics { | |
| 13 | |
| 14 // Abstract class representing a metric sample (single measures). | |
| 15 // This class and its subclasses are used by libmetrics (ChromeOS) to serialize | |
| 16 // and deserialize measurements to send them to a metrics sending service. | |
| 17 // It is meant to be a simple container with serialization functions. | |
| 18 class MetricSample { | |
| 19 public: | |
| 20 // Types of metric sample used. | |
| 21 enum SampleType { | |
| 22 CRASH, | |
| 23 HISTOGRAM, | |
| 24 LINEAR_HISTOGRAM, | |
| 25 SPARSE_HISTOGRAM, | |
| 26 USER_ACTION | |
| 27 }; | |
| 28 | |
| 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). | |
|
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
| |
| 33 // | |
| 34 // This function should be used to filter bad samples before serializing them | |
| 35 // to disk. | |
|
Luigi Semenzato
2014/05/08 17:19:37
Maybe "to disk" is assuming too much here?
| |
| 36 virtual bool IsValid() const; | |
| 37 | |
| 38 SampleType type() const { return type_; } | |
| 39 const std::string& name() const { return name_; } | |
| 40 | |
| 41 // Return a serialized version of the sample. | |
| 42 // | |
| 43 // This function should be overriden by subclasses to define their own | |
| 44 // serialization format. | |
| 45 // The general serialized message is: | |
| 46 // |sampletype|,\0,<sample type specific serialized data>,\0 | |
| 47 // | |
| 48 // 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
| |
| 49 // and chrome. We will keep it for now. | |
| 50 virtual std::string ToString() const; | |
| 51 | |
| 52 private: | |
| 53 const SampleType type_; | |
| 54 const std::string name_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(MetricSample); | |
| 57 }; | |
| 58 | |
| 59 } // namespace metrics | |
| 60 | |
| 61 #endif // COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ | |
| OLD | NEW |