Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: components/metrics/export/metric_sample.h

Issue 227873002: Create a histogram serialization mechanism in components/metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert to use scoped_ptr. Remove using declarations. Fixed linting. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 };
29
30 MetricSample(SampleType sample_type, const std::string& metric_name);
31 virtual ~MetricSample();
32
33 // Return true if the sample is valid (can be serialized without ambiguity).
34 //
35 // This function should be used to filter bad samples before serializing them
36 // to disk.
37 virtual bool IsValid() const;
38
39 SampleType type() const { return type_; }
40 const std::string& name() const { return name_; }
41
42 // Return a serialized version of the sample.
43 //
44 // This function should be overriden by subclasses to define their own
45 // serialization format.
46 // The general serialized message is:
47 // |sampletype|,\0,<sample type specific serialized data>,\0
48 //
49 // The format is akward but it is implemented independently in both chrome os
50 // and chrome. We will keep it for now.
51 virtual std::string ToString() const;
52
53 private:
54 const SampleType type_;
55 const std::string name_;
56
57 DISALLOW_COPY_AND_ASSIGN(MetricSample);
58 };
59
60 } // namespace metrics
61
62 #endif // COMPONENTS_METRICS_EXPORT_METRIC_SAMPLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698