1 // Copyright 2016 The Chromium Authors 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/time/time.h" 8 #include "build/build_config.h" 9 #include "build/chromeos_buildflags.h" 10 #include "net/base/network_change_notifier.h" 11 12 namespace metrics { 13 14 namespace { 15 16 #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) 17 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. 18 #else 19 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. 20 #endif 21 22 // Android-only cellular settings. 23 #if BUILDFLAG(IS_ANDROID) 24 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. 25 #endif 26 27 } // namespace 28 GetUploadInterval(bool use_cellular_upload_interval)29base::TimeDelta GetUploadInterval(bool use_cellular_upload_interval) { 30 #if BUILDFLAG(IS_ANDROID) 31 if (use_cellular_upload_interval) 32 return base::Seconds(kStandardUploadIntervalCellularSeconds); 33 #endif 34 return base::Seconds(kStandardUploadIntervalSeconds); 35 } 36 ShouldUseCellularUploadInterval()37bool ShouldUseCellularUploadInterval() { 38 #if BUILDFLAG(IS_ANDROID) 39 return net::NetworkChangeNotifier::IsConnectionCellular( 40 net::NetworkChangeNotifier::GetConnectionType()); 41 #else 42 return false; 43 #endif 44 } 45 46 } // namespace metrics 47