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

Unified Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 1130993005: Reset metrics if cellular uploads logic should be applied. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix function name and nits Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698