| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 static void WriteLogsToPrefList( | 52 static void WriteLogsToPrefList( |
| 53 const std::vector<MetricsLogManager::SerializedLog>& local_list, | 53 const std::vector<MetricsLogManager::SerializedLog>& local_list, |
| 54 bool is_xml, | 54 bool is_xml, |
| 55 size_t max_list_size, | 55 size_t max_bytes, |
| 56 base::ListValue* list); | 56 base::ListValue* list); |
| 57 | 57 |
| 58 // Decodes and verifies the textual log data from |list|, populating | 58 // Decodes and verifies the textual log data from |list|, populating |
| 59 // |local_list| and returning a status code. If |is_xml| is true, populates | 59 // |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. | 60 // the XML data in |local_list|; otherwise populates the protobuf data. |
| 61 static LogReadStatus ReadLogsFromPrefList( | 61 static LogReadStatus ReadLogsFromPrefList( |
| 62 const base::ListValue& list, | 62 const base::ListValue& list, |
| 63 bool is_xml, | 63 bool is_xml, |
| 64 std::vector<MetricsLogManager::SerializedLog>* local_list); | 64 std::vector<MetricsLogManager::SerializedLog>* local_list); |
| 65 | 65 |
| 66 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); | 66 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); |
| 67 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); | 67 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); |
| 68 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitLogList); | 68 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitLogList); |
| 69 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitIndividualLog); |
| 70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitAllLogs); |
| 69 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); | 71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); |
| 70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); | 72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); |
| 71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); | 73 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); |
| 72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); | 74 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); |
| 73 | 75 |
| 74 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); | 76 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ | 79 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ |
| OLD | NEW |