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_METRIC_SAMPLE_CHROMEOS_H_ | |
| 6 #define COMPONENTS_METRICS_METRIC_SAMPLE_CHROMEOS_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 }; | |
| 29 explicit MetricSample(SampleType type, const std::string& metric_name); | |
|
Ben Chan
2014/04/18 20:27:08
explicit is not needed when there are two or more
| |
| 30 virtual ~MetricSample(); | |
| 31 | |
| 32 // Returns 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; | |
| 37 SampleType type() const { return type_; } | |
| 38 std::string name() const { return name_; } | |
|
Ben Chan
2014/04/18 20:27:08
why not "const std::string& name() const"
| |
| 39 | |
| 40 // Returns 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_METRIC_SAMPLE_CHROMEOS_H_ | |
| OLD | NEW |