| 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 #include "components/metrics/metrics_log_manager.h" | 5 #include "components/metrics/metrics_log_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 switch (log_type) { | 108 switch (log_type) { |
| 109 case MetricsLog::INITIAL_STABILITY_LOG: | 109 case MetricsLog::INITIAL_STABILITY_LOG: |
| 110 initial_log_queue_.StoreLog(log_data); | 110 initial_log_queue_.StoreLog(log_data); |
| 111 break; | 111 break; |
| 112 case MetricsLog::ONGOING_LOG: | 112 case MetricsLog::ONGOING_LOG: |
| 113 ongoing_log_queue_.StoreLog(log_data); | 113 ongoing_log_queue_.StoreLog(log_data); |
| 114 break; | 114 break; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void MetricsLogManager::StoreStagedLogAsUnsent( | |
| 119 PersistedLogs::StoreType store_type) { | |
| 120 DCHECK(has_staged_log()); | |
| 121 if (initial_log_queue_.has_staged_log()) | |
| 122 initial_log_queue_.StoreStagedLogAsUnsent(store_type); | |
| 123 else | |
| 124 ongoing_log_queue_.StoreStagedLogAsUnsent(store_type); | |
| 125 } | |
| 126 | |
| 127 void MetricsLogManager::DiscardLastProvisionalStore() { | |
| 128 // We have at most one provisional store, (since at most one log is being | |
| 129 // uploaded at a time), so at least one of these will be a no-op. | |
| 130 initial_log_queue_.DiscardLastProvisionalStore(); | |
| 131 ongoing_log_queue_.DiscardLastProvisionalStore(); | |
| 132 } | |
| 133 | |
| 134 void MetricsLogManager::PersistUnsentLogs() { | 118 void MetricsLogManager::PersistUnsentLogs() { |
| 135 DCHECK(unsent_logs_loaded_); | 119 DCHECK(unsent_logs_loaded_); |
| 136 if (!unsent_logs_loaded_) | 120 if (!unsent_logs_loaded_) |
| 137 return; | 121 return; |
| 138 | 122 |
| 139 base::ElapsedTimer timer; | 123 base::ElapsedTimer timer; |
| 140 initial_log_queue_.SerializeLogs(); | 124 initial_log_queue_.SerializeLogs(); |
| 141 ongoing_log_queue_.SerializeLogs(); | 125 ongoing_log_queue_.SerializeLogs(); |
| 142 UMA_HISTOGRAM_TIMES("UMA.StoreLogsTime", timer.Elapsed()); | 126 UMA_HISTOGRAM_TIMES("UMA.StoreLogsTime", timer.Elapsed()); |
| 143 } | 127 } |
| 144 | 128 |
| 145 void MetricsLogManager::LoadPersistedUnsentLogs() { | 129 void MetricsLogManager::LoadPersistedUnsentLogs() { |
| 146 base::ElapsedTimer timer; | 130 base::ElapsedTimer timer; |
| 147 initial_log_queue_.DeserializeLogs(); | 131 initial_log_queue_.DeserializeLogs(); |
| 148 ongoing_log_queue_.DeserializeLogs(); | 132 ongoing_log_queue_.DeserializeLogs(); |
| 149 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); | 133 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); |
| 150 | 134 |
| 151 unsent_logs_loaded_ = true; | 135 unsent_logs_loaded_ = true; |
| 152 } | 136 } |
| 153 | 137 |
| 154 } // namespace metrics | 138 } // namespace metrics |
| OLD | NEW |