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

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, 9 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.h ('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 79219)
+++ base/sys_info_win.cc (working copy)
@@ -95,14 +95,21 @@
}
// 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) {
+ static bool checked_version = false;
+ static int32 major = 0, minor = 0;
+ if (!checked_version) {
brettw 2011/03/24 20:19:03 This makes this function no longer thread safe. I
Peter Kasting 2011/03/24 20:59:02 Good point. The reason I did this is because rvar
brettw 2011/03/24 23:47:37 You're more expert on the compilers here than I am
Peter Kasting 2011/03/25 00:39:19 volatile isn't what you want, that means "can be c
+ checked_version = true;
+ OSVERSIONINFO info = {0};
+ info.dwOSVersionInfoSize = sizeof(info);
+ GetVersionEx(&info);
+ major = info.dwMajorVersion;
+ minor = info.dwMinorVersion;
+ }
+ *major_version = major;
+ *minor_version = minor;
*bugfix_version = 0;
}
« no previous file with comments | « base/sys_info.h ('k') | base/win/windows_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698