summaryrefslogtreecommitdiffstats
path: root/base/win/windows_version.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/win/windows_version.cc')
-rw-r--r--base/win/windows_version.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc
index 8dc2d93..5779074 100644
--- a/base/win/windows_version.cc
+++ b/base/win/windows_version.cc
@@ -13,7 +13,18 @@ namespace win {
// static
OSInfo* OSInfo::GetInstance() {
- return Singleton<OSInfo>::get();
+ // Note: we don't use the Singleton class because it depends on AtExitManager,
+ // and it's convenient for other modules to use this classs without it. This
+ // pattern is copied from gurl.cc.
+ static OSInfo* info;
+ if (!info) {
+ OSInfo* new_info = new OSInfo();
+ if (InterlockedCompareExchangePointer(
+ reinterpret_cast<PVOID*>(&info), new_info, NULL)) {
+ delete new_info;
+ }
+ }
+ return info;
}
OSInfo::OSInfo()