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

Unified Diff: base/sys_info_win.cc

Issue 6713107: Make the windows_version.h functions threadsafe by using a singleton. (Closed) Base URL: svn://chrome-svn/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/sys_info_mac.cc ('k') | base/win/windows_version.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_win.cc
===================================================================
--- base/sys_info_win.cc (revision 80667)
+++ base/sys_info_win.cc (working copy)
@@ -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 @@
// 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 @@
// 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;
}
« 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