OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 20 matching lines...) Expand all Loading... |
31 // GetAsString(). | 31 // GetAsString(). |
32 DECODE_FAIL, // Failed to decode log. | 32 DECODE_FAIL, // Failed to decode log. |
33 END_RECALL_STATUS // Number of bins to use to create the histogram. | 33 END_RECALL_STATUS // Number of bins to use to create the histogram. |
34 }; | 34 }; |
35 | 35 |
36 MetricsLogSerializer(); | 36 MetricsLogSerializer(); |
37 virtual ~MetricsLogSerializer(); | 37 virtual ~MetricsLogSerializer(); |
38 | 38 |
39 // Implementation of MetricsLogManager::LogSerializer | 39 // Implementation of MetricsLogManager::LogSerializer |
40 virtual void SerializeLogs(const std::vector<std::string>& logs, | 40 virtual void SerializeLogs(const std::vector<std::string>& logs, |
41 MetricsLogManager::LogType log_type); | 41 MetricsLogManager::LogType log_type) OVERRIDE; |
42 virtual void DeserializeLogs(MetricsLogManager::LogType log_type, | 42 virtual void DeserializeLogs(MetricsLogManager::LogType log_type, |
43 std::vector<std::string>* logs); | 43 std::vector<std::string>* logs) OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 // Encodes the textual log data from |local_list| and writes it to the given | 46 // Encodes the textual log data from |local_list| and writes it to the given |
47 // pref list, along with list size and checksum. | 47 // pref list, along with list size and checksum. |
48 static void WriteLogsToPrefList(const std::vector<std::string>& local_list, | 48 static void WriteLogsToPrefList(const std::vector<std::string>& local_list, |
49 const size_t kMaxLocalListSize, | 49 const size_t kMaxLocalListSize, |
50 base::ListValue* list); | 50 base::ListValue* list); |
51 | 51 |
52 // Decodes and verifies the textual log data from |list|, populating | 52 // Decodes and verifies the textual log data from |list|, populating |
53 // |local_list| and returning a status code. | 53 // |local_list| and returning a status code. |
54 static LogReadStatus ReadLogsFromPrefList( | 54 static LogReadStatus ReadLogsFromPrefList( |
55 const base::ListValue& list, | 55 const base::ListValue& list, |
56 std::vector<std::string>* local_list); | 56 std::vector<std::string>* local_list); |
57 | 57 |
58 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); | 58 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); |
59 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); | 59 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); |
60 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitLogList); | 60 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, OverLimitLogList); |
61 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); | 61 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); |
62 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); | 62 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); |
63 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); | 63 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); |
64 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); | 64 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); | 66 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); |
67 }; | 67 }; |
68 | 68 |
69 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ | 69 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ |
OLD | NEW |