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

Side by Side Diff: chrome/browser/component_updater/sw_reporter_installer_win.cc

Issue 681423002: Update the sw_reporter version code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responding to comment Created 6 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 | « no previous file | 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "chrome/browser/component_updater/sw_reporter_installer_win.h" 5 #include "chrome/browser/component_updater/sw_reporter_installer_win.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const char kSRTPromptOnGroup[] = "On"; 93 const char kSRTPromptOnGroup[] = "On";
94 94
95 // Exit codes that identify that a cleanup is needed. 95 // Exit codes that identify that a cleanup is needed.
96 const int kCleanupNeeded = 0; 96 const int kCleanupNeeded = 0;
97 const int kPostRebootCleanupNeeded = 4; 97 const int kPostRebootCleanupNeeded = 4;
98 98
99 void ReportUmaStep(SwReporterUmaValue value) { 99 void ReportUmaStep(SwReporterUmaValue value) {
100 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX); 100 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX);
101 } 101 }
102 102
103 void ReportUmaVersion(const base::Version& version) { 103 void ReportVersionWithUma(const base::Version& version) {
104 DCHECK(!version.components().empty()); 104 DCHECK(!version.components().empty());
105 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", 105 // The minor version is the 2nd last component of the version,
106 version.components().back()); 106 // or just the first component if there is only 1.
107 // The major version uses the 1st component value (when there is more than 107 uint32_t minor_version = 0;
108 // one, since the last one is always the minor version) as a hi word in a
109 // double word. The low word is either the second component (when there are
110 // only three) or the 3rd one if there are at least 4. E.g., for W.X.Y.Z, we
111 // ignore X, and Z is the minor version. We compute the major version with W
112 // as the hi word, and Y as the low word. For X.Y.Z, we use X and Y as hi and
113 // low words, and if we would have Y.Z we would use Y as the hi word and 0 as
114 // the low word. major version is 0 if the version only has one component.
115 uint32_t major_version = 0;
116 if (version.components().size() > 1) 108 if (version.components().size() > 1)
117 major_version = 0x10000 * version.components()[0]; 109 minor_version = version.components()[version.components().size() - 2];
118 if (version.components().size() < 4 && version.components().size() > 2) 110 else
119 major_version += version.components()[1]; 111 minor_version = version.components()[0];
120 else if (version.components().size() > 3) 112 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", minor_version);
113
114 // The major version for X.Y.Z is X*256^3+Y*256+Z. If there are additional
115 // components, only the first three count, and if there are less than 3, the
116 // missing values are just replaced by zero. So 1 is equivalent 1.0.0.
117 DCHECK(version.components()[0] < 0x100);
118 uint32_t major_version = 0x1000000 * version.components()[0];
119 if (version.components().size() >= 2) {
120 DCHECK(version.components()[1] < 0x10000);
121 major_version += 0x100 * version.components()[1];
122 }
123 if (version.components().size() >= 3) {
124 DCHECK(version.components()[2] < 0x100);
121 major_version += version.components()[2]; 125 major_version += version.components()[2];
126 }
122 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version); 127 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version);
123 } 128 }
124 129
125 // This function is called on the UI thread to report the SwReporter exit code 130 // This function is called on the UI thread to report the SwReporter exit code
126 // and then clear it from the registry as well as clear the execution state 131 // and then clear it from the registry as well as clear the execution state
127 // from the local state. This could be called from an interruptible worker 132 // from the local state. This could be called from an interruptible worker
128 // thread so should be resilient to unexpected shutdown. |version| is provided 133 // thread so should be resilient to unexpected shutdown. |version| is provided
129 // so the kSwReporterPromptVersion prefs can be set. 134 // so the kSwReporterPromptVersion prefs can be set.
130 void ReportAndClearExitCode(int exit_code, const std::string& version) { 135 void ReportAndClearExitCode(int exit_code, const std::string& version) {
131 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.ExitCode", exit_code); 136 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.ExitCode", exit_code);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 239
235 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, 240 virtual bool OnCustomInstall(const base::DictionaryValue& manifest,
236 const base::FilePath& install_dir) { 241 const base::FilePath& install_dir) {
237 return true; 242 return true;
238 } 243 }
239 244
240 virtual void ComponentReady(const base::Version& version, 245 virtual void ComponentReady(const base::Version& version,
241 const base::FilePath& install_dir, 246 const base::FilePath& install_dir,
242 scoped_ptr<base::DictionaryValue> manifest) { 247 scoped_ptr<base::DictionaryValue> manifest) {
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
244 ReportUmaVersion(version); 249 ReportVersionWithUma(version);
245 250
246 wcsncpy_s(version_dir_, 251 wcsncpy_s(version_dir_,
247 _MAX_PATH, 252 _MAX_PATH,
248 install_dir.value().c_str(), 253 install_dir.value().c_str(),
249 install_dir.value().size()); 254 install_dir.value().size());
250 255
251 // A previous run may have results in the registry, so check and report 256 // A previous run may have results in the registry, so check and report
252 // them if present. 257 // them if present.
253 std::string version_string(version.GetString()); 258 std::string version_string(version.GetString());
254 base::win::RegKey srt_key( 259 base::win::RegKey srt_key(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 -1, 400 -1,
396 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 401 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
397 402
398 registry->RegisterStringPref( 403 registry->RegisterStringPref(
399 prefs::kSwReporterPromptVersion, 404 prefs::kSwReporterPromptVersion,
400 "", 405 "",
401 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 406 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
402 } 407 }
403 408
404 } // namespace component_updater 409 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698