| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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_LOG_STORE_H_ |
| 6 #define COMPONENTS_METRICS_LOG_STORE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace metrics { |
| 11 |
| 12 // Interface for local storage of serialized logs to be reported. |
| 13 // It allows consumers to check if there are logs to consume, consume them one |
| 14 // at a time by staging and discarding logs, and persist/load the whole set. |
| 15 class LogStore { |
| 16 public: |
| 17 // Returns true if there are any logs waiting to be uploaded. |
| 18 virtual bool has_unsent_logs() const = 0; |
| 19 |
| 20 // Returns true if there is a log that needs to be, or is being, uploaded. |
| 21 virtual bool has_staged_log() const = 0; |
| 22 |
| 23 // The text of the staged log, as a serialized protobuf. |
| 24 // Will trigger a DCHECK if there is no staged log. |
| 25 virtual const std::string& staged_log() const = 0; |
| 26 |
| 27 // The SHA1 hash of the staged log. |
| 28 // Will trigger a DCHECK if there is no staged log. |
| 29 virtual const std::string& staged_log_hash() const = 0; |
| 30 |
| 31 // Populates staged_log() with the next stored log to send. |
| 32 // The order in which logs are staged is up to the implementor. |
| 33 // The staged_log must remain the same even if additional logs are added. |
| 34 // Should only be called if has_unsent_logs() is true. |
| 35 virtual void StageNextLog() = 0; |
| 36 |
| 37 // Discards the staged log. |
| 38 virtual void DiscardStagedLog() = 0; |
| 39 |
| 40 // Saves any unsent logs to persistent storage. |
| 41 virtual void PersistUnsentLogs() const = 0; |
| 42 |
| 43 // Loads unsent logs from persistent storage. |
| 44 virtual void LoadPersistedUnsentLogs() = 0; |
| 45 }; |
| 46 |
| 47 } // namespace metrics |
| 48 |
| 49 #endif // COMPONENTS_METRICS_LOG_STORE_H_ |
| OLD | NEW |