Add git cl format presubmit warning for extension and apps.
[chromium-blink-merge.git] / base / win / windows_version.h
blobe51840b0db8bb2d8bf62d6a36a450fc0afff6eb1
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_WIN_WINDOWS_VERSION_H_
6 #define BASE_WIN_WINDOWS_VERSION_H_
8 #include <string>
10 #include "base/base_export.h"
11 #include "base/basictypes.h"
13 typedef void* HANDLE;
15 namespace base {
16 namespace win {
18 // The running version of Windows. This is declared outside OSInfo for
19 // syntactic sugar reasons; see the declaration of GetVersion() below.
20 // NOTE: Keep these in order so callers can do things like
21 // "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...".
22 enum Version {
23 VERSION_PRE_XP = 0, // Not supported.
24 VERSION_XP,
25 VERSION_SERVER_2003, // Also includes XP Pro x64 and Server 2003 R2.
26 VERSION_VISTA, // Also includes Windows Server 2008.
27 VERSION_WIN7, // Also includes Windows Server 2008 R2.
28 VERSION_WIN8, // Also includes Windows Server 2012.
29 VERSION_WIN8_1, // Code named Windows Blue
30 VERSION_WIN_LAST, // Indicates error condition.
33 // A rough bucketing of the available types of versions of Windows. This is used
34 // to distinguish enterprise enabled versions from home versions and potentially
35 // server versions.
36 enum VersionType {
37 SUITE_HOME,
38 SUITE_PROFESSIONAL,
39 SUITE_SERVER,
40 SUITE_LAST,
43 // A singleton that can be used to query various pieces of information about the
44 // OS and process state. Note that this doesn't use the base Singleton class, so
45 // it can be used without an AtExitManager.
46 class BASE_EXPORT OSInfo {
47 public:
48 struct VersionNumber {
49 int major;
50 int minor;
51 int build;
54 struct ServicePack {
55 int major;
56 int minor;
59 // The processor architecture this copy of Windows natively uses. For
60 // example, given an x64-capable processor, we have three possibilities:
61 // 32-bit Chrome running on 32-bit Windows: X86_ARCHITECTURE
62 // 32-bit Chrome running on 64-bit Windows via WOW64: X64_ARCHITECTURE
63 // 64-bit Chrome running on 64-bit Windows: X64_ARCHITECTURE
64 enum WindowsArchitecture {
65 X86_ARCHITECTURE,
66 X64_ARCHITECTURE,
67 IA64_ARCHITECTURE,
68 OTHER_ARCHITECTURE,
71 // Whether a process is running under WOW64 (the wrapper that allows 32-bit
72 // processes to run on 64-bit versions of Windows). This will return
73 // WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit
74 // Chrome on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g.
75 // the process does not have sufficient access rights to determine this.
76 enum WOW64Status {
77 WOW64_DISABLED,
78 WOW64_ENABLED,
79 WOW64_UNKNOWN,
82 static OSInfo* GetInstance();
84 Version version() const { return version_; }
85 // The next two functions return arrays of values, [major, minor(, build)].
86 VersionNumber version_number() const { return version_number_; }
87 VersionType version_type() const { return version_type_; }
88 ServicePack service_pack() const { return service_pack_; }
89 WindowsArchitecture architecture() const { return architecture_; }
90 int processors() const { return processors_; }
91 size_t allocation_granularity() const { return allocation_granularity_; }
92 WOW64Status wow64_status() const { return wow64_status_; }
93 std::string processor_model_name();
95 // Like wow64_status(), but for the supplied handle instead of the current
96 // process. This doesn't touch member state, so you can bypass the singleton.
97 static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
99 private:
100 OSInfo();
101 ~OSInfo();
103 Version version_;
104 VersionNumber version_number_;
105 VersionType version_type_;
106 ServicePack service_pack_;
107 WindowsArchitecture architecture_;
108 int processors_;
109 size_t allocation_granularity_;
110 WOW64Status wow64_status_;
111 std::string processor_model_name_;
113 DISALLOW_COPY_AND_ASSIGN(OSInfo);
116 // Because this is by far the most commonly-requested value from the above
117 // singleton, we add a global-scope accessor here as syntactic sugar.
118 BASE_EXPORT Version GetVersion();
120 } // namespace win
121 } // namespace base
123 #endif // BASE_WIN_WINDOWS_VERSION_H_