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

Side by Side Diff: components/metrics/metrics_log_store.h

Issue 2689323010: Split a MetricsLogStore object out of MetricsLogManager. (Closed)
Patch Set: More feedback 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 unified diff | Download patch
OLDNEW
(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 // A LogStore implementation for storing UMA logs.
21 // This implementation keeps track of two types of logs, initial and ongoing,
22 // each stored in PersistedLogs. It prioritizes staging initial logs over
23 // ongoing logs.
24 class MetricsLogStore : public LogStore {
25 public:
26 MetricsLogStore(PrefService* local_state, size_t max_retransmit_size);
Alexei Svitkine (slow) 2017/02/22 20:43:46 Nit: Document the param?
Steven Holte 2017/02/22 22:15:54 Done.
27 ~MetricsLogStore();
28
29 // Registers local state prefs used by this class.
30 static void RegisterPrefs(PrefRegistrySimple* registry);
31
32 // Saves |log_data| as the given type.
33 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type);
34
35 // metrics::LogStore:
Alexei Svitkine (slow) 2017/02/22 20:43:46 Nit: Remove metrics::
Steven Holte 2017/02/22 22:15:54 Done, also removed the one I added in persisted_lo
36 bool has_unsent_logs() const override;
37 bool has_staged_log() const override;
38 const std::string& staged_log() const override;
39 const std::string& staged_log_hash() const override;
40 void StageNextLog() override;
41 void DiscardStagedLog() override;
42 void PersistUnsentLogs() const override;
43 void LoadPersistedUnsentLogs() override;
44
45 // Inspection methods for tests.
46 size_t ongoing_log_count() const { return ongoing_log_queue_.size(); }
47 size_t initial_log_count() const { return initial_log_queue_.size(); }
48
49 private:
50 // Tracks whether unsent logs (if any) have been loaded from the serializer.
51 bool unsent_logs_loaded_;
52
53 // Logs stored with the INITIAL_STABILITY_LOG type that haven't been sent yet.
54 // These logs will be staged first when staging new logs.
55 PersistedLogs initial_log_queue_;
56 // Logs stored with the ONGOING_LOG type that haven't been sent yet.
57 PersistedLogs ongoing_log_queue_;
58
59 DISALLOW_COPY_AND_ASSIGN(MetricsLogStore);
60 };
61
62 } // namespace metrics
63
64 #endif // COMPONENTS_METRICS_METRICS_LOG_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698