| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ |
| 6 #define CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ | 6 #define CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const std::vector<MetricsLogManager::SerializedLog>& logs, | 42 const std::vector<MetricsLogManager::SerializedLog>& logs, |
| 43 MetricsLogManager::LogType log_type) OVERRIDE; | 43 MetricsLogManager::LogType log_type) OVERRIDE; |
| 44 virtual void DeserializeLogs( | 44 virtual void DeserializeLogs( |
| 45 MetricsLogManager::LogType log_type, | 45 MetricsLogManager::LogType log_type, |
| 46 std::vector<MetricsLogManager::SerializedLog>* logs) OVERRIDE; | 46 std::vector<MetricsLogManager::SerializedLog>* logs) OVERRIDE; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Encodes the textual log data from |local_list| and writes it to the given | 49 // Encodes the textual log data from |local_list| and writes it to the given |
| 50 // pref list, along with list size and checksum. If |is_xml| is true, writes | 50 // pref list, along with list size and checksum. If |is_xml| is true, writes |
| 51 // the XML data from |local_list|; otherwise writes the protobuf data. | 51 // the XML data from |local_list|; otherwise writes the protobuf data. |
| 52 // At most |max_list_length| logs will be stored, unless that doesn't reach |
| 53 // |min_bytes| bytes of logs, in which case at least |min_bytes| will be |
| 54 // stored. At least one of those two arguments must be non-zero. |
| 52 static void WriteLogsToPrefList( | 55 static void WriteLogsToPrefList( |
| 53 const std::vector<MetricsLogManager::SerializedLog>& local_list, | 56 const std::vector<MetricsLogManager::SerializedLog>& local_list, |
| 54 bool is_xml, | 57 bool is_xml, |
| 55 size_t max_list_size, | 58 size_t max_list_length, |
| 59 size_t min_bytes, |
| 56 base::ListValue* list); | 60 base::ListValue* list); |
| 57 | 61 |
| 58 // Decodes and verifies the textual log data from |list|, populating | 62 // Decodes and verifies the textual log data from |list|, populating |
| 59 // |local_list| and returning a status code. If |is_xml| is true, populates | 63 // |local_list| and returning a status code. If |is_xml| is true, populates |
| 60 // the XML data in |local_list|; otherwise populates the protobuf data. | 64 // the XML data in |local_list|; otherwise populates the protobuf data. |
| 61 static LogReadStatus ReadLogsFromPrefList( | 65 static LogReadStatus ReadLogsFromPrefList( |
| 62 const base::ListValue& list, | 66 const base::ListValue& list, |
| 63 bool is_xml, | 67 bool is_xml, |
| 64 std::vector<MetricsLogManager::SerializedLog>* local_list); | 68 std::vector<MetricsLogManager::SerializedLog>* local_list); |
| 65 | 69 |
| 66 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); | 70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); |
| 67 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); | 71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); |
| 68 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitLogList); | 72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButTinyLogList); |
| 73 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButSmallLogList); |
| 74 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, ShortButLargeLogList); |
| 75 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongAndLargeLogList); |
| 69 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); | 76 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); |
| 70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); | 77 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); |
| 71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); | 78 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); |
| 72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); | 79 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); |
| 73 | 80 |
| 74 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); | 81 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); |
| 75 }; | 82 }; |
| 76 | 83 |
| 77 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ | 84 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ |
| OLD | NEW |