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

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

Issue 1906173002: Convert //components/metrics from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « components/metrics/metrics_log.cc ('k') | components/metrics/metrics_log_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 5 #ifndef COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
6 #define COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 6 #define COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "components/metrics/metrics_log.h" 15 #include "components/metrics/metrics_log.h"
16 #include "components/metrics/persisted_logs.h" 16 #include "components/metrics/persisted_logs.h"
17 17
18 namespace metrics { 18 namespace metrics {
19 19
20 // Manages all the log objects used by a MetricsService implementation. Keeps 20 // Manages all the log objects used by a MetricsService implementation. Keeps
21 // track of both an in progress log and a log that is staged for uploading as 21 // track of both an in progress log and a log that is staged for uploading as
22 // text, as well as saving logs to, and loading logs from, persistent storage. 22 // text, as well as saving logs to, and loading logs from, persistent storage.
23 class MetricsLogManager { 23 class MetricsLogManager {
24 public: 24 public:
25 // The metrics log manager will persist it's unsent logs by storing them in 25 // The metrics log manager will persist it's unsent logs by storing them in
26 // |local_state|, and will not persist ongoing logs over 26 // |local_state|, and will not persist ongoing logs over
27 // |max_ongoing_log_size|. 27 // |max_ongoing_log_size|.
28 MetricsLogManager(PrefService* local_state, size_t max_ongoing_log_size); 28 MetricsLogManager(PrefService* local_state, size_t max_ongoing_log_size);
29 ~MetricsLogManager(); 29 ~MetricsLogManager();
30 30
31 // Makes |log| the current_log. This should only be called if there is not a 31 // Makes |log| the current_log. This should only be called if there is not a
32 // current log. 32 // current log.
33 void BeginLoggingWithLog(scoped_ptr<MetricsLog> log); 33 void BeginLoggingWithLog(std::unique_ptr<MetricsLog> log);
34 34
35 // Returns the in-progress log. 35 // Returns the in-progress log.
36 MetricsLog* current_log() { return current_log_.get(); } 36 MetricsLog* current_log() { return current_log_.get(); }
37 37
38 // Closes current_log(), compresses it, and stores the compressed log for 38 // Closes current_log(), compresses it, and stores the compressed log for
39 // later, leaving current_log() NULL. 39 // later, leaving current_log() NULL.
40 void FinishCurrentLog(); 40 void FinishCurrentLog();
41 41
42 // Returns true if there are any logs waiting to be uploaded. 42 // Returns true if there are any logs waiting to be uploaded.
43 bool has_unsent_logs() const { 43 bool has_unsent_logs() const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Saves |log_data| as the given type. Public to allow to push log created by 95 // Saves |log_data| as the given type. Public to allow to push log created by
96 // external components. 96 // external components.
97 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type); 97 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type);
98 98
99 private: 99 private:
100 // Tracks whether unsent logs (if any) have been loaded from the serializer. 100 // Tracks whether unsent logs (if any) have been loaded from the serializer.
101 bool unsent_logs_loaded_; 101 bool unsent_logs_loaded_;
102 102
103 // The log that we are still appending to. 103 // The log that we are still appending to.
104 scoped_ptr<MetricsLog> current_log_; 104 std::unique_ptr<MetricsLog> current_log_;
105 105
106 // A paused, previously-current log. 106 // A paused, previously-current log.
107 scoped_ptr<MetricsLog> paused_log_; 107 std::unique_ptr<MetricsLog> paused_log_;
108 108
109 // Logs that have not yet been sent. 109 // Logs that have not yet been sent.
110 PersistedLogs initial_log_queue_; 110 PersistedLogs initial_log_queue_;
111 PersistedLogs ongoing_log_queue_; 111 PersistedLogs ongoing_log_queue_;
112 112
113 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); 113 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager);
114 }; 114 };
115 115
116 } // namespace metrics 116 } // namespace metrics
117 117
118 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 118 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
OLDNEW
« no previous file with comments | « components/metrics/metrics_log.cc ('k') | components/metrics/metrics_log_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698