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

Unified Diff: components/metrics/metrics_service.cc

Issue 2918533003: Send metrics with embedded system profiles after system startup. (Closed)
Patch Set: fixed tests on mac Created 3 years, 6 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 f489d16019e897f326b09e2effe5c263ffd1a411..301e9bb7dcc2c18f6f9f01c203568e294842253f 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -625,6 +625,12 @@ void MetricsService::OpenNewLog() {
FROM_HERE, base::Bind(&MetricsService::StartInitTask,
self_ptr_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(kInitializationDelaySeconds));
+
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
Alexei Svitkine (slow) 2017/06/08 23:59:30 Please use the new post task APIs in base please.
bcwhite 2017/06/09 15:09:27 That API runs tasks on threads it owns rather than
+ FROM_HERE,
+ base::Bind(&MetricsService::RecordIndependentHistogramJob,
+ self_ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromSeconds(2 * kInitializationDelaySeconds));
}
}
@@ -971,6 +977,29 @@ void MetricsService::RecordCurrentStabilityHistograms() {
provider->RecordInitialHistogramSnapshots(&histogram_snapshot_manager_);
}
+bool MetricsService::RecordIndependentHistogramLog() {
Alexei Svitkine (slow) 2017/06/08 23:59:30 Nit: Add thread_checker_ tests here and below.
bcwhite 2017/06/09 15:09:27 Done.
+ std::unique_ptr<MetricsLog> log = CreateLog(MetricsLog::INDEPENDENT_LOG);
Alexei Svitkine (slow) 2017/06/08 23:59:31 CreateLog() uses session_id_ but this is not corre
bcwhite 2017/06/09 15:09:27 Done.
+ for (auto& provider : metrics_providers_) {
+ if (log->LoadIndependentMetrics(provider.get())) {
+ log_manager_.PauseCurrentLog();
+ log_manager_.BeginLoggingWithLog(std::move(log));
+ log_manager_.FinishCurrentLog(log_store());
+ log_manager_.ResumePausedLog();
+ return true;
+ }
+ }
+ return false;
+}
+
+void MetricsService::RecordIndependentHistogramJob() {
+ bool found = RecordIndependentHistogramLog();
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&MetricsService::RecordIndependentHistogramJob,
+ self_ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromSeconds(found ? 5 : 900));
Alexei Svitkine (slow) 2017/06/08 23:59:30 Nit: instead FromMinutes(15) and move the found to
bcwhite 2017/06/09 15:09:27 Done.
+}
+
void MetricsService::LogCleanShutdown(bool end_completed) {
DCHECK(thread_checker_.CalledOnValidThread());
// Redundant setting to assure that we always reset this value at shutdown

Powered by Google App Engine
This is Rietveld 408576698