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

Unified Diff: components/metrics/persisted_logs.h

Issue 2358223002: Add log date to the metrics log (Closed)
Patch Set: add deprectaed comments Created 4 years, 3 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/persisted_logs.h
diff --git a/components/metrics/persisted_logs.h b/components/metrics/persisted_logs.h
index 73ad79a5b06e36a0e43aeebe06a44e5b615308a3..479924fd0fdab8fd717d6d1ad852c3d7624a04ec 100644
--- a/components/metrics/persisted_logs.h
+++ b/components/metrics/persisted_logs.h
@@ -51,6 +51,7 @@ class PersistedLogs {
// that limit will be skipped when writing to disk.
PersistedLogs(PrefService* local_state,
const char* pref_name,
+ const char* outdated_pref_name,
size_t min_log_count,
size_t min_log_bytes,
size_t max_log_size);
@@ -87,6 +88,12 @@ class PersistedLogs {
return list_[staged_log_index_].hash;
}
+ // Returns the timestamp of the element in the front of the list.
+ const std::string& staged_log_timestamp() const {
+ DCHECK(has_staged_log());
+ return list_[staged_log_index_].timestamp;
+ }
+
// The number of elements currently stored.
size_t size() const { return list_.size(); }
@@ -100,6 +107,9 @@ class PersistedLogs {
// Reads the list from the ListValue.
LogReadStatus ReadLogsFromPrefList(const base::ListValue& list);
+ // Reads the list from the ListValue in the old Log-hash pair format.
+ LogReadStatus ReadLogsFromOldFormatPrefList(const base::ListValue& list);
+
// A weak pointer to the PrefService object to read and write the preference
// from. Calling code should ensure this object continues to exist for the
// lifetime of the PersistedLogs object.
@@ -108,6 +118,10 @@ class PersistedLogs {
// The name of the preference to serialize logs to/from.
const char* pref_name_;
+ // The name of the preference to serialize logs to/from which may contain log
+ // in the old formatting.
+ const char* outdated_pref_name_;
+
// We will keep at least this |min_log_count_| logs or |min_log_bytes_| bytes
// of logs, whichever is greater, when writing to disk. These apply after
// skipping logs greater than |max_log_size_|.
@@ -117,19 +131,23 @@ class PersistedLogs {
// Logs greater than this size will not be written to disk.
const size_t max_log_size_;
- struct LogHashPair {
- // Initializes the members based on uncompressed |log_data|.
- void Init(const std::string& log_data);
+ struct LogInfo {
+ // Initializes the members based on uncompressed |log_data| and
+ // |log_timestamp|.
+ void Init(const std::string& log_data, const std::string& log_timestamp);
// Compressed log data - a serialized protobuf that's been gzipped.
std::string compressed_log_data;
// The SHA1 hash of log, stored to catch errors from memory corruption.
std::string hash;
+
+ // The timestamp of when the log was created as a time_t value.
+ std::string timestamp;
};
// A list of all of the stored logs, stored with SHA1 hashes to check for
// corruption while they are stored in memory.
- std::vector<LogHashPair> list_;
+ std::vector<LogInfo> list_;
// The index and type of the log staged for upload. If nothing has been
// staged, the index will be -1.
« 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