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

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

Issue 318203004: Make MetricsService save compressed logs to local state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // This should only be called if there is not a current log. 84 // This should only be called if there is not a current log.
85 void ResumePausedLog(); 85 void ResumePausedLog();
86 86
87 // Saves the staged log, then clears staged_log(). 87 // Saves the staged log, then clears staged_log().
88 // If |store_type| is PROVISIONAL_STORE, it can be dropped from storage with 88 // If |store_type| is PROVISIONAL_STORE, it can be dropped from storage with
89 // a later call to DiscardLastProvisionalStore (if it hasn't already been 89 // a later call to DiscardLastProvisionalStore (if it hasn't already been
90 // staged again). 90 // staged again).
91 // This is intended to be used when logs are being saved while an upload is in 91 // This is intended to be used when logs are being saved while an upload is in
92 // progress, in case the upload later succeeds. 92 // progress, in case the upload later succeeds.
93 // This can only be called if has_staged_log() is true. 93 // This can only be called if has_staged_log() is true.
94 void StoreStagedLogAsUnsent(metrics::PersistedLogs::StoreType store_type); 94 void StoreStagedLogAsUnsent(PersistedLogs::StoreType store_type);
95 95
96 // Discards the last log stored with StoreStagedLogAsUnsent with |store_type| 96 // Discards the last log stored with StoreStagedLogAsUnsent with |store_type|
97 // set to PROVISIONAL_STORE, as long as it hasn't already been re-staged. If 97 // set to PROVISIONAL_STORE, as long as it hasn't already been re-staged. If
98 // the log is no longer present, this is a no-op. 98 // the log is no longer present, this is a no-op.
99 void DiscardLastProvisionalStore(); 99 void DiscardLastProvisionalStore();
100 100
101 // Saves any unsent logs to persistent storage. 101 // Saves any unsent logs to persistent storage.
102 void PersistUnsentLogs(); 102 void PersistUnsentLogs();
103 103
104 // Loads any unsent logs from persistent storage. 104 // Loads any unsent logs from persistent storage.
105 void LoadPersistedUnsentLogs(); 105 void LoadPersistedUnsentLogs();
106 106
107 private: 107 private:
108 // Saves |log| as the given type. 108 // Saves |log_data| as the given type.
109 // NOTE: This clears the contents of |log| (to avoid an expensive copy), 109 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type);
110 // so the log should be discarded after this call.
111 void StoreLog(std::string* log, MetricsLog::LogType log_type);
112 110
113 // Tracks whether unsent logs (if any) have been loaded from the serializer. 111 // Tracks whether unsent logs (if any) have been loaded from the serializer.
114 bool unsent_logs_loaded_; 112 bool unsent_logs_loaded_;
115 113
116 // The log that we are still appending to. 114 // The log that we are still appending to.
117 scoped_ptr<MetricsLog> current_log_; 115 scoped_ptr<MetricsLog> current_log_;
118 116
119 // A paused, previously-current log. 117 // A paused, previously-current log.
120 scoped_ptr<MetricsLog> paused_log_; 118 scoped_ptr<MetricsLog> paused_log_;
121 119
122 // Logs that have not yet been sent. 120 // Logs that have not yet been sent.
123 metrics::PersistedLogs initial_log_queue_; 121 PersistedLogs initial_log_queue_;
124 metrics::PersistedLogs ongoing_log_queue_; 122 PersistedLogs ongoing_log_queue_;
125 123
126 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); 124 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager);
127 }; 125 };
128 126
129 } // namespace metrics 127 } // namespace metrics
130 128
131 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ 129 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_
OLDNEW
« no previous file with comments | « components/metrics/compression_utils_unittest.cc ('k') | components/metrics/metrics_log_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698