Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1867)

Unified Diff: base/sys_info_win.cc

Issue 13945012: Implement missing SysInfo methods on OpenBSD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test sysctl() < 0 instead of == -1 Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/sys_info_openbsd.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
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
« no previous file with comments | « base/sys_info_openbsd.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698