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

Side by Side Diff: components/update_client/utils_win.cc

Issue 2506523002: Report Windows build and patch number in the component updater checks. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « components/update_client/utils_win.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
(Empty)
1 // Copyright 2016 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.
4
5 #include "components/update_client/utils_win.h"
6
7 #include <windows.h>
8
9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/sys_info.h"
13 #include "base/win/registry.h"
14
15 namespace update_client {
16
17 namespace {
18
19 constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] =
20 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
21
22 constexpr wchar_t kRegValCurrentBuild[] = L"CurrentBuild";
23 constexpr wchar_t kRegValCurrentBuildNumber[] = L"CurrentBuildNumber";
24 constexpr wchar_t kRegValUBR[] = L"UBR";
25
26 } // namespace
27
28 // This function implements a best-effort algorithm to return the
29 // Windows build and patch numbers as part of the Windows OS version.
30 // The build and patch numbers are read from
31 // HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion and they are
32 // replicated under the corresponding Wow6432 hive for the 32-bit programs to
33 // read.
34 std::string GetWindowsOSVersion() {
35 int32_t major = 0;
36 int32_t minor = 0;
37 int32_t bugfix = 0;
38 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
39
40 base::win::RegKey key;
41 if (key.Open(HKEY_LOCAL_MACHINE, kRegKeyWindowsNTCurrentVersion,
42 KEY_QUERY_VALUE) != ERROR_SUCCESS) {
43 return base::StringPrintf("%d.%d.%d.%d", major, minor, bugfix, 0);
44 }
45
46 // Try "CurrentBuild", then fallback to "CurrentBuildNumber". Convert the
grt (UTC plus 2) 2016/11/15 10:25:49 does this differ from the build # obtained by GetV
Sorin Jianu 2016/11/15 19:06:52 The same value is retrieved in both cases.
47 // string value to an integral type for validation.
48 base::string16 build_str;
49 if (key.ReadValue(kRegValCurrentBuild, &build_str) != ERROR_SUCCESS)
50 key.ReadValue(kRegValCurrentBuildNumber, &build_str);
51 unsigned int build_number = 0;
52 base::StringToUint(build_str, &build_number);
53
54 DWORD patch = 0;
55 key.ReadValueDW(kRegValUBR, &patch);
grt (UTC plus 2) 2016/11/15 10:25:49 i like having this value available. i like it so m
Sorin Jianu 2016/11/15 19:06:52 It makes sense. I am not quite sure what UBR repre
56
57 return base::StringPrintf("%d.%d.%u.%lu", major, minor, build_number, patch);
grt (UTC plus 2) 2016/11/15 10:25:49 wdyt of putting UBR in the string returned by base
Sorin Jianu 2016/11/15 19:06:52 I thought about it but I am not sure what is going
58 }
59
60 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/utils_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698