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

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

Issue 239093004: Move part of metrics from chrome/common to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding TBR section for owners of minor changes. Created 6 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 5 #ifndef COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
6 #define CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 6 #define COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
7
8 7
9 #include <string> 8 #include <string>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/basictypes.h" 11 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "chrome/common/metrics/metrics_log_base.h" 13 #include "components/metrics/metrics_log_base.h"
14
15 namespace metrics {
15 16
16 // Manages all the log objects used by a MetricsService implementation. Keeps 17 // Manages all the log objects used by a MetricsService implementation. Keeps
17 // track of both an in progress log and a log that is staged for uploading as 18 // track of both an in progress log and a log that is staged for uploading as
18 // text, as well as saving logs to, and loading logs from, persistent storage. 19 // text, as well as saving logs to, and loading logs from, persistent storage.
19 class MetricsLogManager { 20 class MetricsLogManager {
20 public: 21 public:
21 typedef MetricsLogBase::LogType LogType; 22 typedef MetricsLogBase::LogType LogType;
22 23
23 MetricsLogManager(); 24 MetricsLogManager();
24 ~MetricsLogManager(); 25 ~MetricsLogManager();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 // Loads any unsent logs from persistent storage using the current log 160 // Loads any unsent logs from persistent storage using the current log
160 // serializer. Can only be called after set_log_serializer. 161 // serializer. Can only be called after set_log_serializer.
161 void LoadPersistedUnsentLogs(); 162 void LoadPersistedUnsentLogs();
162 163
163 private: 164 private:
164 // Saves |log| as the given type (or discards it in accordance with 165 // Saves |log| as the given type (or discards it in accordance with
165 // |max_ongoing_log_store_size_|). 166 // |max_ongoing_log_store_size_|).
166 // NOTE: This clears the contents of |log| (to avoid an expensive copy), 167 // NOTE: This clears the contents of |log| (to avoid an expensive copy),
167 // so the log should be discarded after this call. 168 // so the log should be discarded after this call.
168 void StoreLog(SerializedLog* log, 169 void StoreLog(SerializedLog* log, LogType log_type, StoreType store_type);
169 LogType log_type,
170 StoreType store_type);
171 170
172 // Compresses |current_log_| into |compressed_log|. 171 // Compresses |current_log_| into |compressed_log|.
173 void CompressCurrentLog(SerializedLog* compressed_log); 172 void CompressCurrentLog(SerializedLog* compressed_log);
174 173
175 // Tracks whether unsent logs (if any) have been loaded from the serializer. 174 // Tracks whether unsent logs (if any) have been loaded from the serializer.
176 bool unsent_logs_loaded_; 175 bool unsent_logs_loaded_;
177 176
178 // The log that we are still appending to. 177 // The log that we are still appending to.
179 scoped_ptr<MetricsLogBase> current_log_; 178 scoped_ptr<MetricsLogBase> current_log_;
180 179
(...skipping 21 matching lines...) Expand all
202 // re-staged, the index will be -1; 201 // re-staged, the index will be -1;
203 // This is necessary because during an upload there are two logs (staged 202 // This is necessary because during an upload there are two logs (staged
204 // and current) and a client might store them in either order, so it's 203 // and current) and a client might store them in either order, so it's
205 // not necessarily the case that the provisional store is the last store. 204 // not necessarily the case that the provisional store is the last store.
206 int last_provisional_store_index_; 205 int last_provisional_store_index_;
207 LogType last_provisional_store_type_; 206 LogType last_provisional_store_type_;
208 207
209 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); 208 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager);
210 }; 209 };
211 210
212 #endif // CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ 211 } // namespace metrics
212
213 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698