OLD | NEW |
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" |
15 | 14 |
| 15 namespace metrics { |
16 // Manages all the log objects used by a MetricsService implementation. Keeps | 16 // 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 | 17 // 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. | 18 // text, as well as saving logs to, and loading logs from, persistent storage. |
19 class MetricsLogManager { | 19 class MetricsLogManager { |
20 public: | 20 public: |
21 typedef MetricsLogBase::LogType LogType; | 21 typedef MetricsLogBase::LogType LogType; |
22 | 22 |
23 MetricsLogManager(); | 23 MetricsLogManager(); |
24 ~MetricsLogManager(); | 24 ~MetricsLogManager(); |
25 | 25 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // Loads any unsent logs from persistent storage using the current log | 159 // Loads any unsent logs from persistent storage using the current log |
160 // serializer. Can only be called after set_log_serializer. | 160 // serializer. Can only be called after set_log_serializer. |
161 void LoadPersistedUnsentLogs(); | 161 void LoadPersistedUnsentLogs(); |
162 | 162 |
163 private: | 163 private: |
164 // Saves |log| as the given type (or discards it in accordance with | 164 // Saves |log| as the given type (or discards it in accordance with |
165 // |max_ongoing_log_store_size_|). | 165 // |max_ongoing_log_store_size_|). |
166 // NOTE: This clears the contents of |log| (to avoid an expensive copy), | 166 // NOTE: This clears the contents of |log| (to avoid an expensive copy), |
167 // so the log should be discarded after this call. | 167 // so the log should be discarded after this call. |
168 void StoreLog(SerializedLog* log, | 168 void StoreLog(SerializedLog* log, LogType log_type, StoreType store_type); |
169 LogType log_type, | |
170 StoreType store_type); | |
171 | 169 |
172 // Compresses |current_log_| into |compressed_log|. | 170 // Compresses |current_log_| into |compressed_log|. |
173 void CompressCurrentLog(SerializedLog* compressed_log); | 171 void CompressCurrentLog(SerializedLog* compressed_log); |
174 | 172 |
175 // Tracks whether unsent logs (if any) have been loaded from the serializer. | 173 // Tracks whether unsent logs (if any) have been loaded from the serializer. |
176 bool unsent_logs_loaded_; | 174 bool unsent_logs_loaded_; |
177 | 175 |
178 // The log that we are still appending to. | 176 // The log that we are still appending to. |
179 scoped_ptr<MetricsLogBase> current_log_; | 177 scoped_ptr<MetricsLogBase> current_log_; |
180 | 178 |
(...skipping 20 matching lines...) Expand all Loading... |
201 // provisionally stored, or the last provisional store has already been | 199 // provisionally stored, or the last provisional store has already been |
202 // re-staged, the index will be -1; | 200 // re-staged, the index will be -1; |
203 // This is necessary because during an upload there are two logs (staged | 201 // 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 | 202 // 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. | 203 // not necessarily the case that the provisional store is the last store. |
206 int last_provisional_store_index_; | 204 int last_provisional_store_index_; |
207 LogType last_provisional_store_type_; | 205 LogType last_provisional_store_type_; |
208 | 206 |
209 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); | 207 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); |
210 }; | 208 }; |
| 209 } // namespace metrics |
211 | 210 |
212 #endif // CHROME_COMMON_METRICS_METRICS_LOG_MANAGER_H_ | 211 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ |
OLD | NEW |