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

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..df935d84d556572339e45d264c8f3864462da468
--- /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 "components/variations/variations_associated_data.h"
+#include "net/base/network_change_notifier.h"
+
+namespace metrics {
+
+namespace {
+
+// 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;
+}
Alexei Svitkine (slow) 2016/05/13 20:21:09 Nit: Add // namespace Also, an empty line above i
gayane -on leave until 09-2017 2016/05/13 20:43:00 Done.
+
+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 !defined(OS_ANDROID) && !defined(OS_IOS)
+ return false;
+#endif
Alexei Svitkine (slow) 2016/05/13 20:21:09 I think you need an #else here else compiler may w
gayane -on leave until 09-2017 2016/05/13 20:43:00 Done.
+
+ std::string enabled = variations::GetVariationParamValue(
+ "UMA_EnableCellularLogUpload", "Enabled");
+ std::string optimized = variations::GetVariationParamValue(
+ "UMA_EnableCellularLogUpload", "Optimize");
+ bool is_enabled = kDefaultCellularLogicEnabled;
+ if (!enabled.empty())
+ is_enabled = (enabled == "true");
+
+ bool is_optimized = kDefaultCellularLogicOptimization;
+ if (!optimized.empty())
+ is_optimized = (optimized == "true");
+
+ if (!is_enabled || !is_optimized)
+ return false;
+
+ return net::NetworkChangeNotifier::IsConnectionCellular(
+ net::NetworkChangeNotifier::GetConnectionType());
+}
+
+} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698