#include "base/system/sys_info.h"
#include <algorithm>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/features.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/notreached.h"
#include "base/system/sys_info_internal.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "build/build_config.h"
namespace base {
namespace {
uint64_t GetLowMemoryDeviceThresholdMB() { … }
std::optional<uint64_t> g_amount_of_physical_memory_mb_for_testing;
}
int SysInfo::NumberOfEfficientProcessors() { … }
uint64_t SysInfo::AmountOfPhysicalMemory() { … }
uint64_t SysInfo::AmountOfAvailablePhysicalMemory() { … }
bool SysInfo::IsLowEndDevice() { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS)
namespace {
enum class BucketizedSize {
k2GbOrLess,
k3Gb,
k4Gb,
k6Gb,
k8GbOrHigher,
};
BucketizedSize GetSystemRamBucketizedSize() {
int physical_memory = base::SysInfo::AmountOfPhysicalMemoryMB();
constexpr int kUpperBound2GB = 2 * 1024;
if (physical_memory <= kUpperBound2GB) {
return BucketizedSize::k2GbOrLess;
}
constexpr int kLowerBound3GB = kUpperBound2GB;
constexpr int kUpperBound3GB = 3.2 * 1024;
if (kLowerBound3GB < physical_memory && physical_memory <= kUpperBound3GB) {
return BucketizedSize::k3Gb;
}
constexpr int kLowerBound4GB = kUpperBound3GB;
constexpr int kUpperBound4GB = 4 * 1024;
if (kLowerBound4GB < physical_memory && physical_memory <= kUpperBound4GB) {
return BucketizedSize::k4Gb;
}
constexpr int kLowerBound6GB = kUpperBound4GB;
constexpr int kUpperBound6GB = 6.5 * 1024 - 1;
if (kLowerBound6GB < physical_memory && physical_memory <= kUpperBound6GB) {
return BucketizedSize::k6Gb;
}
return BucketizedSize::k8GbOrHigher;
}
BucketizedSize GetCachedSystemRamBucketizedSize() {
static BucketizedSize s_size = GetSystemRamBucketizedSize();
return s_size;
}
bool IsPartialLowEndModeOnMidRangeDevicesEnabled() {
return SysInfo::Is4GbOr6GbDevice() &&
base::FeatureList::IsEnabled(
features::kPartialLowEndModeOnMidRangeDevices);
}
bool IsPartialLowEndModeOn3GbDevicesEnabled() {
return SysInfo::Is3GbDevice() &&
base::FeatureList::IsEnabled(features::kPartialLowEndModeOn3GbDevices);
}
}
bool SysInfo::Is3GbDevice() {
return GetCachedSystemRamBucketizedSize() == BucketizedSize::k3Gb;
}
bool SysInfo::Is4GbDevice() {
return GetCachedSystemRamBucketizedSize() == BucketizedSize::k4Gb;
}
bool SysInfo::Is4GbOr6GbDevice() {
return GetCachedSystemRamBucketizedSize() == BucketizedSize::k4Gb ||
GetCachedSystemRamBucketizedSize() == BucketizedSize::k6Gb;
}
bool SysInfo::Is6GbDevice() {
return GetCachedSystemRamBucketizedSize() == BucketizedSize::k6Gb;
}
#endif
bool SysInfo::IsLowEndDeviceOrPartialLowEndModeEnabled() { … }
bool SysInfo::IsLowEndDeviceOrPartialLowEndModeEnabled(
const FeatureParam<bool>& param_for_exclusion) { … }
#if !BUILDFLAG(IS_ANDROID)
bool DetectLowEndDevice() { … }
bool SysInfo::IsLowEndDeviceImpl() { … }
#endif
#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN) && \
!BUILDFLAG(IS_CHROMEOS)
std::string SysInfo::HardwareModelName() { … }
#endif
void SysInfo::GetHardwareInfo(base::OnceCallback<void(HardwareInfo)> callback) { … }
base::TimeDelta SysInfo::Uptime() { … }
std::string SysInfo::ProcessCPUArchitecture() { … }
std::optional<uint64_t> SysInfo::SetAmountOfPhysicalMemoryMbForTesting(
const uint64_t amount_of_memory_mb) { … }
void SysInfo::ClearAmountOfPhysicalMemoryMbForTesting() { … }
}