| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 | 15 |
| 15 // static | 16 // static |
| 16 int SysInfo::NumberOfProcessors() { | 17 int SysInfo::NumberOfProcessors() { |
| 17 SYSTEM_INFO info; | 18 SYSTEM_INFO info; |
| 18 GetSystemInfo(&info); | 19 GetSystemInfo(&info); |
| 19 return static_cast<int>(info.dwNumberOfProcessors); | 20 return static_cast<int>(info.dwNumberOfProcessors); |
| 20 } | 21 } |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 int64 SysInfo::AmountOfPhysicalMemory() { | 24 int64 SysInfo::AmountOfPhysicalMemory() { |
| 24 MEMORYSTATUSEX memory_info; | 25 MEMORYSTATUSEX memory_info; |
| 25 memory_info.dwLength = sizeof(memory_info); | 26 memory_info.dwLength = sizeof(memory_info); |
| 26 if (!GlobalMemoryStatusEx(&memory_info)) { | 27 if (!GlobalMemoryStatusEx(&memory_info)) { |
| 27 NOTREACHED(); | 28 NOTREACHED(); |
| 28 return 0; | 29 return 0; |
| 29 } | 30 } |
| 30 | 31 |
| 31 int64 rv = static_cast<int64>(memory_info.ullTotalPhys); | 32 int64 rv = static_cast<int64>(memory_info.ullTotalPhys); |
| 32 if (rv < 0) | 33 if (rv < 0) |
| 33 rv = kint64max; | 34 rv = kint64max; |
| 34 return rv; | 35 return rv; |
| 35 } | 36 } |
| 36 | 37 |
| 37 // static | 38 // static |
| 38 int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) { | 39 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
| 39 ULARGE_INTEGER available, total, free; | 40 ULARGE_INTEGER available, total, free; |
| 40 if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) { | 41 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) { |
| 41 return -1; | 42 return -1; |
| 42 } | 43 } |
| 43 int64 rv = static_cast<int64>(available.QuadPart); | 44 int64 rv = static_cast<int64>(available.QuadPart); |
| 44 if (rv < 0) | 45 if (rv < 0) |
| 45 rv = kint64max; | 46 rv = kint64max; |
| 46 return rv; | 47 return rv; |
| 47 } | 48 } |
| 48 | 49 |
| 49 // static | 50 // static |
| 50 bool SysInfo::HasEnvVar(const wchar_t* var) { | 51 bool SysInfo::HasEnvVar(const wchar_t* var) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 int32 *bugfix_version) { | 115 int32 *bugfix_version) { |
| 115 OSVERSIONINFO info = {0}; | 116 OSVERSIONINFO info = {0}; |
| 116 info.dwOSVersionInfoSize = sizeof(info); | 117 info.dwOSVersionInfoSize = sizeof(info); |
| 117 GetVersionEx(&info); | 118 GetVersionEx(&info); |
| 118 *major_version = info.dwMajorVersion; | 119 *major_version = info.dwMajorVersion; |
| 119 *minor_version = info.dwMinorVersion; | 120 *minor_version = info.dwMinorVersion; |
| 120 *bugfix_version = 0; | 121 *bugfix_version = 0; |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace base | 124 } // namespace base |
| OLD | NEW |