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

Side by Side Diff: components/metrics/net/cellular_logic_helper.cc

Issue 2351873002: Clean up UMA 3g experiment and unify metrics enabled pref for Android (Closed)
Patch Set: Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/net/cellular_logic_helper.h" 5 #include "components/metrics/net/cellular_logic_helper.h"
6 6
7 #include "components/variations/variations_associated_data.h"
8 #include "net/base/network_change_notifier.h" 7 #include "net/base/network_change_notifier.h"
9 8
10 namespace metrics { 9 namespace metrics {
11 10
12 namespace { 11 namespace {
13 12
14 // Standard interval between log uploads, in seconds. 13 // Standard interval between log uploads, in seconds.
15 #if defined(OS_ANDROID) || defined(OS_IOS) 14 #if defined(OS_ANDROID) || defined(OS_IOS)
16 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. 15 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes.
17 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. 16 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes.
18 #else 17 #else
19 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. 18 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes.
20 #endif 19 #endif
21 20
22 #if defined(OS_ANDROID)
23 const bool kDefaultCellularLogicEnabled = true;
24 const bool kDefaultCellularLogicOptimization = true;
25 #else
26 const bool kDefaultCellularLogicEnabled = false;
27 const bool kDefaultCellularLogicOptimization = false;
28 #endif
Alexei Svitkine (slow) 2016/09/19 19:38:02 Shouldn't we keep this logic - given that we still
gayane -on leave until 09-2017 2016/09/19 20:05:58 Brought back the defaults but still removed the ex
Alexei Svitkine (slow) 2016/09/19 20:36:56 Given that in this file the extra boolean is not d
29
30 } // namespace 21 } // namespace
31 22
32 base::TimeDelta GetUploadInterval() { 23 base::TimeDelta GetUploadInterval() {
33 #if defined(OS_ANDROID) || defined(OS_IOS) 24 #if defined(OS_ANDROID) || defined(OS_IOS)
34 if (IsCellularLogicEnabled()) 25 if (IsCellularLogicEnabled())
35 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds); 26 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
36 #endif 27 #endif
37 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); 28 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
38 } 29 }
39 30
40 // Returns true if current connection type is cellular and user is assigned to 31 // Returns true if current connection type is cellular.
41 // experimental group for enabled cellular uploads.
42 bool IsCellularLogicEnabled() { 32 bool IsCellularLogicEnabled() {
43 std::string enabled = variations::GetVariationParamValue(
44 "UMA_EnableCellularLogUpload", "Enabled");
45 std::string optimized = variations::GetVariationParamValue(
46 "UMA_EnableCellularLogUpload", "Optimize");
47 bool is_enabled = kDefaultCellularLogicEnabled;
48 if (!enabled.empty())
49 is_enabled = (enabled == "true");
50
51 bool is_optimized = kDefaultCellularLogicOptimization;
52 if (!optimized.empty())
53 is_optimized = (optimized == "true");
54
55 if (!is_enabled || !is_optimized)
56 return false;
57
58 return net::NetworkChangeNotifier::IsConnectionCellular( 33 return net::NetworkChangeNotifier::IsConnectionCellular(
59 net::NetworkChangeNotifier::GetConnectionType()); 34 net::NetworkChangeNotifier::GetConnectionType());
60 } 35 }
61 36
62 } // namespace metrics 37 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698