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

Side by Side Diff: base/win/windows_version.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 unified diff | Download patch | Annotate | Revision Log
« base/sys_info_win.cc ('K') | « base/win/windows_version.h ('k') | no next file » | 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/win/windows_version.h" 5 #include "base/win/windows_version.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 16 matching lines...) Expand all
27 win_version = VERSION_XP; 27 win_version = VERSION_XP;
28 break; 28 break;
29 case 2: 29 case 2:
30 default: 30 default:
31 win_version = VERSION_SERVER_2003; 31 win_version = VERSION_SERVER_2003;
32 break; 32 break;
33 } 33 }
34 } else if (version_info.dwMajorVersion == 6) { 34 } else if (version_info.dwMajorVersion == 6) {
35 if (version_info.wProductType != VER_NT_WORKSTATION) { 35 if (version_info.wProductType != VER_NT_WORKSTATION) {
36 // 2008 is 6.0, and 2008 R2 is 6.1. 36 // 2008 is 6.0, and 2008 R2 is 6.1.
37 win_version = VERSION_2008; 37 win_version = VERSION_SERVER_2008;
38 } else { 38 } else {
39 if (version_info.dwMinorVersion == 0) { 39 if (version_info.dwMinorVersion == 0) {
40 win_version = VERSION_VISTA; 40 win_version = VERSION_VISTA;
41 } else { 41 } else {
42 win_version = VERSION_WIN7; 42 win_version = VERSION_WIN7;
43 } 43 }
44 } 44 }
45 } else if (version_info.dwMajorVersion > 6) { 45 } else if (version_info.dwMajorVersion > 6) {
46 win_version = VERSION_WIN7; 46 win_version = VERSION_WIN7;
47 } 47 }
(...skipping 14 matching lines...) Expand all
62 service_pack_major = version_info.wServicePackMajor; 62 service_pack_major = version_info.wServicePackMajor;
63 service_pack_minor = version_info.wServicePackMinor; 63 service_pack_minor = version_info.wServicePackMinor;
64 checked_version = true; 64 checked_version = true;
65 } 65 }
66 66
67 *major = service_pack_major; 67 *major = service_pack_major;
68 *minor = service_pack_minor; 68 *minor = service_pack_minor;
69 } 69 }
70 70
71 WindowsArchitecture GetWindowsArchitecture() { 71 WindowsArchitecture GetWindowsArchitecture() {
72 SYSTEM_INFO system_info; 72 SYSTEM_INFO system_info = {0};
73 GetNativeSystemInfo(&system_info); 73 GetNativeSystemInfo(&system_info);
74 switch (system_info.wProcessorArchitecture) { 74 switch (system_info.wProcessorArchitecture) {
75 case PROCESSOR_ARCHITECTURE_INTEL: return X86_ARCHITECTURE; 75 case PROCESSOR_ARCHITECTURE_INTEL: return X86_ARCHITECTURE;
76 case PROCESSOR_ARCHITECTURE_AMD64: return X64_ARCHITECTURE; 76 case PROCESSOR_ARCHITECTURE_AMD64: return X64_ARCHITECTURE;
77 case PROCESSOR_ARCHITECTURE_IA64: return IA64_ARCHITECTURE; 77 case PROCESSOR_ARCHITECTURE_IA64: return IA64_ARCHITECTURE;
78 default: return OTHER_ARCHITECTURE; 78 default: return OTHER_ARCHITECTURE;
79 } 79 }
80 } 80 }
81 81
82 WOW64Status GetWOW64Status() { 82 WOW64Status GetWOW64Status() {
83 static WOW64Status wow64_status = 83 static WOW64Status wow64_status =
84 GetWOW64StatusForProcess(GetCurrentProcess()); 84 GetWOW64StatusForProcess(GetCurrentProcess());
85 return wow64_status; 85 return wow64_status;
86 } 86 }
87 87
88 WOW64Status GetWOW64StatusForProcess(HANDLE process_handle) { 88 WOW64Status GetWOW64StatusForProcess(HANDLE process_handle) {
89 typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL); 89 typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL);
90 IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>( 90 IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>(
91 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process")); 91 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process"));
92 if (!is_wow64_process) 92 if (!is_wow64_process)
93 return WOW64_DISABLED; 93 return WOW64_DISABLED;
94 BOOL is_wow64 = FALSE; 94 BOOL is_wow64 = FALSE;
95 if (!(*is_wow64_process)(process_handle, &is_wow64)) 95 if (!(*is_wow64_process)(process_handle, &is_wow64))
96 return WOW64_UNKNOWN; 96 return WOW64_UNKNOWN;
97 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; 97 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED;
98 } 98 }
99 99
100 } // namespace win 100 } // namespace win
101 } // namespace base 101 } // namespace base
OLDNEW
« base/sys_info_win.cc ('K') | « base/win/windows_version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698