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

Unified Diff: components/metrics/metrics_reporting_scheduler.cc

Issue 922383003: Enable UMA log uploads for cellular networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments fixed Created 5 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_reporting_scheduler.cc
diff --git a/components/metrics/metrics_reporting_scheduler.cc b/components/metrics/metrics_reporting_scheduler.cc
index 53c0cc553f26bac20f89bc18339caadd4d01ef60..fb5461bd92e38717caaffc01a902118fa4f58de5 100644
--- a/components/metrics/metrics_reporting_scheduler.cc
+++ b/components/metrics/metrics_reporting_scheduler.cc
@@ -38,6 +38,7 @@ const int kUnsentLogsIntervalSeconds = 15;
// Standard interval between log uploads, in seconds.
#if defined(OS_ANDROID) || defined(OS_IOS)
const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes.
+const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes.
#else
const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes.
#endif
@@ -83,16 +84,28 @@ base::TimeDelta GetUploadIntervalFromExperiment() {
return TimeDelta::FromMinutes(interval);
}
+#if defined(OS_ANDROID) || defined(OS_IOS)
+// Returns true if the user is assigned to the experiment group for enabled
+// cellular uploads.
+bool IsCellularEnabledByExperiment() {
+ const std::string group_name =
+ base::FieldTrialList::FindFullName("UMA_EnableCellularLogUpload");
+ return group_name == "Enabled";
+}
+#endif
+
} // anonymous namespace
MetricsReportingScheduler::MetricsReportingScheduler(
- const base::Closure& upload_callback)
+ const base::Closure& upload_callback,
+ const base::Callback<void(bool*)>& cellular_callback)
: upload_callback_(upload_callback),
upload_interval_(TimeDelta::FromSeconds(kInitialUploadIntervalSeconds)),
running_(false),
callback_pending_(false),
init_task_complete_(false),
- waiting_for_init_task_complete_(false) {
+ waiting_for_init_task_complete_(false),
+ cellular_callback_(cellular_callback) {
}
MetricsReportingScheduler::~MetricsReportingScheduler() {}
@@ -193,11 +206,15 @@ void MetricsReportingScheduler::BackOffUploadInterval() {
}
base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() {
-#if defined(OS_ANDROID)
- return GetUploadIntervalFromExperiment();
-#else
- return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
+#if defined(OS_ANDROID) || defined(OS_IOS)
+ bool is_cellular = false;
+ if (!cellular_callback_.is_null())
+ cellular_callback_.Run(&is_cellular);
+
+ if (is_cellular && IsCellularEnabledByExperiment())
+ return TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
#endif
+ return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
}
} // namespace metrics
« no previous file with comments | « components/metrics/metrics_reporting_scheduler.h ('k') | components/metrics/metrics_reporting_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698