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

Unified Diff: components/metrics/net/cellular_logic_helper.cc

Issue 1974593002: Make the launch params the default client behavior for UMA 3g (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: components/metrics/net/cellular_logic_helper.cc
diff --git a/components/metrics/net/cellular_logic_helper.cc b/components/metrics/net/cellular_logic_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d5c25a45e931c8d214809f4f86bf4d59aace68dc
--- /dev/null
+++ b/components/metrics/net/cellular_logic_helper.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/metrics/net/cellular_logic_helper.h"
+
+#include "base/metrics/field_trial.h"
+#include "components/variations/variations_associated_data.h"
+#include "net/base/network_change_notifier.h"
+
+namespace metrics {
+
+// 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
+
+const bool kDefaultCellularLogicEnabled = true;
+const bool kDefaultCellularLogicOptimization = true;
+
+base::TimeDelta GetUploadInterval() {
+#if defined(OS_ANDROID) || defined(OS_IOS)
+ if (IsCellularLogicEnabled())
+ return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
+#endif
+ return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
+}
+
+// Returns true if current connection type is cellular and user is assigned to
+// experimental group for enabled cellular uploads.
+bool IsCellularLogicEnabled() {
+ if (base::FieldTrialList::FindFullName("UMA_EnableCellularLogUpload").empty())
+ return false;
Alexei Svitkine (slow) 2016/05/13 15:53:59 I think we want to default to the new behavior whe
gayane -on leave until 09-2017 2016/05/13 18:33:15 Done.
+
+ std::string enabled = variations::GetVariationParamValue(
+ "UMA_EnableCellularLogUpload", "Enabled");
+ std::string optimized = variations::GetVariationParamValue(
+ "UMA_EnableCellularLogUpload", "Optimize");
+ bool is_enabled;
+ if (enabled.empty())
+ is_enabled = kDefaultCellularLogicEnabled;
+ else
+ is_enabled = enabled == "true";
+
+ bool is_optimized;
+ if (optimized.empty())
+ is_optimized = kDefaultCellularLogicOptimization;
+ else
+ is_optimized = optimized == "true";
+
+ if (!is_enabled || !is_optimized)
+ return false;
+
+ return net::NetworkChangeNotifier::IsConnectionCellular(
+ net::NetworkChangeNotifier::GetConnectionType());
+}
+}
Alexei Svitkine (slow) 2016/05/13 15:53:59 Nit: Add // namespace metrics and an empty line ab
gayane -on leave until 09-2017 2016/05/13 18:33:15 Done.

Powered by Google App Engine
This is Rietveld 408576698