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_METRICS_UTILS_CHROMEOS_H_ | |
| 6 #define COMPONENTS_METRICS_METRICS_UTILS_CHROMEOS_H_ | |
| 7 | |
| 8 #include "base/base_export.h" | |
| 9 #include "base/memory/scoped_vector.h" | |
| 10 | |
| 11 namespace metrics { | |
| 12 class MetricSample; | |
| 13 | |
| 14 // Contains metrics helpers to serialize and deserialize metrics collected by | |
| 15 // chrome os. | |
|
Ben Chan
2014/04/18 20:27:08
nit: [ocd] inconsistency: chrome os vs ChromeOS in
| |
| 16 namespace MetricsUtils { | |
| 17 | |
| 18 // Deserialize a sample passed as a string and return a sample. | |
| 19 // The return value will either be a subclass of MetricSample or NULL if the | |
| 20 // sample could not be parsed. | |
| 21 BASE_EXPORT MetricSample* ReadSample(const std::string& sample); | |
| 22 | |
| 23 // Read all samples from a file and truncate the file when done. | |
| 24 BASE_EXPORT void ReadAndTruncateMetricsFromFile( | |
| 25 const std::string& filename, | |
| 26 ScopedVector<MetricSample>* metrics); | |
| 27 | |
| 28 // Serialize a metric and write it to filename. | |
| 29 // The format for the message wrote is: | |
| 30 // message_size, serialized_message | |
| 31 // where | |
| 32 // * message_size is the total length of the message (message_size + | |
| 33 // serialized_message) on 4 bytes | |
| 34 // * serialized_message is the serialized version of sample (using ToString) | |
| 35 BASE_EXPORT bool WriteMetricToFile(const MetricSample& sample, | |
| 36 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_METRICS_UTILS_CHROMEOS_H_ | |
| OLD | NEW |