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

Side by Side Diff: components/metrics/export/linearhistogram_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_LINEARHISTOGRAM_SAMPLE_H_
6 #define COMPONENTS_METRICS_EXPORT_LINEARHISTOGRAM_SAMPLE_H_
7
8 #include <string>
9
10 #include "base/base_export.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/metrics/export/metric_sample.h"
14
15 namespace metrics {
16
17 // Represent a linear histogram sample (called Enum too).
18 // This class is meant to be used to serialize and deserialize samples to send
19 // them from ChromeOS to Chrome.
20 class BASE_EXPORT LinearHistogramSample : public MetricSample {
21 public:
22 LinearHistogramSample(const std::string& name, int sample, int max);
23 virtual ~LinearHistogramSample();
24
25 int sample() const { return sample_; }
26 int max() const { return max_; }
27
28 // Return the serialized version of the sample in the format:
29 // linearhistogram\0|name_| |sample_| |max_|\0
30 virtual std::string ToString() const OVERRIDE;
31
32 // Deserialize a sample passed as a string.
33 // Returns a LinearHistogram if the deserialization is successful.
34 // Returns NULL if the deserialization fails.
35 static scoped_ptr<LinearHistogramSample> ReadLinearHistogram(
36 const std::string& serialized_histogram);
37
38 private:
39 const int sample_, max_;
Alexei Svitkine (slow) 2014/05/01 15:57:09 Nit: 1 per line.
bsimonnet 2014/05/01 20:34:21 Done.
40
41 DISALLOW_COPY_AND_ASSIGN(LinearHistogramSample);
42 };
43
44 } // namespace metrics
45
46 #endif // COMPONENTS_METRICS_EXPORT_LINEARHISTOGRAM_SAMPLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698