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

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

Issue 290103005: Remove the provisional store and just store the staged log when writing to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 #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
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
OLDNEW
« no previous file with comments | « components/metrics/metrics_log_manager.h ('k') | components/metrics/metrics_log_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698