summaryrefslogtreecommitdiffstats
path: root/base/sys_info_win.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 18:49:09 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 18:49:09 +0000
commit517617476b7231f63b2f900d9dc825db2ee4161d (patch)
treea09d1e81c9796b0859a01dfc467710724046e8ce /base/sys_info_win.cc
parentd91ddfc676314764d240a9ad0da06063bb265d76 (diff)
downloadchromium_src-517617476b7231f63b2f900d9dc825db2ee4161d.zip
chromium_src-517617476b7231f63b2f900d9dc825db2ee4161d.tar.gz
chromium_src-517617476b7231f63b2f900d9dc825db2ee4161d.tar.bz2
Make the windows_version.h functions threadsafe by using a singleton. Add accessors to the singleton for more values that various code wants, then convert almost everyone using OSVERSIONINFO or SYSTEM_INFO structs to calling these accessors. Declare an AtExitManager in the out-of-process test runner since it didn't have one and that breaks singleton-using code in the test executable (as opposed to in chrome.dll).
A few other minor cleanups along the way (binding of "*", shorter code, etc.). Because I ran into problems with it while modifying gcapi.cc, I cleaned up our usage of strsafe.h a bit, so that files that don't need it don't include it and files that do use STRSAFE_NO_DEPRECATE instead of a modified #include order. BUG=none TEST=none Review URL: http://codereview.chromium.org/6713107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_win.cc')
-rw-r--r--base/sys_info_win.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index ce8376a..045d516 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -10,14 +10,13 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/stringprintf.h"
+#include "base/win/windows_version.h"
namespace base {
// static
int SysInfo::NumberOfProcessors() {
- SYSTEM_INFO info;
- GetSystemInfo(&info);
- return static_cast<int>(info.dwNumberOfProcessors);
+ return win::OSInfo::GetInstance()->processors();
}
// static
@@ -54,12 +53,17 @@ std::string SysInfo::OperatingSystemName() {
// static
std::string SysInfo::OperatingSystemVersion() {
- OSVERSIONINFO info = {0};
- info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&info);
-
- return base::StringPrintf("%lu.%lu",
- info.dwMajorVersion, info.dwMinorVersion);
+ win::OSInfo* os_info = win::OSInfo::GetInstance();
+ win::OSInfo::VersionNumber version_number = os_info->version_number();
+ std::string version(StringPrintf("%d.%d", version_number.major,
+ version_number.minor));
+ win::OSInfo::ServicePack service_pack = os_info->service_pack();
+ if (service_pack.major != 0) {
+ version += StringPrintf(" SP%d", service_pack.major);
+ if (service_pack.minor != 0)
+ version += StringPrintf(".%d", service_pack.minor);
+ }
+ return version;
}
// TODO: Implement OperatingSystemVersionComplete, which would include
@@ -88,21 +92,16 @@ int SysInfo::DisplayCount() {
// static
size_t SysInfo::VMAllocationGranularity() {
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
-
- return sysinfo.dwAllocationGranularity;
+ return win::OSInfo::GetInstance()->allocation_granularity();
}
// static
-void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
- int32 *minor_version,
- int32 *bugfix_version) {
- OSVERSIONINFO info = {0};
- info.dwOSVersionInfoSize = sizeof(info);
- GetVersionEx(&info);
- *major_version = info.dwMajorVersion;
- *minor_version = info.dwMinorVersion;
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
+ int32* minor_version,
+ int32* bugfix_version) {
+ win::OSInfo* os_info = win::OSInfo::GetInstance();
+ *major_version = os_info->version_number().major;
+ *minor_version = os_info->version_number().minor;
*bugfix_version = 0;
}