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

Side by Side Diff: components/metrics/metric_sample_chromeos.h

Issue 227873002: Create a histogram serialization mechanism in components/metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving to components instead of base. Adding sanity checks. Fixing lint Created 6 years, 8 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_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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698