Index: components/metrics/persisted_logs.h |
diff --git a/components/metrics/persisted_logs.h b/components/metrics/persisted_logs.h |
index 73ad79a5b06e36a0e43aeebe06a44e5b615308a3..ff5de71ecc2039b7c02ba841e0993c4f83355f2e 100644 |
--- a/components/metrics/persisted_logs.h |
+++ b/components/metrics/persisted_logs.h |
@@ -72,6 +72,8 @@ class PersistedLogs { |
// Remove the staged log. |
void DiscardStagedLog(); |
+ void MigrateFromOldFormat(const char* old_pref_name); |
+ |
// True if a log has been staged. |
bool has_staged_log() const { return staged_log_index_ != -1; } |
@@ -87,6 +89,12 @@ class PersistedLogs { |
return list_[staged_log_index_].hash; |
} |
+ // Returns the timestamp of the element in the front of the list. |
+ int 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 +108,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 ReadLogsFromPrefList_OldFormat(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. |
@@ -117,7 +128,7 @@ class PersistedLogs { |
// Logs greater than this size will not be written to disk. |
const size_t max_log_size_; |
- struct LogHashPair { |
+ struct LogInfo { |
// Initializes the members based on uncompressed |log_data|. |
void Init(const std::string& log_data); |
@@ -126,10 +137,14 @@ class PersistedLogs { |
// The SHA1 hash of log, stored to catch errors from memory corruption. |
std::string hash; |
+ |
+ // The timestamp of when the log was created in seconds. Seconds is enough |
+ // as decision for removing old logs wouldn't need more granularity. |
+ int timestamp; |
Alexei Svitkine (slow)
2016/09/28 18:50:30
Add a ctor so that this value is initialized.
gayane -on leave until 09-2017
2016/09/28 20:50:50
Done.
|
}; |
// 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. |