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

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: fix build presubmit warning 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 namespace {
13
14 // Standard interval between log uploads, in seconds.
15 #if defined(OS_ANDROID) || defined(OS_IOS)
16 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes.
17 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes.
18 #else
19 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes.
20 #endif
21
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
29
30 } // namespace
31
32 base::TimeDelta GetUploadInterval() {
33 #if defined(OS_ANDROID) || defined(OS_IOS)
34 if (IsCellularLogicEnabled())
35 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds);
36 #endif
37 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
38 }
39
40 // Returns true if current connection type is cellular and user is assigned to
41 // experimental group for enabled cellular uploads.
42 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(
59 net::NetworkChangeNotifier::GetConnectionType());
60 }
61
62 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/net/cellular_logic_helper.h ('k') | ios/chrome/browser/metrics/ios_chrome_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698