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

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

Issue 2689323010: Split a MetricsLogStore object out of MetricsLogManager. (Closed)
Patch Set: Incorporate 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);
27 ~MetricsLogStore();
28
29 // At startup, prefs needs to be called with a list of all the pref names and
30 // types we'll be using.
bcwhite 2017/02/22 16:25:09 "types being used".
Steven Holte 2017/02/22 20:35:50 Replaced this with a simpler comment.
31 static void RegisterPrefs(PrefRegistrySimple* registry);
32
33 // Saves |log_data| as the given type.
34 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type);
35
36 // metrics::LogStore implementation
bcwhite 2017/02/22 16:25:09 Just metrics::LogStore:
Steven Holte 2017/02/22 20:35:50 Done.
37 bool has_unsent_logs() const override;
38 bool has_staged_log() const override;
39 const std::string& staged_log() const override;
40 const std::string& staged_log_hash() const override;
41 void StageNextLog() override;
42 void DiscardStagedLog() override;
43 void PersistUnsentLogs() const override;
44 void LoadPersistedUnsentLogs() override;
45
46 // Inspection methods for tests.
47 size_t ongoing_log_count() const { return ongoing_log_queue_.size(); }
48 size_t initial_log_count() const { return initial_log_queue_.size(); }
49
50 private:
51 // Tracks whether unsent logs (if any) have been loaded from the serializer.
52 bool unsent_logs_loaded_;
53
54 // Logs stored with the INITIAL_STABILITY_LOG type that haven't been sent yet.
55 // These logs will be staged first when staging new logs.
56 PersistedLogs initial_log_queue_;
57 // Logs stored with the ONGOING_LOG type that haven't been sent yet.
58 PersistedLogs ongoing_log_queue_;
59
60 DISALLOW_COPY_AND_ASSIGN(MetricsLogStore);
61 };
62
63 } // namespace metrics
64
65 #endif // COMPONENTS_METRICS_METRICS_LOG_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698