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 "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 const bool kDefaultCellularLogicEnabled = true; | |
| 23 const bool kDefaultCellularLogicOptimization = true; | |
| 24 } | |
|
Alexei Svitkine (slow)
2016/05/13 20:21:09
Nit: Add // namespace
Also, an empty line above i
gayane -on leave until 09-2017
2016/05/13 20:43:00
Done.
| |
| 25 | |
| 26 base::TimeDelta GetUploadInterval() { | |
| 27 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 28 if (IsCellularLogicEnabled()) | |
| 29 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds); | |
| 30 #endif | |
| 31 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); | |
| 32 } | |
| 33 | |
| 34 // Returns true if current connection type is cellular and user is assigned to | |
| 35 // experimental group for enabled cellular uploads. | |
| 36 bool IsCellularLogicEnabled() { | |
| 37 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 38 return false; | |
| 39 #endif | |
|
Alexei Svitkine (slow)
2016/05/13 20:21:09
I think you need an #else here else compiler may w
gayane -on leave until 09-2017
2016/05/13 20:43:00
Done.
| |
| 40 | |
| 41 std::string enabled = variations::GetVariationParamValue( | |
| 42 "UMA_EnableCellularLogUpload", "Enabled"); | |
| 43 std::string optimized = variations::GetVariationParamValue( | |
| 44 "UMA_EnableCellularLogUpload", "Optimize"); | |
| 45 bool is_enabled = kDefaultCellularLogicEnabled; | |
| 46 if (!enabled.empty()) | |
| 47 is_enabled = (enabled == "true"); | |
| 48 | |
| 49 bool is_optimized = kDefaultCellularLogicOptimization; | |
| 50 if (!optimized.empty()) | |
| 51 is_optimized = (optimized == "true"); | |
| 52 | |
| 53 if (!is_enabled || !is_optimized) | |
| 54 return false; | |
| 55 | |
| 56 return net::NetworkChangeNotifier::IsConnectionCellular( | |
| 57 net::NetworkChangeNotifier::GetConnectionType()); | |
| 58 } | |
| 59 | |
| 60 } // namespace metrics | |
| OLD | NEW |