diff options
author | ziadh@chromium.org <ziadh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-19 08:00:42 +0000 |
---|---|---|
committer | ziadh@chromium.org <ziadh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-19 08:00:42 +0000 |
commit | 46f89e149da3971fcf52b778de939256fae4249a (patch) | |
tree | 24a85f97832b082072dd54035a89de4ca9cc86cf /chrome/browser/metrics/metrics_service.h | |
parent | a110dd1ff6a3b8507ee164ababea537df52642cb (diff) | |
download | chromium_src-46f89e149da3971fcf52b778de939256fae4249a.zip chromium_src-46f89e149da3971fcf52b778de939256fae4249a.tar.gz chromium_src-46f89e149da3971fcf52b778de939256fae4249a.tar.bz2 |
Compress and checksum pending logs that are going to be persisted. Persisted logs now have the following format:
[list_size, log1, log2, ..., log_n, checksum].
where each log is bzipped before being written. Upon reading the logs from disk, we verify the data and register whether we faced corruptions or not.
r=jar
Review URL: http://codereview.chromium.org/2936005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/metrics_service.h')
-rw-r--r-- | chrome/browser/metrics/metrics_service.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index 7e318f0..5066d82 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -80,6 +80,30 @@ class MetricsService : public NotificationObserver, public URLFetcher::Delegate, public MetricsServiceBase { public: + // Used to produce a historgram that keeps track of the status of recalling + // persisted per logs. + enum LogRecallStatus { + RECALL_SUCCESS, // We were able to correctly recall a persisted log. + LIST_EMPTY, // Attempting to recall from an empty list. + LIST_SIZE_MISSING, // Failed to recover list size using GetAsInteger(). + LIST_SIZE_TOO_SMALL, // Too few elements in the list (less than 3). + LIST_SIZE_CORRUPTION, // List size is not as expected. + LOG_STRING_CORRUPTION, // Failed to recover log string using GetAsString(). + CHECKSUM_CORRUPTION, // Failed to verify checksum. + CHECKSUM_STRING_CORRUPTION, // Failed to recover checksum string using + // GetAsString(). + DECODE_FAIL, // Failed to decode log. + END_RECALL_STATUS // Number of bins to use to create the histogram. + }; + + // TODO(ziadh): This is here temporarily for a side experiment. Remove later + // on. + enum LogStoreStatus { + ENCODE_FAIL, // Failed to encode log. + COMPRESS_FAIL, // Failed to compress log. + END_STORE_STATUS // Number of bins to use to create the histogram. + }; + MetricsService(); virtual ~MetricsService(); @@ -263,7 +287,16 @@ class MetricsService : public NotificationObserver, void PrepareInitialLog(); // Pull copies of unsent logs from prefs into instance variables. void RecallUnsentLogs(); - // Convert pending_log_ to XML in pending_log_text_ for transmission. + // Decode and verify written pref log data. + static MetricsService::LogRecallStatus RecallUnsentLogsHelper( + const ListValue& list, + std::vector<std::string>* local_list); + // Encode and write list size and checksum for perf log data. + static void StoreUnsentLogsHelper(const std::vector<std::string>& local_list, + const size_t kMaxLocalListSize, + ListValue* list); + // Convert |pending_log_| to XML in |compressed_log_|, and compress it for + // transmission. void PreparePendingLogText(); // Convert pending_log_ to XML, compress it, and prepare to pass to server. @@ -489,6 +522,13 @@ class MetricsService : public NotificationObserver, scoped_refptr<chromeos::ExternalMetrics> external_metrics_; #endif + FRIEND_TEST(MetricsServiceTest, EmptyLogList); + FRIEND_TEST(MetricsServiceTest, SingleElementLogList); + FRIEND_TEST(MetricsServiceTest, OverLimitLogList); + FRIEND_TEST(MetricsServiceTest, SmallRecoveredListSize); + FRIEND_TEST(MetricsServiceTest, RemoveSizeFromLogList); + FRIEND_TEST(MetricsServiceTest, CorruptSizeOfLogList); + FRIEND_TEST(MetricsServiceTest, CorruptChecksumOfLogList); FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesAllZeroes); FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesCorrectly); FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); |