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

Side by Side Diff: components/metrics/serialization/serialization_utils.h

Issue 2691803002: Remove ScopedVector in //component/metrics (Closed)
Patch Set: code rebase Created 3 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_ 5 #ifndef COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
6 #define COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_ 6 #define COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10 #include <vector>
11 #include "base/memory/scoped_vector.h"
12 11
13 namespace metrics { 12 namespace metrics {
14 13
15 class MetricSample; 14 class MetricSample;
16 15
17 // Metrics helpers to serialize and deserialize metrics collected by 16 // Metrics helpers to serialize and deserialize metrics collected by
18 // ChromeOS. 17 // ChromeOS.
19 namespace SerializationUtils { 18 namespace SerializationUtils {
20 19
21 // Deserializes a sample passed as a string and return a sample. 20 // Deserializes a sample passed as a string and return a sample.
22 // The return value will either be a scoped_ptr to a Metric sample (if the 21 // The return value will either be a scoped_ptr to a Metric sample (if the
23 // deserialization was successful) or a NULL scoped_ptr. 22 // deserialization was successful) or a NULL scoped_ptr.
24 std::unique_ptr<MetricSample> ParseSample(const std::string& sample); 23 std::unique_ptr<MetricSample> ParseSample(const std::string& sample);
25 24
26 // Reads all samples from a file and truncate the file when done. 25 // Reads all samples from a file and truncate the file when done.
27 void ReadAndTruncateMetricsFromFile(const std::string& filename, 26 void ReadAndTruncateMetricsFromFile(
28 ScopedVector<MetricSample>* metrics); 27 const std::string& filename,
28 std::vector<std::unique_ptr<MetricSample>>* metrics);
29 29
30 // Serializes a sample and write it to filename. 30 // Serializes a sample and write it to filename.
31 // The format for the message is: 31 // The format for the message is:
32 // message_size, serialized_message 32 // message_size, serialized_message
33 // where 33 // where
34 // * message_size is the total length of the message (message_size + 34 // * message_size is the total length of the message (message_size +
35 // serialized_message) on 4 bytes 35 // serialized_message) on 4 bytes
36 // * serialized_message is the serialized version of sample (using ToString) 36 // * serialized_message is the serialized version of sample (using ToString)
37 // 37 //
38 // NB: the file will never leave the device so message_size will be written 38 // NB: the file will never leave the device so message_size will be written
39 // with the architecture's endianness. 39 // with the architecture's endianness.
40 bool WriteMetricToFile(const MetricSample& sample, const std::string& filename); 40 bool WriteMetricToFile(const MetricSample& sample, const std::string& filename);
41 41
42 // Maximum length of a serialized message 42 // Maximum length of a serialized message
43 static const int kMessageMaxLength = 1024; 43 static const int kMessageMaxLength = 1024;
44 44
45 } // namespace SerializationUtils 45 } // namespace SerializationUtils
46 } // namespace metrics 46 } // namespace metrics
47 47
48 #endif // COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_ 48 #endif // COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
OLDNEW
« no previous file with comments | « components/metrics/metrics_service_unittest.cc ('k') | components/metrics/serialization/serialization_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698