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

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: Callback to get connection type 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..19fc159e7bdd1b8efdda737c01a546453d8d9317 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
@@ -86,13 +87,15 @@ base::TimeDelta GetUploadIntervalFromExperiment() {
} // 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() {}
@@ -194,10 +197,22 @@ void MetricsReportingScheduler::BackOffUploadInterval() {
base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() {
#if defined(OS_ANDROID)
- return GetUploadIntervalFromExperiment();
-#else
- return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
+ bool is_cellular = false;
+ cellular_callback_.Run(&is_cellular);
+ if (IsCellularEnabledByExperiment() && is_cellular)
Alexei Svitkine (slow) 2015/02/18 03:26:23 Nit: Reverse the order in the if, so we don't need
gayane -on leave until 09-2017 2015/02/18 21:38:23 Done.
+ return TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
#endif
+ return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
+}
+
+void MetricsReportingScheduler::SetConnectionType(bool is_cellular) {
+ is_cellular_connection_ = is_cellular;
+}
+
+bool MetricsReportingScheduler::IsCellularEnabledByExperiment() {
+ const std::string group_name =
+ base::FieldTrialList::FindFullName("UMA_EnableCellularLogUpload");
+ return group_name == "Enabled";
}
} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698