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

Unified Diff: components/metrics/metrics_log_manager.h

Issue 2689323010: Split a MetricsLogStore object out of MetricsLogManager. (Closed)
Patch Set: Rebase Created 3 years, 10 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/log_store.h ('k') | components/metrics/metrics_log_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_log_manager.h
diff --git a/components/metrics/metrics_log_manager.h b/components/metrics/metrics_log_manager.h
index 21e170867f78a4c5c8bb8703325884e35f0f7cd5..3227617acfc1293bfa74c163b0c769a867bc4186 100644
--- a/components/metrics/metrics_log_manager.h
+++ b/components/metrics/metrics_log_manager.h
@@ -13,19 +13,16 @@
#include "base/macros.h"
#include "components/metrics/metrics_log.h"
-#include "components/metrics/persisted_logs.h"
namespace metrics {
+class MetricsLogStore;
+
// Manages all the log objects used by a MetricsService implementation. Keeps
-// track of both an in progress log and a log that is staged for uploading as
-// text, as well as saving logs to, and loading logs from, persistent storage.
+// track of an in-progress log and a paused log.
class MetricsLogManager {
public:
- // The metrics log manager will persist it's unsent logs by storing them in
- // |local_state|, and will not persist ongoing logs over
- // |max_ongoing_log_size|.
- MetricsLogManager(PrefService* local_state, size_t max_ongoing_log_size);
+ MetricsLogManager();
~MetricsLogManager();
// Makes |log| the current_log. This should only be called if there is not a
@@ -35,42 +32,9 @@ class MetricsLogManager {
// Returns the in-progress log.
MetricsLog* current_log() { return current_log_.get(); }
- // Closes current_log(), compresses it, and stores the compressed log for
- // later, leaving current_log() NULL.
- void FinishCurrentLog();
-
- // Returns true if there are any logs waiting to be uploaded.
- bool has_unsent_logs() const {
- return initial_log_queue_.size() || ongoing_log_queue_.size();
- }
-
- // Populates staged_log_text() with the next stored log to send.
- // Should only be called if has_unsent_logs() is true.
- void StageNextLogForUpload();
-
- // Returns true if there is a log that needs to be, or is being, uploaded.
- bool has_staged_log() const {
- return initial_log_queue_.has_staged_log() ||
- ongoing_log_queue_.has_staged_log();
- }
-
- // The text of the staged log, as a serialized protobuf.
- // Will trigger a DCHECK if there is no staged log.
- const std::string& staged_log() const {
- return initial_log_queue_.has_staged_log() ?
- initial_log_queue_.staged_log() : ongoing_log_queue_.staged_log();
- }
-
- // The SHA1 hash of the staged log.
- // Will trigger a DCHECK if there is no staged log.
- const std::string& staged_log_hash() const {
- return initial_log_queue_.has_staged_log() ?
- initial_log_queue_.staged_log_hash() :
- ongoing_log_queue_.staged_log_hash();
- }
-
- // Discards the staged log.
- void DiscardStagedLog();
+ // Closes |current_log_|, compresses it, and stores it in the |log_store| for
+ // later, leaving |current_log_| NULL.
+ void FinishCurrentLog(MetricsLogStore* log_store);
// Closes and discards |current_log|.
void DiscardCurrentLog();
@@ -86,30 +50,13 @@ class MetricsLogManager {
// This should only be called if there is not a current log.
void ResumePausedLog();
- // Saves any unsent logs to persistent storage.
- void PersistUnsentLogs();
-
- // Loads any unsent logs from persistent storage.
- void LoadPersistedUnsentLogs();
-
- // Saves |log_data| as the given type. Public to allow to push log created by
- // external components.
- void StoreLog(const std::string& log_data, MetricsLog::LogType log_type);
-
private:
- // Tracks whether unsent logs (if any) have been loaded from the serializer.
- bool unsent_logs_loaded_;
-
// The log that we are still appending to.
std::unique_ptr<MetricsLog> current_log_;
// A paused, previously-current log.
std::unique_ptr<MetricsLog> paused_log_;
- // Logs that have not yet been sent.
- PersistedLogs initial_log_queue_;
- PersistedLogs ongoing_log_queue_;
-
DISALLOW_COPY_AND_ASSIGN(MetricsLogManager);
};
« no previous file with comments | « components/metrics/log_store.h ('k') | components/metrics/metrics_log_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698