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

Side by Side Diff: components/metrics/export/metrics_utils.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_METRICS_UTILS_H_
6 #define COMPONENTS_METRICS_EXPORT_METRICS_UTILS_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12
13 namespace metrics {
Alexei Svitkine (slow) 2014/05/01 15:57:09 Nit: Add empty line after this.
bsimonnet 2014/05/01 20:34:21 Done.
14 class MetricSample;
15
16 // Metrics helpers to serialize and deserialize metrics collected by
17 // ChromeOS.
18 namespace MetricsUtils {
19
20 // Deserialize a sample passed as a string and return a sample.
21 // The return value will either be a subclass of MetricSample or NULL if the
22 // sample could not be parsed.
23 scoped_ptr<MetricSample> ReadSample(const std::string& sample);
24
25 // Read all samples from a file and truncate the file when done.
26 void ReadAndTruncateMetricsFromFile(const std::string& filename,
27 ScopedVector<MetricSample>* metrics);
28
29 // Serialize a metric and write it to filename.
30 // The format for the message wrote is:
31 // message_size, serialized_message
32 // where
33 // * message_size is the total length of the message (message_size +
34 // serialized_message) on 4 bytes
35 // * serialized_message is the serialized version of sample (using ToString)
36 bool WriteMetricToFile(const MetricSample& sample, const std::string& filename);
37
38 // Maximum length of a serialized message
39 const int kMessageMaxLength = 1024;
40
41 } // namespace MetricsUtils
42 } // namespace metrics
43
44 #endif // COMPONENTS_METRICS_EXPORT_METRICS_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698