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

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: addressed review comments by Greg 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 e882d8becd443438b51109db7f97492b06517efc..37de190cdc0963bcf2fca772329963aa904f8a36 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 (auto& 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 (auto& 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 (auto& 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 (auto& 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 (auto& 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::kUmaStabilityHistogramFlag);
+ 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::kUmaStabilityHistogramFlag)
+ histogram_snapshot_manager_.PrepareDelta(*it);
+ }
+ for (auto& provider : metrics_providers_)
Alexei Svitkine (slow) 2016/02/17 21:55:36 Nit: "for (MetricsProvider* provider : metrics_pro
bcwhite 2016/02/18 01:46:57 Done.
+ provider->RecordHistogramSnapshots(&histogram_snapshot_manager_);
+ histogram_snapshot_manager_.FinishDeltas();
}
void MetricsService::RecordCurrentStabilityHistograms() {
« components/metrics/metrics_provider.cc ('K') | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698