Chromium Code Reviews| 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_METRICS_LOG_STORE_H_ | |
| 6 #define COMPONENTS_METRICS_METRICS_LOG_STORE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "components/metrics/log_store.h" | |
| 12 #include "components/metrics/metrics_log.h" | |
| 13 #include "components/metrics/persisted_logs.h" | |
| 14 | |
| 15 class PrefService; | |
| 16 class PrefRegistrySimple; | |
| 17 | |
| 18 namespace metrics { | |
| 19 | |
| 20 // Interface for local storage of logs to be reported. | |
|
rkaplow
2017/02/20 21:24:13
kind of strange wording, should you instead say th
Steven Holte
2017/02/21 21:51:18
Wrote a new description.
| |
| 21 class MetricsLogStore : public LogStore { | |
| 22 public: | |
| 23 MetricsLogStore(PrefService* local_state, size_t max_retransmit_size); | |
| 24 ~MetricsLogStore(); | |
| 25 | |
| 26 // At startup, prefs needs to be called with a list of all the pref names and | |
| 27 // types we'll be using. | |
| 28 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 29 | |
| 30 // Saves |log_data| as the given type. Public to allow to push log created by | |
| 31 // external components. | |
| 32 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type); | |
| 33 | |
| 34 // metrics::LogStore implementation | |
| 35 bool has_unsent_logs() const override; | |
| 36 bool has_staged_log() const override; | |
| 37 const std::string& staged_log() const override; | |
| 38 const std::string& staged_log_hash() const override; | |
| 39 void StageNextLog() override; | |
| 40 void DiscardStagedLog() override; | |
| 41 void PersistUnsentLogs() const override; | |
| 42 void LoadPersistedUnsentLogs() override; | |
| 43 | |
| 44 // Inspection methods for tests. | |
| 45 size_t ongoing_log_count() const { return ongoing_log_queue_.size(); } | |
| 46 size_t initial_log_count() const { return initial_log_queue_.size(); } | |
| 47 | |
| 48 private: | |
| 49 // Tracks whether unsent logs (if any) have been loaded from the serializer. | |
| 50 bool unsent_logs_loaded_; | |
| 51 | |
| 52 // Logs that have not yet been sent. | |
|
rkaplow
2017/02/20 21:24:13
i'd say worth mentioning what the difference is-
Steven Holte
2017/02/21 21:51:19
Done.
| |
| 53 PersistedLogs initial_log_queue_; | |
| 54 PersistedLogs ongoing_log_queue_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(MetricsLogStore); | |
| 57 }; | |
| 58 | |
| 59 } // namespace metrics | |
| 60 | |
| 61 #endif // COMPONENTS_METRICS_METRICS_LOG_STORE_H_ | |
| OLD | NEW |