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

Side by Side Diff: components/metrics/persisted_logs.h

Issue 2610653003: Remove old-format PersistedLogs support (Closed)
Patch Set: Remove old-format PersistedLogs support Created 3 years, 11 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
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | components/metrics/persisted_logs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_METRICS_PERSISTED_LOGS_H_ 5 #ifndef COMPONENTS_METRICS_PERSISTED_LOGS_H_
6 #define COMPONENTS_METRICS_PERSISTED_LOGS_H_ 6 #define COMPONENTS_METRICS_PERSISTED_LOGS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // is longer than the lifetime of PersistedLogs. 48 // is longer than the lifetime of PersistedLogs.
49 // 49 //
50 // When saving logs to disk, stores either the first |min_log_count| logs, or 50 // When saving logs to disk, stores either the first |min_log_count| logs, or
51 // at least |min_log_bytes| bytes of logs, whichever is greater. 51 // at least |min_log_bytes| bytes of logs, whichever is greater.
52 // 52 //
53 // If the optional |max_log_size| parameter is non-zero, all logs larger than 53 // If the optional |max_log_size| parameter is non-zero, all logs larger than
54 // that limit will be skipped when writing to disk. 54 // that limit will be skipped when writing to disk.
55 PersistedLogs(std::unique_ptr<PersistedLogsMetrics> metrics, 55 PersistedLogs(std::unique_ptr<PersistedLogsMetrics> metrics,
56 PrefService* local_state, 56 PrefService* local_state,
57 const char* pref_name, 57 const char* pref_name,
58 const char* outdated_pref_name,
59 size_t min_log_count, 58 size_t min_log_count,
60 size_t min_log_bytes, 59 size_t min_log_bytes,
61 size_t max_log_size); 60 size_t max_log_size);
62 ~PersistedLogs(); 61 ~PersistedLogs();
63 62
64 // Write list to storage. 63 // Write list to storage.
65 void SerializeLogs() const; 64 void SerializeLogs() const;
66 65
67 // Reads the list from the preference. 66 // Reads the list from the preference.
68 LogReadStatus DeserializeLogs(); 67 LogReadStatus DeserializeLogs();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // True if there are no stored logs. 103 // True if there are no stored logs.
105 bool empty() const { return list_.empty(); } 104 bool empty() const { return list_.empty(); }
106 105
107 private: 106 private:
108 // Writes the list to the ListValue. 107 // Writes the list to the ListValue.
109 void WriteLogsToPrefList(base::ListValue* list) const; 108 void WriteLogsToPrefList(base::ListValue* list) const;
110 109
111 // Reads the list from the ListValue. 110 // Reads the list from the ListValue.
112 LogReadStatus ReadLogsFromPrefList(const base::ListValue& list); 111 LogReadStatus ReadLogsFromPrefList(const base::ListValue& list);
113 112
114 // Reads the list from the ListValue in the old Log-hash pair format.
115 LogReadStatus ReadLogsFromOldFormatPrefList(const base::ListValue& list);
116
117 // An object for recording UMA metrics. 113 // An object for recording UMA metrics.
118 std::unique_ptr<PersistedLogsMetrics> metrics_; 114 std::unique_ptr<PersistedLogsMetrics> metrics_;
119 115
120 // A weak pointer to the PrefService object to read and write the preference 116 // A weak pointer to the PrefService object to read and write the preference
121 // from. Calling code should ensure this object continues to exist for the 117 // from. Calling code should ensure this object continues to exist for the
122 // lifetime of the PersistedLogs object. 118 // lifetime of the PersistedLogs object.
123 PrefService* local_state_; 119 PrefService* local_state_;
124 120
125 // The name of the preference to serialize logs to/from. 121 // The name of the preference to serialize logs to/from.
126 const char* pref_name_; 122 const char* pref_name_;
127 123
128 // The name of the preference to serialize logs to/from which may contain log
129 // in the old formatting.
130 const char* outdated_pref_name_;
131
132 // We will keep at least this |min_log_count_| logs or |min_log_bytes_| bytes 124 // We will keep at least this |min_log_count_| logs or |min_log_bytes_| bytes
133 // of logs, whichever is greater, when writing to disk. These apply after 125 // of logs, whichever is greater, when writing to disk. These apply after
134 // skipping logs greater than |max_log_size_|. 126 // skipping logs greater than |max_log_size_|.
135 const size_t min_log_count_; 127 const size_t min_log_count_;
136 const size_t min_log_bytes_; 128 const size_t min_log_bytes_;
137 129
138 // Logs greater than this size will not be written to disk. 130 // Logs greater than this size will not be written to disk.
139 const size_t max_log_size_; 131 const size_t max_log_size_;
140 132
141 struct LogInfo { 133 struct LogInfo {
(...skipping 20 matching lines...) Expand all
162 // The index and type of the log staged for upload. If nothing has been 154 // The index and type of the log staged for upload. If nothing has been
163 // staged, the index will be -1. 155 // staged, the index will be -1.
164 int staged_log_index_; 156 int staged_log_index_;
165 157
166 DISALLOW_COPY_AND_ASSIGN(PersistedLogs); 158 DISALLOW_COPY_AND_ASSIGN(PersistedLogs);
167 }; 159 };
168 160
169 } // namespace metrics 161 } // namespace metrics
170 162
171 #endif // COMPONENTS_METRICS_PERSISTED_LOGS_H_ 163 #endif // COMPONENTS_METRICS_PERSISTED_LOGS_H_
OLDNEW
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | components/metrics/persisted_logs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698