holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_METRICS_PERSISTED_LOGS_METRICS_H_ |
| 6 | #define COMPONENTS_METRICS_PERSISTED_LOGS_METRICS_H_ |
| 7 | |
| 8 | #include "base/macros.h" |
| 9 | #include "components/metrics/persisted_logs.h" |
| 10 | |
| 11 | namespace metrics { |
| 12 | |
| 13 | // Interface for recording metrics from PersistedLogs. |
| 14 | class PersistedLogsMetrics { |
| 15 | public: |
holte | ade6fdf | 2017-02-23 02:42:39 | [diff] [blame] | 16 | // Used to produce a histogram that keeps track of the status of recalling |
| 17 | // persisted per logs. |
| 18 | enum LogReadStatus { |
| 19 | RECALL_SUCCESS, // We were able to correctly recall a persisted log. |
| 20 | LIST_EMPTY, // Attempting to recall from an empty list. |
| 21 | LIST_SIZE_MISSING, // Failed to recover list size using GetAsInteger(). |
| 22 | LIST_SIZE_TOO_SMALL, // Too few elements in the list (less than 3). |
| 23 | LIST_SIZE_CORRUPTION, // List size is not as expected. |
| 24 | LOG_STRING_CORRUPTION, // Failed to recover log string using GetAsString(). |
| 25 | CHECKSUM_CORRUPTION, // Failed to verify checksum. |
| 26 | CHECKSUM_STRING_CORRUPTION, // Failed to recover checksum string using |
| 27 | // GetAsString(). |
| 28 | DECODE_FAIL, // Failed to decode log. |
| 29 | DEPRECATED_XML_PROTO_MISMATCH, // The XML and protobuf logs have |
| 30 | // inconsistent data. |
| 31 | END_RECALL_STATUS // Number of bins to use to create the histogram. |
| 32 | }; |
| 33 | |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 34 | PersistedLogsMetrics() {} |
holte | 7b74c62 | 2017-01-23 23:13:07 | [diff] [blame] | 35 | virtual ~PersistedLogsMetrics() {} |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 36 | |
holte | ade6fdf | 2017-02-23 02:42:39 | [diff] [blame] | 37 | virtual void RecordLogReadStatus(LogReadStatus status){}; |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 38 | |
| 39 | virtual void RecordCompressionRatio( |
| 40 | size_t compressed_size, size_t original_size) {} |
| 41 | |
| 42 | virtual void RecordDroppedLogSize(size_t size) {} |
| 43 | |
| 44 | virtual void RecordDroppedLogsNum(int dropped_logs_num) {} |
| 45 | |
| 46 | private: |
| 47 | DISALLOW_COPY_AND_ASSIGN(PersistedLogsMetrics); |
| 48 | }; |
| 49 | |
| 50 | } // namespace metrics |
| 51 | |
| 52 | #endif // COMPONENTS_METRICS_PERSISTED_LOGS_METRICS_H_ |