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

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

Issue 9562007: Add a minimum byte count to metrics log serialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change limit terminology, |start| decrement logic Created 8 years, 7 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 #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
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 // Logs will be stored starting with the most recent, and working backward
53 // until at least |list_length_limit| logs and |byte_limit| bytes of logs have
54 // been 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 list_length_limit,
59 size_t byte_limit,
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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_log_serializer.cc » ('j') | chrome/browser/metrics/metrics_log_serializer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698