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

Side by Side 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: upload interval based on the 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/metrics_reporting_scheduler.h" 5 #include "components/metrics/metrics_reporting_scheduler.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 20 matching lines...) Expand all
31 // Sending in a burst is better on a mobile device, since keeping the radio on 31 // Sending in a burst is better on a mobile device, since keeping the radio on
32 // is very expensive. 32 // is very expensive.
33 const int kUnsentLogsIntervalSeconds = 3; 33 const int kUnsentLogsIntervalSeconds = 3;
34 #else 34 #else
35 const int kUnsentLogsIntervalSeconds = 15; 35 const int kUnsentLogsIntervalSeconds = 15;
36 #endif 36 #endif
37 37
38 // Standard interval between log uploads, in seconds. 38 // Standard interval between log uploads, in seconds.
39 #if defined(OS_ANDROID) || defined(OS_IOS) 39 #if defined(OS_ANDROID) || defined(OS_IOS)
40 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. 40 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes.
41 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Five minutes.
41 #else 42 #else
42 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. 43 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes.
43 #endif 44 #endif
44 45
45 // When uploading metrics to the server fails, we progressively wait longer and 46 // When uploading metrics to the server fails, we progressively wait longer and
46 // longer before sending the next log. This backoff process helps reduce load 47 // longer before sending the next log. This backoff process helps reduce load
47 // on a server that is having issues. 48 // on a server that is having issues.
48 // The following is the multiplier we use to expand that inter-log duration. 49 // The following is the multiplier we use to expand that inter-log duration.
49 const double kBackoffMultiplier = 1.1; 50 const double kBackoffMultiplier = 1.1;
50 51
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 upload_interval_.InMicroseconds())); 188 upload_interval_.InMicroseconds()));
188 189
189 TimeDelta max_interval = kMaxBackoffMultiplier * GetStandardUploadInterval(); 190 TimeDelta max_interval = kMaxBackoffMultiplier * GetStandardUploadInterval();
190 if (upload_interval_ > max_interval || upload_interval_.InSeconds() < 0) { 191 if (upload_interval_ > max_interval || upload_interval_.InSeconds() < 0) {
191 upload_interval_ = max_interval; 192 upload_interval_ = max_interval;
192 } 193 }
193 } 194 }
194 195
195 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() { 196 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() {
196 #if defined(OS_ANDROID) 197 #if defined(OS_ANDROID)
197 return GetUploadIntervalFromExperiment(); 198 if (IsCellularConnection())
199 return TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
200 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
Alexei Svitkine (slow) 2015/02/13 21:11:40 Nit: This is the same return as a below. So you ca
gayane -on leave until 09-2017 2015/02/13 22:23:13 Done.
198 #else 201 #else
199 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); 202 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
200 #endif 203 #endif
201 } 204 }
202 205
206 void MetricsReportingScheduler::SetNetworkMetricsProvider(
207 const metrics::NetworkMetricsProvider* network_metrics_provider) {
208 network_metrics_provider_= network_metrics_provider;
209 }
210
211 bool MetricsReportingScheduler::IsCellularConnection() {
212 SystemProfileProto::Network::ConnectionType connection_type =
213 network_metrics_provider_->GetConnectionType();
Alexei Svitkine (slow) 2015/02/13 21:11:40 Nit: Since the API allows network_metrics_provider
gayane -on leave until 09-2017 2015/02/13 22:23:13 Done.
214
215 switch(connection_type) {
Alexei Svitkine (slow) 2015/02/13 21:11:40 Nit: space before (
gayane -on leave until 09-2017 2015/02/13 22:23:13 Done.
216 case SystemProfileProto_Network_ConnectionType_CONNECTION_2G:
217 case SystemProfileProto_Network_ConnectionType_CONNECTION_3G:
218 case SystemProfileProto_Network_ConnectionType_CONNECTION_4G:
219 return true;
220 default:
221 return false;
222 }
223 }
224
203 } // namespace metrics 225 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698