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

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: removed some unnecessary includes 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
« no previous file with comments | « components/metrics/metrics_provider.cc ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); 1136 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials);
1137 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, 1137 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials,
1138 GetInstallDate(), GetMetricsReportingEnabledDate()); 1138 GetInstallDate(), GetMetricsReportingEnabledDate());
1139 } 1139 }
1140 1140
1141 void MetricsService::RecordCurrentHistograms() { 1141 void MetricsService::RecordCurrentHistograms() {
1142 DCHECK(log_manager_.current_log()); 1142 DCHECK(log_manager_.current_log());
1143 histogram_snapshot_manager_.StartDeltas(); 1143 histogram_snapshot_manager_.StartDeltas();
1144 // "true" to the begin() call indicates that StatisticsRecorder should include 1144 // "true" to the begin() call indicates that StatisticsRecorder should include
1145 // histograms held in persistent storage. 1145 // histograms held in persistent storage.
1146 auto end = base::StatisticsRecorder::end(); 1146 histogram_snapshot_manager_.PrepareDeltasWithoutStartFinish(
1147 for (auto it = base::StatisticsRecorder::begin(true); it != end; ++it) { 1147 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
1148 if ((*it)->flags() & base::Histogram::kUmaTargetedHistogramFlag) 1148 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
1149 histogram_snapshot_manager_.PrepareDelta(*it);
1150 }
1151 for (MetricsProvider* provider : metrics_providers_) 1149 for (MetricsProvider* provider : metrics_providers_)
1152 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_); 1150 provider->RecordHistogramSnapshots(&histogram_snapshot_manager_);
1153 histogram_snapshot_manager_.FinishDeltas(); 1151 histogram_snapshot_manager_.FinishDeltas();
1154 } 1152 }
1155 1153
1156 void MetricsService::RecordCurrentStabilityHistograms() { 1154 void MetricsService::RecordCurrentStabilityHistograms() {
1157 DCHECK(log_manager_.current_log()); 1155 DCHECK(log_manager_.current_log());
1156 histogram_snapshot_manager_.StartDeltas();
1158 // "true" indicates that StatisticsRecorder should include histograms in 1157 // "true" indicates that StatisticsRecorder should include histograms in
1159 // persistent storage. 1158 // persistent storage.
1160 histogram_snapshot_manager_.PrepareDeltas( 1159 histogram_snapshot_manager_.PrepareDeltasWithoutStartFinish(
1161 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), 1160 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
1162 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); 1161 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag);
1162 for (MetricsProvider* provider : metrics_providers_)
1163 provider->RecordInitialHistogramSnapshots(&histogram_snapshot_manager_);
1164 histogram_snapshot_manager_.FinishDeltas();
1163 } 1165 }
1164 1166
1165 void MetricsService::LogCleanShutdown() { 1167 void MetricsService::LogCleanShutdown() {
1166 // Redundant setting to assure that we always reset this value at shutdown 1168 // 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). 1169 // (and that we don't use some alternate path, and not call LogCleanShutdown).
1168 clean_shutdown_status_ = CLEANLY_SHUTDOWN; 1170 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1169 1171
1170 clean_exit_beacon_.WriteBeaconValue(true); 1172 clean_exit_beacon_.WriteBeaconValue(true);
1171 RecordCurrentState(local_state_); 1173 RecordCurrentState(local_state_);
1172 local_state_->SetInteger(prefs::kStabilityExecutionPhase, 1174 local_state_->SetInteger(prefs::kStabilityExecutionPhase,
(...skipping 18 matching lines...) Expand all
1191 base::Time::Now().ToTimeT()); 1193 base::Time::Now().ToTimeT());
1192 } 1194 }
1193 1195
1194 void MetricsService::SkipAndDiscardUpload() { 1196 void MetricsService::SkipAndDiscardUpload() {
1195 log_manager_.DiscardStagedLog(); 1197 log_manager_.DiscardStagedLog();
1196 scheduler_->UploadCancelled(); 1198 scheduler_->UploadCancelled();
1197 log_upload_in_progress_ = false; 1199 log_upload_in_progress_ = false;
1198 } 1200 }
1199 1201
1200 } // namespace metrics 1202 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_provider.cc ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698