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

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

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: added merge test Created 5 years 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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial, uint32 group) { 246 SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial, uint32 group) {
247 id.name = trial; 247 id.name = trial;
248 id.group = group; 248 id.group = group;
249 } 249 }
250 250
251 SyntheticTrialGroup::~SyntheticTrialGroup() { 251 SyntheticTrialGroup::~SyntheticTrialGroup() {
252 } 252 }
253 253
254 MetricsService::PersistentHistogramIterator::PersistentHistogramIterator( 254 MetricsService::PersistentHistogramIterator::PersistentHistogramIterator(
255 HistogramSet* found_histograms,
255 AllocatorSet& allocators, 256 AllocatorSet& allocators,
256 AllocatorSet::iterator pos) 257 AllocatorSet::iterator pos)
257 : allocators_(allocators), 258 : allocators_(allocators),
258 allocator_iter_(pos) { 259 allocator_iter_(pos),
260 found_histograms_(found_histograms) {
259 if (pos != allocators_.end()) { 261 if (pos != allocators_.end()) {
260 (*allocator_iter_)->CreateIterator(&histogram_iter_); 262 (*allocator_iter_)->CreateIterator(&histogram_iter_);
261 // Have to call ++ to advance iterator to the first persistent histogram. 263 // Have to call ++ to advance iterator to the first persistent histogram.
262 operator++(); 264 operator++();
263 } 265 }
264 } 266 }
265 267
266 MetricsService::PersistentHistogramIterator& 268 MetricsService::PersistentHistogramIterator&
267 MetricsService::PersistentHistogramIterator::operator++() { 269 MetricsService::PersistentHistogramIterator::operator++() {
268 if (allocator_iter_ != allocators_.end()) { 270 if (allocator_iter_ != allocators_.end()) {
269 for (;;) { 271 for (;;) {
270 base::HistogramBase* h = base::HistogramBase::GetNextPersistentHistogram( 272 current_histogram_ = base::HistogramBase::GetNextPersistentHistogram(
271 *allocator_iter_, &histogram_iter_); 273 *allocator_iter_, &histogram_iter_);
272 if (h) { 274 if (current_histogram_) {
273 current_histogram_ = new HistogramPointer(h); 275 DCHECK(found_histograms_->find(current_histogram_) ==
276 found_histograms_->end());
277 found_histograms_->insert(current_histogram_);
274 break; 278 break;
275 } 279 }
276 allocator_iter_++; 280 allocator_iter_++;
277 if (allocator_iter_ == allocators_.end()) { 281 if (allocator_iter_ == allocators_.end()) {
278 histogram_iter_.clear(); // Clear so it matches end() iterator. 282 histogram_iter_.clear(); // Clear so it matches end() iterator.
279 current_histogram_ = nullptr; 283 current_histogram_ = nullptr;
280 break; 284 break;
281 } 285 }
282 (*allocator_iter_)->CreateIterator(&histogram_iter_); 286 (*allocator_iter_)->CreateIterator(&histogram_iter_);
283 } 287 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); 1155 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials);
1152 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, 1156 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials,
1153 GetInstallDate(), GetMetricsReportingEnabledDate()); 1157 GetInstallDate(), GetMetricsReportingEnabledDate());
1154 } 1158 }
1155 1159
1156 void MetricsService::RecordCurrentHistograms() { 1160 void MetricsService::RecordCurrentHistograms() {
1157 DCHECK(log_manager_.current_log()); 1161 DCHECK(log_manager_.current_log());
1158 histogram_snapshot_manager_.PrepareDeltas( 1162 histogram_snapshot_manager_.PrepareDeltas(
1159 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), 1163 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
1160 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); 1164 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
1165 HistogramSet persistent_histograms;
1161 histogram_snapshot_manager_.PrepareDeltas( 1166 histogram_snapshot_manager_.PrepareDeltas(
1162 persistent_begin(), persistent_end(), 1167 persistent_begin(&persistent_histograms), persistent_end(),
1163 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); 1168 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
1169 STLDeleteElements(&persistent_histograms);
1164 } 1170 }
1165 1171
1166 void MetricsService::RecordCurrentStabilityHistograms() { 1172 void MetricsService::RecordCurrentStabilityHistograms() {
1167 DCHECK(log_manager_.current_log()); 1173 DCHECK(log_manager_.current_log());
1168 histogram_snapshot_manager_.PrepareDeltas( 1174 histogram_snapshot_manager_.PrepareDeltas(
1169 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), 1175 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
1170 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); 1176 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag);
1171 } 1177 }
1172 1178
1173 void MetricsService::LogCleanShutdown() { 1179 void MetricsService::LogCleanShutdown() {
(...skipping 24 matching lines...) Expand all
1198 pref->SetInt64(prefs::kStabilityLastTimestampSec, 1204 pref->SetInt64(prefs::kStabilityLastTimestampSec,
1199 base::Time::Now().ToTimeT()); 1205 base::Time::Now().ToTimeT());
1200 } 1206 }
1201 1207
1202 void MetricsService::SkipAndDiscardUpload() { 1208 void MetricsService::SkipAndDiscardUpload() {
1203 log_manager_.DiscardStagedLog(); 1209 log_manager_.DiscardStagedLog();
1204 scheduler_->UploadCancelled(); 1210 scheduler_->UploadCancelled();
1205 log_upload_in_progress_ = false; 1211 log_upload_in_progress_ = false;
1206 } 1212 }
1207 1213
1208 MetricsService::PersistentHistogramIterator MetricsService::persistent_begin() { 1214 MetricsService::PersistentHistogramIterator MetricsService::persistent_begin(
1209 return PersistentHistogramIterator(allocators_, allocators_.begin()); 1215 HistogramSet* found) {
1216 return PersistentHistogramIterator(found, allocators_, allocators_.begin());
1210 } 1217 }
1211 1218
1212 MetricsService::PersistentHistogramIterator MetricsService::persistent_end() { 1219 MetricsService::PersistentHistogramIterator MetricsService::persistent_end() {
1213 return PersistentHistogramIterator(allocators_, allocators_.end()); 1220 return PersistentHistogramIterator(nullptr, allocators_, allocators_.end());
1214 } 1221 }
1215 1222
1216 } // namespace metrics 1223 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698