| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // ResumePausedLog(). Only one log may be paused at a time. | 77 // ResumePausedLog(). Only one log may be paused at a time. |
| 78 // TODO(stuartmorgan): Pause/resume support is really a workaround for a | 78 // TODO(stuartmorgan): Pause/resume support is really a workaround for a |
| 79 // design issue in initial log writing; that should be fixed, and pause/resume | 79 // design issue in initial log writing; that should be fixed, and pause/resume |
| 80 // removed. | 80 // removed. |
| 81 void PauseCurrentLog(); | 81 void PauseCurrentLog(); |
| 82 | 82 |
| 83 // Restores the previously paused log (if any) to current_log(). | 83 // Restores the previously paused log (if any) to current_log(). |
| 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(). | |
| 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 | |
| 90 // staged again). | |
| 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. | |
| 93 // This can only be called if has_staged_log() is true. | |
| 94 void StoreStagedLogAsUnsent(PersistedLogs::StoreType store_type); | |
| 95 | |
| 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 | |
| 98 // the log is no longer present, this is a no-op. | |
| 99 void DiscardLastProvisionalStore(); | |
| 100 | |
| 101 // Saves any unsent logs to persistent storage. | 87 // Saves any unsent logs to persistent storage. |
| 102 void PersistUnsentLogs(); | 88 void PersistUnsentLogs(); |
| 103 | 89 |
| 104 // Loads any unsent logs from persistent storage. | 90 // Loads any unsent logs from persistent storage. |
| 105 void LoadPersistedUnsentLogs(); | 91 void LoadPersistedUnsentLogs(); |
| 106 | 92 |
| 107 private: | 93 private: |
| 108 // Saves |log_data| as the given type. | 94 // Saves |log_data| as the given type. |
| 109 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type); | 95 void StoreLog(const std::string& log_data, MetricsLog::LogType log_type); |
| 110 | 96 |
| 111 // Tracks whether unsent logs (if any) have been loaded from the serializer. | 97 // Tracks whether unsent logs (if any) have been loaded from the serializer. |
| 112 bool unsent_logs_loaded_; | 98 bool unsent_logs_loaded_; |
| 113 | 99 |
| 114 // The log that we are still appending to. | 100 // The log that we are still appending to. |
| 115 scoped_ptr<MetricsLog> current_log_; | 101 scoped_ptr<MetricsLog> current_log_; |
| 116 | 102 |
| 117 // A paused, previously-current log. | 103 // A paused, previously-current log. |
| 118 scoped_ptr<MetricsLog> paused_log_; | 104 scoped_ptr<MetricsLog> paused_log_; |
| 119 | 105 |
| 120 // Logs that have not yet been sent. | 106 // Logs that have not yet been sent. |
| 121 PersistedLogs initial_log_queue_; | 107 PersistedLogs initial_log_queue_; |
| 122 PersistedLogs ongoing_log_queue_; | 108 PersistedLogs ongoing_log_queue_; |
| 123 | 109 |
| 124 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); | 110 DISALLOW_COPY_AND_ASSIGN(MetricsLogManager); |
| 125 }; | 111 }; |
| 126 | 112 |
| 127 } // namespace metrics | 113 } // namespace metrics |
| 128 | 114 |
| 129 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ | 115 #endif // COMPONENTS_METRICS_METRICS_LOG_MANAGER_H_ |
| OLD | NEW |