Chromium Code Reviews| Index: chrome/browser/metrics/chrome_metrics_service_client.cc |
| diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| index 2b6e1e1885a1aca2e24a7eb3cb54a3cad530145d..3dc6c50790d10b888ef4b85129cbca416f69fc2e 100644 |
| --- a/chrome/browser/metrics/chrome_metrics_service_client.cc |
| +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| @@ -101,7 +101,22 @@ bool IsCellularLogicEnabled() { |
| net::NetworkChangeNotifier::GetConnectionType()); |
| } |
| -} // namespace |
| +// Checks whether it is the first time that cellular uploads logic should be |
| +// enabled based on whether the the preference for that logic is initialized. |
| +// This should happen only once as the used preference will be initialized |
| +// afterwards in |UmaSessionStats.java|. |
| +bool ShouldClearSavedMetrics() { |
| +#if !defined(OS_ANDROID) |
| + return false; |
| +#endif |
| + PrefService* local_state = g_browser_process->local_state(); |
| + return !local_state->HasPrefPath(prefs::kMetricsReportingEnabled) && |
| + variations::GetVariationParamValue("UMA_EnableCellularLogUpload", |
| + "Enabled") == "true"; |
| +} |
| + |
| +} // anonymous namespace |
|
Alexei Svitkine (slow)
2015/05/13 14:36:02
Nit: No need to say "anonymous", just " // namesp
gayane -on leave until 09-2017
2015/05/13 14:46:02
Done.
|
| + |
| ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| metrics::MetricsStateManager* state_manager) |
| @@ -279,6 +294,14 @@ void ChromeMetricsServiceClient::LogPluginLoadingError( |
| } |
| void ChromeMetricsServiceClient::Initialize() { |
| + // Clear metrics reports if it is the first time cellular upload logic should |
| + // apply to avoid sudden bulk uploads. It needs to be done before initializing |
| + // metrics service so that metrics log manager is initialized correctly. |
| + if (ShouldClearSavedMetrics()) { |
| + local_state->ClearPref(metrics::prefs::kMetricsInitialLogs); |
| + local_state->ClearPref(metrics::prefs::kMetricsOngoingLogs); |
| + } |
| + |
| metrics_service_.reset(new metrics::MetricsService( |
| metrics_state_manager_, this, g_browser_process->local_state())); |
| @@ -363,6 +386,12 @@ void ChromeMetricsServiceClient::Initialize() { |
| scoped_ptr<metrics::MetricsProvider>( |
| SigninStatusMetricsProvider::CreateInstance())); |
| #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) |
| + |
| + // Clear stability metrics if it is the first time cellular upload logic |
| + // should apply to avoid sudden bulk uploads. It needs to be done after all |
| + // providers are registered. |
| + if (ShouldClearSavedMetrics()) |
| + metrics_service_->ClearSavedStabilityMetrics(); |
| } |
| void ChromeMetricsServiceClient::OnInitTaskGotHardwareClass() { |