Chromium Code Reviews| 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 "base/metrics/field_trial.h" | |
| 8 #include "components/variations/variations_associated_data.h" | |
| 9 #include "net/base/network_change_notifier.h" | |
| 10 | |
| 11 namespace metrics { | |
| 12 | |
| 13 // Standard interval between log uploads, in seconds. | |
| 14 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 15 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. | |
| 16 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. | |
| 17 #else | |
| 18 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. | |
| 19 #endif | |
| 20 | |
| 21 const bool kDefaultCellularLogicEnabled = true; | |
| 22 const bool kDefaultCellularLogicOptimization = true; | |
| 23 | |
| 24 base::TimeDelta GetUploadInterval() { | |
| 25 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 26 if (IsCellularLogicEnabled()) | |
| 27 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds); | |
| 28 #endif | |
| 29 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); | |
| 30 } | |
| 31 | |
| 32 // Returns true if current connection type is cellular and user is assigned to | |
| 33 // experimental group for enabled cellular uploads. | |
| 34 bool IsCellularLogicEnabled() { | |
| 35 if (base::FieldTrialList::FindFullName("UMA_EnableCellularLogUpload").empty()) | |
| 36 return false; | |
|
Alexei Svitkine (slow)
2016/05/13 15:53:59
I think we want to default to the new behavior whe
gayane -on leave until 09-2017
2016/05/13 18:33:15
Done.
| |
| 37 | |
| 38 std::string enabled = variations::GetVariationParamValue( | |
| 39 "UMA_EnableCellularLogUpload", "Enabled"); | |
| 40 std::string optimized = variations::GetVariationParamValue( | |
| 41 "UMA_EnableCellularLogUpload", "Optimize"); | |
| 42 bool is_enabled; | |
| 43 if (enabled.empty()) | |
| 44 is_enabled = kDefaultCellularLogicEnabled; | |
| 45 else | |
| 46 is_enabled = enabled == "true"; | |
| 47 | |
| 48 bool is_optimized; | |
| 49 if (optimized.empty()) | |
| 50 is_optimized = kDefaultCellularLogicOptimization; | |
| 51 else | |
| 52 is_optimized = optimized == "true"; | |
| 53 | |
| 54 if (!is_enabled || !is_optimized) | |
| 55 return false; | |
| 56 | |
| 57 return net::NetworkChangeNotifier::IsConnectionCellular( | |
| 58 net::NetworkChangeNotifier::GetConnectionType()); | |
| 59 } | |
| 60 } | |
|
Alexei Svitkine (slow)
2016/05/13 15:53:59
Nit: Add // namespace metrics and an empty line ab
gayane -on leave until 09-2017
2016/05/13 18:33:15
Done.
| |
| OLD | NEW |