Chromium Code Reviews| Index: base/sys_info_win.cc |
| diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc |
| index af0ce7e6d8ef1c0c8effef4f4bb609851d78d515..1d15b62669810c70e3320b486398d6406439a6a0 100644 |
| --- a/base/sys_info_win.cc |
| +++ b/base/sys_info_win.cc |
| @@ -13,15 +13,9 @@ |
| #include "base/threading/thread_restrictions.h" |
| #include "base/win/windows_version.h" |
| -namespace base { |
| - |
| -// static |
| -int SysInfo::NumberOfProcessors() { |
| - return win::OSInfo::GetInstance()->processors(); |
| -} |
| +namespace { |
| -// static |
| -int64 SysInfo::AmountOfPhysicalMemory() { |
| +int64 AmountOfMemory(DWORDLONG MEMORYSTATUSEX::* memory_field) { |
|
Mark Mentovai
2013/04/09 22:14:21
It’s unusual in Chrome code, but I can’t find a re
mdempsky_google
2013/04/09 23:06:32
Exactly how I felt about it then. ;)
|
| MEMORYSTATUSEX memory_info; |
| memory_info.dwLength = sizeof(memory_info); |
| if (!GlobalMemoryStatusEx(&memory_info)) { |
| @@ -29,25 +23,29 @@ int64 SysInfo::AmountOfPhysicalMemory() { |
| return 0; |
| } |
| - int64 rv = static_cast<int64>(memory_info.ullTotalPhys); |
| + int64 rv = static_cast<int64>(memory_info.*memory_field); |
| if (rv < 0) |
| rv = kint64max; |
| return rv; |
| } |
| +} // namespace |
| + |
| +namespace base { |
| + |
| // static |
| -int64 SysInfo::AmountOfAvailablePhysicalMemory() { |
| - MEMORYSTATUSEX memory_info; |
| - memory_info.dwLength = sizeof(memory_info); |
| - if (!GlobalMemoryStatusEx(&memory_info)) { |
| - NOTREACHED(); |
| - return 0; |
| - } |
| +int SysInfo::NumberOfProcessors() { |
| + return win::OSInfo::GetInstance()->processors(); |
| +} |
| - int64 rv = static_cast<int64>(memory_info.ullAvailPhys); |
| - if (rv < 0) |
| - rv = kint64max; |
| - return rv; |
| +// static |
| +int64 SysInfo::AmountOfPhysicalMemory() { |
| + return AmountOfMemory(&MEMORYSTATUSEX::ullTotalPhys); |
| +} |
| + |
| +// static |
| +int64 SysInfo::AmountOfAvailablePhysicalMemory() { |
| + return AmountOfMemory(&MEMORYSTATUSEX::ullAvailPhys); |
| } |
| // static |