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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/metrics/net/cellular_logic_helper.h"
6
7 #include "components/variations/variations_associated_data.h"
8 #include "net/base/network_change_notifier.h"
9
10 namespace metrics {
11
12 // Standard interval between log uploads, in seconds.
13 #if defined(OS_ANDROID) || defined(OS_IOS)
14 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes.
15 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes.
16 #else
17 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes.
18 #endif
19
20 const bool kDefaultCellularLogicEnabled = true;
21 const bool kDefaultCellularLogicOptimization = true;
Alexei Svitkine (slow) 2016/05/13 18:37:13 These should be in the anon namespace.
gayane -on leave until 09-2017 2016/05/13 19:17:02 Done.
22
23 base::TimeDelta GetUploadInterval() {
24 #if defined(OS_ANDROID) || defined(OS_IOS)
25 if (IsCellularLogicEnabled())
26 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
27 #endif
28 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
29 }
30
31 // Returns true if current connection type is cellular and user is assigned to
32 // experimental group for enabled cellular uploads.
33 bool IsCellularLogicEnabled() {
Alexei Svitkine (slow) 2016/05/13 18:37:13 Should we make this return false when platform is
gayane -on leave until 09-2017 2016/05/13 19:17:02 Done.
34 std::string enabled = variations::GetVariationParamValue(
35 "UMA_EnableCellularLogUpload", "Enabled");
36 std::string optimized = variations::GetVariationParamValue(
37 "UMA_EnableCellularLogUpload", "Optimize");
38 bool is_enabled;
39 if (enabled.empty())
40 is_enabled = kDefaultCellularLogicEnabled;
41 else
42 is_enabled = enabled == "true";
Alexei Svitkine (slow) 2016/05/13 18:37:13 Nit: How about this structure: bool is_enabled =
gayane -on leave until 09-2017 2016/05/13 19:17:01 Done.
43
44 bool is_optimized;
45 if (optimized.empty())
46 is_optimized = kDefaultCellularLogicOptimization;
47 else
48 is_optimized = optimized == "true";
49
50 if (!is_enabled || !is_optimized)
51 return false;
52
53 return net::NetworkChangeNotifier::IsConnectionCellular(
54 net::NetworkChangeNotifier::GetConnectionType());
55 }
56 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698