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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 DCHECK(!paused_log_.get()); | 95 DCHECK(!paused_log_.get()); |
96 paused_log_.reset(current_log_.release()); | 96 paused_log_.reset(current_log_.release()); |
97 } | 97 } |
98 | 98 |
99 void MetricsLogManager::ResumePausedLog() { | 99 void MetricsLogManager::ResumePausedLog() { |
100 DCHECK(!current_log_.get()); | 100 DCHECK(!current_log_.get()); |
101 current_log_.reset(paused_log_.release()); | 101 current_log_.reset(paused_log_.release()); |
102 } | 102 } |
103 | 103 |
104 void MetricsLogManager::StoreLog(std::string* log, LogType log_type) { | 104 void MetricsLogManager::StoreLog(std::string* log, LogType log_type) { |
105 DCHECK_NE(MetricsLogBase::NO_LOG, log_type); | 105 switch (log_type) { |
106 metrics::PersistedLogs* destination_queue = | 106 case MetricsLogBase::INITIAL_STABILITY_LOG: |
107 (log_type == MetricsLogBase::INITIAL_STABILITY_LOG) ? | 107 initial_log_queue_.StoreLog(log); |
108 &initial_log_queue_ : &ongoing_log_queue_; | 108 break; |
109 | 109 case MetricsLogBase::ONGOING_LOG: |
110 destination_queue->StoreLog(log); | 110 ongoing_log_queue_.StoreLog(log); |
| 111 break; |
| 112 } |
111 } | 113 } |
112 | 114 |
113 void MetricsLogManager::StoreStagedLogAsUnsent( | 115 void MetricsLogManager::StoreStagedLogAsUnsent( |
114 metrics::PersistedLogs::StoreType store_type) { | 116 metrics::PersistedLogs::StoreType store_type) { |
115 DCHECK(has_staged_log()); | 117 DCHECK(has_staged_log()); |
116 if (initial_log_queue_.has_staged_log()) | 118 if (initial_log_queue_.has_staged_log()) |
117 initial_log_queue_.StoreStagedLogAsUnsent(store_type); | 119 initial_log_queue_.StoreStagedLogAsUnsent(store_type); |
118 else | 120 else |
119 ongoing_log_queue_.StoreStagedLogAsUnsent(store_type); | 121 ongoing_log_queue_.StoreStagedLogAsUnsent(store_type); |
120 } | 122 } |
(...skipping 19 matching lines...) Expand all Loading... |
140 void MetricsLogManager::LoadPersistedUnsentLogs() { | 142 void MetricsLogManager::LoadPersistedUnsentLogs() { |
141 base::ElapsedTimer timer; | 143 base::ElapsedTimer timer; |
142 initial_log_queue_.DeserializeLogs(); | 144 initial_log_queue_.DeserializeLogs(); |
143 ongoing_log_queue_.DeserializeLogs(); | 145 ongoing_log_queue_.DeserializeLogs(); |
144 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); | 146 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); |
145 | 147 |
146 unsent_logs_loaded_ = true; | 148 unsent_logs_loaded_ = true; |
147 } | 149 } |
148 | 150 |
149 } // namespace metrics | 151 } // namespace metrics |
OLD | NEW |