Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/metrics/metrics_log_serializer.h

Issue 26646003: MetricsService: Send a hash of the UMA log in a header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 #include <vector>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
10 #include "chrome/common/metrics/metrics_log_manager.h" 12 #include "chrome/common/metrics/metrics_log_manager.h"
11 13
12 namespace base { 14 namespace base {
13 class ListValue; 15 class ListValue;
14 } 16 }
15 17
16 // Serializer for persisting metrics logs to prefs. 18 // Serializer for persisting metrics logs to prefs.
17 class MetricsLogSerializer : public MetricsLogManager::LogSerializer { 19 class MetricsLogSerializer : public MetricsLogManager::LogSerializer {
(...skipping 13 matching lines...) Expand all
31 DECODE_FAIL, // Failed to decode log. 33 DECODE_FAIL, // Failed to decode log.
32 DEPRECATED_XML_PROTO_MISMATCH, // The XML and protobuf logs have 34 DEPRECATED_XML_PROTO_MISMATCH, // The XML and protobuf logs have
33 // inconsistent data. 35 // inconsistent data.
34 END_RECALL_STATUS // Number of bins to use to create the histogram. 36 END_RECALL_STATUS // Number of bins to use to create the histogram.
35 }; 37 };
36 38
37 MetricsLogSerializer(); 39 MetricsLogSerializer();
38 virtual ~MetricsLogSerializer(); 40 virtual ~MetricsLogSerializer();
39 41
40 // Implementation of MetricsLogManager::LogSerializer 42 // Implementation of MetricsLogManager::LogSerializer
41 virtual void SerializeLogs(const std::vector<std::string>& logs, 43 virtual void SerializeLogs(
42 MetricsLogManager::LogType log_type) OVERRIDE; 44 const std::vector<MetricsLogManager::SerializedLog>& logs,
43 virtual void DeserializeLogs(MetricsLogManager::LogType log_type, 45 MetricsLogManager::LogType log_type) OVERRIDE;
44 std::vector<std::string>* logs) OVERRIDE; 46 virtual void DeserializeLogs(
47 MetricsLogManager::LogType log_type,
48 std::vector<MetricsLogManager::SerializedLog>* logs) OVERRIDE;
45 49
46 private: 50 private:
47 // Encodes the textual log data from |local_list| and writes it to the given 51 // Encodes the textual log data from |local_list| and writes it to the given
48 // pref list, along with list size and checksum. Logs will be stored starting 52 // pref list, along with list size and checksum. Logs will be stored starting
49 // with the most recent, and working backward until at least 53 // with the most recent, and working backward until at least
50 // |list_length_limit| logs and |byte_limit| bytes of logs have been 54 // |list_length_limit| logs and |byte_limit| bytes of logs have been
51 // stored. At least one of those two arguments must be non-zero. 55 // stored. At least one of those two arguments must be non-zero.
52 static void WriteLogsToPrefList(const std::vector<std::string>& local_list, 56 static void WriteLogsToPrefList(
53 size_t list_length_limit, 57 const std::vector<MetricsLogManager::SerializedLog>& local_list,
54 size_t byte_limit, 58 size_t list_length_limit,
55 base::ListValue* list); 59 size_t byte_limit,
60 base::ListValue* list);
56 61
57 // Decodes and verifies the textual log data from |list|, populating 62 // Decodes and verifies the textual log data from |list|, populating
58 // |local_list| and returning a status code. 63 // |local_list| and returning a status code.
59 static LogReadStatus ReadLogsFromPrefList( 64 static LogReadStatus ReadLogsFromPrefList(
60 const base::ListValue& list, 65 const base::ListValue& list,
61 std::vector<std::string>* local_list); 66 std::vector<MetricsLogManager::SerializedLog>* local_list);
62 67
63 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList); 68 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, EmptyLogList);
64 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList); 69 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SingleElementLogList);
65 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButTinyLogList); 70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButTinyLogList);
66 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButSmallLogList); 71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongButSmallLogList);
67 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, ShortButLargeLogList); 72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, ShortButLargeLogList);
68 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongAndLargeLogList); 73 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, LongAndLargeLogList);
69 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize); 74 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, SmallRecoveredListSize);
70 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList); 75 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, RemoveSizeFromLogList);
71 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList); 76 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptSizeOfLogList);
72 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList); 77 FRIEND_TEST_ALL_PREFIXES(MetricsLogSerializerTest, CorruptChecksumOfLogList);
73 78
74 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer); 79 DISALLOW_COPY_AND_ASSIGN(MetricsLogSerializer);
75 }; 80 };
76 81
77 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_ 82 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_SERIALIZER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_log_serializer.cc » ('j') | chrome/common/metrics/metrics_log_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698