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

Side by Side Diff: base/sys_info_win.cc

Issue 6816024: Revert 80819 due to failed tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/sys_info_mac.cc ('k') | base/win/windows_version.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/win/windows_version.h"
14 13
15 namespace base { 14 namespace base {
16 15
17 // static 16 // static
18 int SysInfo::NumberOfProcessors() { 17 int SysInfo::NumberOfProcessors() {
19 return win::OSInfo::GetInstance()->processors(); 18 SYSTEM_INFO info;
19 GetSystemInfo(&info);
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 }
(...skipping 16 matching lines...) Expand all
46 return rv; 47 return rv;
47 } 48 }
48 49
49 // static 50 // static
50 std::string SysInfo::OperatingSystemName() { 51 std::string SysInfo::OperatingSystemName() {
51 return "Windows NT"; 52 return "Windows NT";
52 } 53 }
53 54
54 // static 55 // static
55 std::string SysInfo::OperatingSystemVersion() { 56 std::string SysInfo::OperatingSystemVersion() {
56 win::OSInfo* os_info = win::OSInfo::GetInstance(); 57 OSVERSIONINFO info = {0};
57 win::OSInfo::VersionNumber version_number = os_info->version_number(); 58 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
58 std::string version(StringPrintf("%d.%d", version_number.major, 59 GetVersionEx(&info);
59 version_number.minor)); 60
60 win::OSInfo::ServicePack service_pack = os_info->service_pack(); 61 return base::StringPrintf("%lu.%lu",
61 if (service_pack.major != 0) { 62 info.dwMajorVersion, info.dwMinorVersion);
62 version += StringPrintf(" SP%d", service_pack.major);
63 if (service_pack.minor != 0)
64 version += StringPrintf(".%d", service_pack.minor);
65 }
66 return version;
67 } 63 }
68 64
69 // TODO: Implement OperatingSystemVersionComplete, which would include 65 // TODO: Implement OperatingSystemVersionComplete, which would include
70 // patchlevel/service pack number. 66 // patchlevel/service pack number.
71 // See chrome/browser/ui/views/bug_report_view.cc, BugReportView::SetOSVersion. 67 // See chrome/browser/ui/views/bug_report_view.cc, BugReportView::SetOSVersion.
72 68
73 // static 69 // static
74 std::string SysInfo::CPUArchitecture() { 70 std::string SysInfo::CPUArchitecture() {
75 // TODO: Make this vary when we support any other architectures. 71 // TODO: Make this vary when we support any other architectures.
76 return "x86"; 72 return "x86";
77 } 73 }
78 74
79 // static 75 // static
80 void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { 76 void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) {
81 if (width) 77 if (width)
82 *width = GetSystemMetrics(SM_CXSCREEN); 78 *width = GetSystemMetrics(SM_CXSCREEN);
83 79
84 if (height) 80 if (height)
85 *height = GetSystemMetrics(SM_CYSCREEN); 81 *height = GetSystemMetrics(SM_CYSCREEN);
86 } 82 }
87 83
88 // static 84 // static
89 int SysInfo::DisplayCount() { 85 int SysInfo::DisplayCount() {
90 return GetSystemMetrics(SM_CMONITORS); 86 return GetSystemMetrics(SM_CMONITORS);
91 } 87 }
92 88
93 // static 89 // static
94 size_t SysInfo::VMAllocationGranularity() { 90 size_t SysInfo::VMAllocationGranularity() {
95 return win::OSInfo::GetInstance()->allocation_granularity(); 91 SYSTEM_INFO sysinfo;
92 GetSystemInfo(&sysinfo);
93
94 return sysinfo.dwAllocationGranularity;
96 } 95 }
97 96
98 // static 97 // static
99 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, 98 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
100 int32* minor_version, 99 int32 *minor_version,
101 int32* bugfix_version) { 100 int32 *bugfix_version) {
102 win::OSInfo* os_info = win::OSInfo::GetInstance(); 101 OSVERSIONINFO info = {0};
103 *major_version = os_info->version_number().major; 102 info.dwOSVersionInfoSize = sizeof(info);
104 *minor_version = os_info->version_number().minor; 103 GetVersionEx(&info);
104 *major_version = info.dwMajorVersion;
105 *minor_version = info.dwMinorVersion;
105 *bugfix_version = 0; 106 *bugfix_version = 0;
106 } 107 }
107 108
108 } // namespace base 109 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info_mac.cc ('k') | base/win/windows_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698