Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/base_export.h" | |
| 11 #include "base/memory/scoped_vector.h" | |
| 12 | |
| 13 namespace metrics { | |
| 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 BASE_EXPORT MetricSample* ReadSample(const std::string& sample); | |
|
Alexei Svitkine (slow)
2014/04/30 15:25:24
These shouldn't use BASE_EXPORT anymore.
bsimonnet
2014/04/30 20:28:40
Done.
| |
| 24 | |
| 25 // Read all samples from a file and truncate the file when done. | |
| 26 BASE_EXPORT void ReadAndTruncateMetricsFromFile( | |
| 27 const std::string& filename, | |
| 28 ScopedVector<MetricSample>* metrics); | |
| 29 | |
| 30 // Serialize a metric and write it to filename. | |
| 31 // The format for the message wrote is: | |
| 32 // message_size, serialized_message | |
| 33 // where | |
| 34 // * message_size is the total length of the message (message_size + | |
| 35 // serialized_message) on 4 bytes | |
| 36 // * serialized_message is the serialized version of sample (using ToString) | |
| 37 BASE_EXPORT bool WriteMetricToFile(const MetricSample& sample, | |
| 38 const std::string& filename); | |
| 39 | |
| 40 // Maximum length of a serialized message | |
| 41 const int kMessageMaxLength = 1024; | |
| 42 | |
| 43 } // namespace MetricsUtils | |
| 44 } // namespace metrics | |
| 45 | |
| 46 #endif // COMPONENTS_METRICS_EXPORT_METRICS_UTILS_H_ | |
| OLD | NEW |