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

Side by Side Diff: components/metrics/linearhistogram_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_LINEARHISTOGRAM_SAMPLE_CHROMEOS_H
Ben Chan 2014/04/18 20:27:08 ditto
6 #define COMPONENTS_METRICS_LINEARHISTOGRAM_SAMPLE_CHROMEOS_H
7
8 #include <string>
9
10 #include "base/base_export.h"
11 #include "base/compiler_specific.h"
12 #include "components/metrics/metric_sample_chromeos.h"
13
14 namespace metrics {
15
16 // Represents a linear histogram sample (called Enum too).
17 // This class is meant to be used to serialize and deserialize samples to send
18 // them from chrome os to chrome.
19 class BASE_EXPORT LinearHistogramSample : public MetricSample {
20 public:
21 LinearHistogramSample(const std::string& name, int sample, int max);
22 virtual ~LinearHistogramSample();
23
24 int sample() const { return sample_; }
25 int max() const { return max_; }
26
27 // Returns the serialized version of the sample in the format:
28 // linearhistogram\0|name_| |sample_| |max_|\0
29 virtual std::string ToString() const OVERRIDE;
30
31 // Deserialize a sample passed as a string.
32 // Returns a LinearHistogram if the deserialization is successful.
33 // Returns NULL if the deserialization fails.
34 static LinearHistogramSample* ReadLinearHistogram(
35 const std::string& serialized_histogram);
36
37 private:
38 const int sample_, max_;
39
40 DISALLOW_COPY_AND_ASSIGN(LinearHistogramSample);
41 };
42
43 } // namespace metrics
44
45 #endif // COMPONENTS_METRICS_LINEARHISTOGRAM_SAMPLE_CHROMEOS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698