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

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

Issue 1784623003: Add histograms to compare GetVersionEx() with VerQueryValue() of kernel32 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 14
15 typedef void* HANDLE; 15 typedef void* HANDLE;
16 16
17 namespace base { 17 namespace base {
18 namespace win { 18 namespace win {
19 19
20 // The running version of Windows. This is declared outside OSInfo for 20 // The running version of Windows. This is declared outside OSInfo for
21 // syntactic sugar reasons; see the declaration of GetVersion() below. 21 // syntactic sugar reasons; see the declaration of GetVersion() below. NOTE:
robliao 2016/03/11 17:04:47 Nit: This NOTE should probably still remain on the
scottmg 2016/03/11 22:44:26 Done.
22 // NOTE: Keep these in order so callers can do things like 22 // Keep these in order so callers can do things like "if
robliao 2016/03/11 17:04:47 "if should be on the next line.
scottmg 2016/03/11 22:44:26 Done.
23 // "if (base::win::GetVersion() >= base::win::VERSION_VISTA) ...". 23 // (base::win::GetVersion() >= base::win::VERSION_VISTA) ...".
24 //
25 // This enum is used in metrics histograms, so they shouldn't be reordered or
26 // removed. New values can be added before VERSION_WIN_LAST.
24 enum Version { 27 enum Version {
25 VERSION_PRE_XP = 0, // Not supported. 28 VERSION_PRE_XP = 0, // Not supported.
26 VERSION_XP, 29 VERSION_XP = 1,
27 VERSION_SERVER_2003, // Also includes XP Pro x64 and Server 2003 R2. 30 VERSION_SERVER_2003 = 2, // Also includes XP Pro x64 and Server 2003 R2.
28 VERSION_VISTA, // Also includes Windows Server 2008. 31 VERSION_VISTA = 3, // Also includes Windows Server 2008.
29 VERSION_WIN7, // Also includes Windows Server 2008 R2. 32 VERSION_WIN7 = 4, // Also includes Windows Server 2008 R2.
30 VERSION_WIN8, // Also includes Windows Server 2012. 33 VERSION_WIN8 = 5, // Also includes Windows Server 2012.
31 VERSION_WIN8_1, // Also includes Windows Server 2012 R2. 34 VERSION_WIN8_1 = 6, // Also includes Windows Server 2012 R2.
32 VERSION_WIN10, // Also includes Windows 10 Server. 35 VERSION_WIN10 = 7, // Also includes Windows 10 Server.
33 VERSION_WIN10_TH2, // Threshold 2: Version 1511, Build 10586. 36 VERSION_WIN10_TH2 = 8, // Threshold 2: Version 1511, Build 10586.
34 VERSION_WIN_LAST, // Indicates error condition. 37 VERSION_WIN_LAST, // Indicates error condition.
35 }; 38 };
36 39
37 // A rough bucketing of the available types of versions of Windows. This is used 40 // A rough bucketing of the available types of versions of Windows. This is used
38 // to distinguish enterprise enabled versions from home versions and potentially 41 // to distinguish enterprise enabled versions from home versions and potentially
39 // server versions. 42 // server versions.
40 enum VersionType { 43 enum VersionType {
41 SUITE_HOME, 44 SUITE_HOME,
42 SUITE_PROFESSIONAL, 45 SUITE_PROFESSIONAL,
43 SUITE_SERVER, 46 SUITE_SERVER,
44 SUITE_LAST, 47 SUITE_LAST,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // the process does not have sufficient access rights to determine this. 82 // the process does not have sufficient access rights to determine this.
80 enum WOW64Status { 83 enum WOW64Status {
81 WOW64_DISABLED, 84 WOW64_DISABLED,
82 WOW64_ENABLED, 85 WOW64_ENABLED,
83 WOW64_UNKNOWN, 86 WOW64_UNKNOWN,
84 }; 87 };
85 88
86 static OSInfo* GetInstance(); 89 static OSInfo* GetInstance();
87 90
88 Version version() const { return version_; } 91 Version version() const { return version_; }
92 Version Kernel32Version() const;
89 // The next two functions return arrays of values, [major, minor(, build)]. 93 // The next two functions return arrays of values, [major, minor(, build)].
90 VersionNumber version_number() const { return version_number_; } 94 VersionNumber version_number() const { return version_number_; }
91 VersionType version_type() const { return version_type_; } 95 VersionType version_type() const { return version_type_; }
92 ServicePack service_pack() const { return service_pack_; } 96 ServicePack service_pack() const { return service_pack_; }
93 WindowsArchitecture architecture() const { return architecture_; } 97 WindowsArchitecture architecture() const { return architecture_; }
94 int processors() const { return processors_; } 98 int processors() const { return processors_; }
95 size_t allocation_granularity() const { return allocation_granularity_; } 99 size_t allocation_granularity() const { return allocation_granularity_; }
96 WOW64Status wow64_status() const { return wow64_status_; } 100 WOW64Status wow64_status() const { return wow64_status_; }
97 std::string processor_model_name(); 101 std::string processor_model_name();
98 102
99 // Like wow64_status(), but for the supplied handle instead of the current 103 // Like wow64_status(), but for the supplied handle instead of the current
100 // process. This doesn't touch member state, so you can bypass the singleton. 104 // process. This doesn't touch member state, so you can bypass the singleton.
101 static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle); 105 static WOW64Status GetWOW64StatusForProcess(HANDLE process_handle);
102 106
103 private: 107 private:
104 OSInfo(); 108 OSInfo();
105 ~OSInfo(); 109 ~OSInfo();
106 110
107 Version version_; 111 Version version_;
112 mutable Version kernel32_version_;
113 mutable bool got_kernel32_version_;
108 VersionNumber version_number_; 114 VersionNumber version_number_;
109 VersionType version_type_; 115 VersionType version_type_;
110 ServicePack service_pack_; 116 ServicePack service_pack_;
111 WindowsArchitecture architecture_; 117 WindowsArchitecture architecture_;
112 int processors_; 118 int processors_;
113 size_t allocation_granularity_; 119 size_t allocation_granularity_;
114 WOW64Status wow64_status_; 120 WOW64Status wow64_status_;
115 std::string processor_model_name_; 121 std::string processor_model_name_;
116 122
117 DISALLOW_COPY_AND_ASSIGN(OSInfo); 123 DISALLOW_COPY_AND_ASSIGN(OSInfo);
118 }; 124 };
119 125
120 // Because this is by far the most commonly-requested value from the above 126 // Because this is by far the most commonly-requested value from the above
121 // singleton, we add a global-scope accessor here as syntactic sugar. 127 // singleton, we add a global-scope accessor here as syntactic sugar.
122 BASE_EXPORT Version GetVersion(); 128 BASE_EXPORT Version GetVersion();
123 129
124 } // namespace win 130 } // namespace win
125 } // namespace base 131 } // namespace base
126 132
127 #endif // BASE_WIN_WINDOWS_VERSION_H_ 133 #endif // BASE_WIN_WINDOWS_VERSION_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/win/windows_version.cc » ('j') | base/win/windows_version.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698