| 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..6ff158f0ea915ff2e47a7317b2779cdb34bc1072 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,13 @@ 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;
|
| + cellular_callback_.Run(&is_cellular);
|
| + if (is_cellular && IsCellularEnabledByExperiment())
|
| + return TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
|
| #endif
|
| + return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
|
| }
|
|
|
| } // namespace metrics
|
|
|