Chromium Code Reviews| Index: base/sys_info_posix.cc |
| diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc |
| index 07d08b72bbcb51fd8e550ab79409c55c6dff9af4..f480f324af1054707dd4c3e6fe8eb4ced19b58b6 100644 |
| --- a/base/sys_info_posix.cc |
| +++ b/base/sys_info_posix.cc |
| @@ -7,6 +7,7 @@ |
| #include <errno.h> |
| #include <string.h> |
| #include <sys/param.h> |
| +#include <sys/resource.h> |
| #include <sys/utsname.h> |
| #include <unistd.h> |
| @@ -45,6 +46,17 @@ base::LazyInstance< |
| g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER; |
| #endif |
| +int64 AmountOfVirtualMemory() { |
| + struct rlimit limit; |
| + int result = getrlimit(RLIMIT_DATA, &limit); |
| + if (result != 0) return 0; |
|
Mark Mentovai
2014/04/08 18:49:57
It’s a little weird to use 0 for both the failure
jochen (gone - plz use gerrit)
2014/04/08 19:26:31
this call should never fail. I can add NOTREACHED(
|
| + return limit.rlim_cur == RLIM_INFINITY ? 0 : limit.rlim_cur; |
| +} |
| + |
| +base::LazyInstance< |
| + base::internal::LazySysInfoValue<int64, AmountOfVirtualMemory> >::Leaky |
| + g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER; |
| + |
| } // namespace |
| namespace base { |
| @@ -56,6 +68,11 @@ int SysInfo::NumberOfProcessors() { |
| #endif |
| // static |
| +int64 SysInfo::AmountOfVirtualMemory() { |
| + return g_lazy_virtual_memory.Get().value(); |
| +} |
| + |
| +// static |
| int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
| base::ThreadRestrictions::AssertIOAllowed(); |