| OLD | NEW |
| (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 |
| OLD | NEW |