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

Side by Side Diff: base/win/windows_version.h

Issue 6816024: Revert 80819 due to failed tests (Closed) Base URL: svn://svn.chromium.org/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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/sys_info_win.cc ('k') | base/win/windows_version.cc » ('j') | 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 #ifndef BASE_WIN_WINDOWS_VERSION_H_ 5 #ifndef BASE_WIN_WINDOWS_VERSION_H_
6 #define BASE_WIN_WINDOWS_VERSION_H_ 6 #define BASE_WIN_WINDOWS_VERSION_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h" 9 #include "base/base_api.h"
10 #include "base/memory/singleton.h"
11 10
12 typedef void* HANDLE; 11 typedef void* HANDLE;
13 12
14 namespace base { 13 namespace base {
15 namespace win { 14 namespace win {
16 15
17 // The running version of Windows. This is declared outside OSInfo for
18 // syntactic sugar reasons; see the declaration of GetVersion() below.
19 // NOTE: Keep these in order so callers can do things like 16 // NOTE: Keep these in order so callers can do things like
20 // "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...". 17 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values,
18 // though.
21 enum Version { 19 enum Version {
22 VERSION_PRE_XP = 0, // Not supported. 20 VERSION_PRE_2000 = 0, // Not supported
23 VERSION_XP, 21 VERSION_2000 = 1, // Not supported
24 VERSION_SERVER_2003, // Also includes Windows XP Professional x64. 22 VERSION_XP = 2,
25 VERSION_VISTA, 23 VERSION_SERVER_2003 = 3, // Also includes Windows XP Professional x64 edition
26 VERSION_SERVER_2008, 24 VERSION_VISTA = 4,
27 VERSION_WIN7, 25 VERSION_2008 = 5,
26 VERSION_WIN7 = 6,
28 }; 27 };
29 28
30 // A Singleton that can be used to query various pieces of information about the 29 // Returns the running version of Windows.
31 // OS and process state. 30 BASE_API Version GetVersion();
32 class BASE_API OSInfo {
33 public:
34 struct VersionNumber {
35 int major;
36 int minor;
37 int build;
38 };
39 31
40 struct ServicePack { 32 // Returns the major and minor version of the service pack installed.
41 int major; 33 BASE_API void GetServicePackLevel(int* major, int* minor);
42 int minor;
43 };
44 34
45 // The processor architecture this copy of Windows natively uses. For 35 enum WindowsArchitecture {
46 // example, given an x64-capable processor, we have three possibilities: 36 X86_ARCHITECTURE,
47 // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE 37 X64_ARCHITECTURE,
48 // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE 38 IA64_ARCHITECTURE,
49 // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE 39 OTHER_ARCHITECTURE,
50 enum WindowsArchitecture {
51 X86_ARCHITECTURE,
52 X64_ARCHITECTURE,
53 IA64_ARCHITECTURE,
54 OTHER_ARCHITECTURE,
55 };
56
57 // Whether a process is running under WOW64 (the wrapper that allows 32-bit
58 // processes to run on 64-bit versions of Windows). This will return
59 // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit
60 // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g.
61 // the process does not have sufficient access rights to determine this.
62 enum WOW64Status {
63 WOW64_DISABLED,
64 WOW64_ENABLED,
65 WOW64_UNKNOWN,
66 };
67
68 static OSInfo* GetInstance();
69
70 Version version() const { return version_; }
71 // The next two functions return arrays of values, [major, minor(, build)].
72 VersionNumber version_number() const { return version_number_; }
73 ServicePack service_pack() const { return service_pack_; }
74 WindowsArchitecture architecture() const { return architecture_; }
75 int processors() const { return processors_; }
76 size_t allocation_granularity() const { return allocation_granularity_; }
77 WOW64Status wow64_status() const { return wow64_status_; }
78
79 // Like wow64_status(), but for the supplied handle instead of the current
80 // process. This doesn't touch member state, so you can bypass the singleton.
81 static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
82
83 private:
84 OSInfo();
85 ~OSInfo();
86
87 Version version_;
88 VersionNumber version_number_;
89 ServicePack service_pack_;
90 WindowsArchitecture architecture_;
91 int processors_;
92 size_t allocation_granularity_;
93 WOW64Status wow64_status_;
94
95 friend struct DefaultSingletonTraits<OSInfo>;
96 DISALLOW_COPY_AND_ASSIGN(OSInfo);
97 }; 40 };
98 41
99 // Because this is by far the most commonly-requested value from the above 42 // Returns the processor architecture this copy of Windows natively uses.
100 // singleton, we add a global-scope accessor here as syntactic sugar. 43 // For example, given an x64-capable processor, we have three possibilities:
101 BASE_API Version GetVersion(); 44 // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE
45 // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE
46 // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE
47 BASE_API WindowsArchitecture GetWindowsArchitecture();
48
49 enum WOW64Status {
50 WOW64_DISABLED,
51 WOW64_ENABLED,
52 WOW64_UNKNOWN,
53 };
54
55 // Returns whether this process is running under WOW64 (the wrapper that allows
56 // 32-bit processes to run on 64-bit versions of Windows). This will return
57 // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit Chrome
58 // on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g. the
59 // process does not have sufficient access rights to determine this.
60 BASE_API WOW64Status GetWOW64Status();
61
62 // Like GetWOW64Status(), but for the supplied handle instead of the current
63 // process.
64 BASE_API WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
102 65
103 } // namespace win 66 } // namespace win
104 } // namespace base 67 } // namespace base
105 68
106 #endif // BASE_WIN_WINDOWS_VERSION_H_ 69 #endif // BASE_WIN_WINDOWS_VERSION_H_
OLDNEW
« no previous file with comments | « base/sys_info_win.cc ('k') | base/win/windows_version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698