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); |
Ilya Sherman
2014/06/02 22:06:19
nit: Probably wise to have a "break;" stmt here as
Alexei Svitkine (slow)
2014/06/03 16:52:53
Done.
| |
111 } | |
111 } | 112 } |
112 | 113 |
113 void MetricsLogManager::StoreStagedLogAsUnsent( | 114 void MetricsLogManager::StoreStagedLogAsUnsent( |
114 metrics::PersistedLogs::StoreType store_type) { | 115 metrics::PersistedLogs::StoreType store_type) { |
115 DCHECK(has_staged_log()); | 116 DCHECK(has_staged_log()); |
116 if (initial_log_queue_.has_staged_log()) | 117 if (initial_log_queue_.has_staged_log()) |
117 initial_log_queue_.StoreStagedLogAsUnsent(store_type); | 118 initial_log_queue_.StoreStagedLogAsUnsent(store_type); |
118 else | 119 else |
119 ongoing_log_queue_.StoreStagedLogAsUnsent(store_type); | 120 ongoing_log_queue_.StoreStagedLogAsUnsent(store_type); |
120 } | 121 } |
(...skipping 19 matching lines...) Expand all Loading... | |
140 void MetricsLogManager::LoadPersistedUnsentLogs() { | 141 void MetricsLogManager::LoadPersistedUnsentLogs() { |
141 base::ElapsedTimer timer; | 142 base::ElapsedTimer timer; |
142 initial_log_queue_.DeserializeLogs(); | 143 initial_log_queue_.DeserializeLogs(); |
143 ongoing_log_queue_.DeserializeLogs(); | 144 ongoing_log_queue_.DeserializeLogs(); |
144 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); | 145 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); |
145 | 146 |
146 unsent_logs_loaded_ = true; | 147 unsent_logs_loaded_ = true; |
147 } | 148 } |
148 | 149 |
149 } // namespace metrics | 150 } // namespace metrics |
OLD | NEW |