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

Unified Diff: components/metrics/metrics_service.cc

Issue 1537743006: Persist setup metrics and have Chrome report them during UMA upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: move AccessResult to .h and add histogram to .xml Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index a69d8e82c1abc1f275fc8e7808b2a0e4b9343d43..dfe6d8099936df454387d4f8559e423eeb8dad36 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -390,8 +390,8 @@ void MetricsService::EnableRecording() {
if (!log_manager_.current_log())
OpenNewLog();
- for (size_t i = 0; i < metrics_providers_.size(); ++i)
- metrics_providers_[i]->OnRecordingEnabled();
+ for (MetricsProvider* provider : metrics_providers_)
+ provider->OnRecordingEnabled();
base::RemoveActionCallback(action_callback_);
action_callback_ = base::Bind(&MetricsService::OnUserAction,
@@ -410,8 +410,8 @@ void MetricsService::DisableRecording() {
base::RemoveActionCallback(action_callback_);
- for (size_t i = 0; i < metrics_providers_.size(); ++i)
- metrics_providers_[i]->OnRecordingDisabled();
+ for (MetricsProvider* provider : metrics_providers_)
+ provider->OnRecordingDisabled();
PushPendingLogsToPersistentStorage();
}
@@ -526,8 +526,8 @@ void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) {
}
void MetricsService::ClearSavedStabilityMetrics() {
- for (size_t i = 0; i < metrics_providers_.size(); ++i)
- metrics_providers_[i]->ClearSavedStabilityMetrics();
+ for (MetricsProvider* provider : metrics_providers_)
+ provider->ClearSavedStabilityMetrics();
// Reset the prefs that are managed by MetricsService/MetricsLog directly.
local_state_->SetInteger(prefs::kStabilityCrashCount, 0);
@@ -679,8 +679,8 @@ void MetricsService::GetUptimes(PrefService* pref,
void MetricsService::NotifyOnDidCreateMetricsLog() {
DCHECK(IsSingleThreaded());
- for (size_t i = 0; i < metrics_providers_.size(); ++i)
- metrics_providers_[i]->OnDidCreateMetricsLog();
+ for (MetricsProvider* provider : metrics_providers_)
+ provider->OnDidCreateMetricsLog();
}
//------------------------------------------------------------------------------
@@ -868,8 +868,8 @@ void MetricsService::SendNextLog() {
bool MetricsService::ProvidersHaveInitialStabilityMetrics() {
// Check whether any metrics provider has initial stability metrics.
- for (size_t i = 0; i < metrics_providers_.size(); ++i) {
- if (metrics_providers_[i]->HasInitialStabilityMetrics())
+ for (MetricsProvider* provider : metrics_providers_) {
+ if (provider->HasInitialStabilityMetrics())
return true;
}
@@ -1107,11 +1107,17 @@ void MetricsService::RecordCurrentEnvironment(MetricsLog* log) {
void MetricsService::RecordCurrentHistograms() {
DCHECK(log_manager_.current_log());
- // "true" indicates that StatisticsRecorder should include histograms in
- // persistent storage.
- histogram_snapshot_manager_.PrepareDeltas(
- base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(),
- base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_snapshot_manager_.StartDeltas();
+ // "true" to the begin() call indicates that StatisticsRecorder should include
+ // histograms held in persistent storage.
+ auto end = base::StatisticsRecorder::end();
+ for (auto it = base::StatisticsRecorder::begin(true); it != end; ++it) {
+ if ((*it)->flags() & base::Histogram::kUmaTargetedHistogramFlag)
+ histogram_snapshot_manager_.PrepareDelta(*it);
+ }
+ for (MetricsProvider* provider : metrics_providers_)
+ provider->RecordHistogramSnapshots(&histogram_snapshot_manager_);
+ histogram_snapshot_manager_.FinishDeltas();
}
void MetricsService::RecordCurrentStabilityHistograms() {

Powered by Google App Engine
This is Rietveld 408576698