1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/sys_info.h"
9 #include "base/file_path.h"
10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stringprintf.h"
13 #include "base/win/windows_version.h"
18 int SysInfo::NumberOfProcessors() {
19 return win::OSInfo::GetInstance()->processors();
23 int64
SysInfo::AmountOfPhysicalMemory() {
24 MEMORYSTATUSEX memory_info
;
25 memory_info
.dwLength
= sizeof(memory_info
);
26 if (!GlobalMemoryStatusEx(&memory_info
)) {
31 int64 rv
= static_cast<int64
>(memory_info
.ullTotalPhys
);
38 int64
SysInfo::AmountOfFreeDiskSpace(const FilePath
& path
) {
39 ULARGE_INTEGER available
, total
, free
;
40 if (!GetDiskFreeSpaceExW(path
.value().c_str(), &available
, &total
, &free
)) {
43 int64 rv
= static_cast<int64
>(available
.QuadPart
);
50 std::string
SysInfo::OperatingSystemName() {
55 std::string
SysInfo::OperatingSystemVersion() {
56 win::OSInfo
* os_info
= win::OSInfo::GetInstance();
57 win::OSInfo::VersionNumber version_number
= os_info
->version_number();
58 std::string
version(StringPrintf("%d.%d", version_number
.major
,
59 version_number
.minor
));
60 win::OSInfo::ServicePack service_pack
= os_info
->service_pack();
61 if (service_pack
.major
!= 0) {
62 version
+= StringPrintf(" SP%d", service_pack
.major
);
63 if (service_pack
.minor
!= 0)
64 version
+= StringPrintf(".%d", service_pack
.minor
);
69 // TODO: Implement OperatingSystemVersionComplete, which would include
70 // patchlevel/service pack number.
71 // See chrome/browser/ui/views/bug_report_view.cc, BugReportView::SetOSVersion.
74 std::string
SysInfo::CPUArchitecture() {
75 // TODO: Make this vary when we support any other architectures.
80 size_t SysInfo::VMAllocationGranularity() {
81 return win::OSInfo::GetInstance()->allocation_granularity();
85 void SysInfo::OperatingSystemVersionNumbers(int32
* major_version
,
87 int32
* bugfix_version
) {
88 win::OSInfo
* os_info
= win::OSInfo::GetInstance();
89 *major_version
= os_info
->version_number().major
;
90 *minor_version
= os_info
->version_number().minor
;