OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/threading/thread_restrictions.h" |
13 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 | 17 |
17 // static | 18 // static |
18 int SysInfo::NumberOfProcessors() { | 19 int SysInfo::NumberOfProcessors() { |
19 return win::OSInfo::GetInstance()->processors(); | 20 return win::OSInfo::GetInstance()->processors(); |
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 FilePath& path) { | 39 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
| 40 base::ThreadRestrictions::AssertIOAllowed(); |
| 41 |
39 ULARGE_INTEGER available, total, free; | 42 ULARGE_INTEGER available, total, free; |
40 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) { | 43 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) { |
41 return -1; | 44 return -1; |
42 } | 45 } |
43 int64 rv = static_cast<int64>(available.QuadPart); | 46 int64 rv = static_cast<int64>(available.QuadPart); |
44 if (rv < 0) | 47 if (rv < 0) |
45 rv = kint64max; | 48 rv = kint64max; |
46 return rv; | 49 return rv; |
47 } | 50 } |
48 | 51 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, | 88 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
86 int32* minor_version, | 89 int32* minor_version, |
87 int32* bugfix_version) { | 90 int32* bugfix_version) { |
88 win::OSInfo* os_info = win::OSInfo::GetInstance(); | 91 win::OSInfo* os_info = win::OSInfo::GetInstance(); |
89 *major_version = os_info->version_number().major; | 92 *major_version = os_info->version_number().major; |
90 *minor_version = os_info->version_number().minor; | 93 *minor_version = os_info->version_number().minor; |
91 *bugfix_version = 0; | 94 *bugfix_version = 0; |
92 } | 95 } |
93 | 96 |
94 } // namespace base | 97 } // namespace base |
OLD | NEW |