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

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

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove DCHECK_IS_ON from .h files because it's not always defined and don't want to add the include Created 4 years, 7 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 //------------------------------------------------------------------------------ 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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 if ((*it)->flags() & base::Histogram::kUmaTargetedHistogramFlag) 1148 if ((*it)->flags() & base::Histogram::kUmaTargetedHistogramFlag)
1149 histogram_snapshot_manager_.PrepareDelta(*it); 1149 histogram_snapshot_manager_.PrepareDelta(*it);
1150 } 1150 }
1151 for (MetricsProvider* provider : metrics_providers_) 1151 for (MetricsProvider* provider : metrics_providers_)
1152 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_); 1152 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_);
1153 histogram_snapshot_manager_.FinishDeltas(); 1153 histogram_snapshot_manager_.FinishDeltas();
1154 } 1154 }
1155 1155
1156 void MetricsService::RecordCurrentStabilityHistograms() { 1156 void MetricsService::RecordCurrentStabilityHistograms() {
1157 DCHECK(log_manager_.current_log()); 1157 DCHECK(log_manager_.current_log());
1158 histogram_snapshot_manager_.StartDeltas();
1158 // "true" indicates that StatisticsRecorder should include histograms in 1159 // "true" indicates that StatisticsRecorder should include histograms in
1159 // persistent storage. 1160 // persistent storage.
1160 histogram_snapshot_manager_.PrepareDeltas( 1161 auto end = base::StatisticsRecorder::end();
1161 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), 1162 for (auto it = base::StatisticsRecorder::begin(true); it != end; ++it) {
1162 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); 1163 if (((*it)->flags() & base::Histogram::kUmaStabilityHistogramFlag) ==
1164 base::Histogram::kUmaStabilityHistogramFlag) {
1165 histogram_snapshot_manager_.PrepareDelta(*it);
1166 }
1167 }
1168 for (MetricsProvider* provider : metrics_providers_)
1169 provider->RecordStabilityHistogramSnapshots(&histogram_snapshot_manager_);
Ilya Sherman 2016/05/04 06:48:08 This doesn't seem like the right place to add this
bcwhite 2016/05/04 14:12:51 Correct. This method is called only from PrepareI
1170 histogram_snapshot_manager_.FinishDeltas();
1163 } 1171 }
1164 1172
1165 void MetricsService::LogCleanShutdown() { 1173 void MetricsService::LogCleanShutdown() {
1166 // Redundant setting to assure that we always reset this value at shutdown 1174 // Redundant setting to assure that we always reset this value at shutdown
1167 // (and that we don't use some alternate path, and not call LogCleanShutdown). 1175 // (and that we don't use some alternate path, and not call LogCleanShutdown).
1168 clean_shutdown_status_ = CLEANLY_SHUTDOWN; 1176 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1169 1177
1170 clean_exit_beacon_.WriteBeaconValue(true); 1178 clean_exit_beacon_.WriteBeaconValue(true);
1171 RecordCurrentState(local_state_); 1179 RecordCurrentState(local_state_);
1172 local_state_->SetInteger(prefs::kStabilityExecutionPhase, 1180 local_state_->SetInteger(prefs::kStabilityExecutionPhase,
(...skipping 18 matching lines...) Expand all
1191 base::Time::Now().ToTimeT()); 1199 base::Time::Now().ToTimeT());
1192 } 1200 }
1193 1201
1194 void MetricsService::SkipAndDiscardUpload() { 1202 void MetricsService::SkipAndDiscardUpload() {
1195 log_manager_.DiscardStagedLog(); 1203 log_manager_.DiscardStagedLog();
1196 scheduler_->UploadCancelled(); 1204 scheduler_->UploadCancelled();
1197 log_upload_in_progress_ = false; 1205 log_upload_in_progress_ = false;
1198 } 1206 }
1199 1207
1200 } // namespace metrics 1208 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698