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

Unified 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 comments Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/sw_reporter_installer_win.cc
diff --git a/chrome/browser/component_updater/sw_reporter_installer_win.cc b/chrome/browser/component_updater/sw_reporter_installer_win.cc
index 6774d3886c97a4882508b0c636a9d02a4212b2b3..a1b71956c4d6c10a260287602e616a1ac49b013c 100644
--- a/chrome/browser/component_updater/sw_reporter_installer_win.cc
+++ b/chrome/browser/component_updater/sw_reporter_installer_win.cc
@@ -100,25 +100,30 @@ void ReportUmaStep(SwReporterUmaValue value) {
UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX);
}
-void ReportUmaVersion(const base::Version& version) {
+void ReportVersionWithUma(const base::Version& version) {
DCHECK(!version.components().empty());
- UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion",
- version.components().back());
- // The major version uses the 1st component value (when there is more than
- // one, since the last one is always the minor version) as a hi word in a
- // double word. The low word is either the second component (when there are
- // only three) or the 3rd one if there are at least 4. E.g., for W.X.Y.Z, we
- // ignore X, and Z is the minor version. We compute the major version with W
- // as the hi word, and Y as the low word. For X.Y.Z, we use X and Y as hi and
- // low words, and if we would have Y.Z we would use Y as the hi word and 0 as
- // the low word. major version is 0 if the version only has one component.
- uint32_t major_version = 0;
+ // The minor version is the 2nd last component of the version,
+ // or just the first component if there is only 1.
+ uint32_t minor_version = 0;
if (version.components().size() > 1)
- major_version = 0x10000 * version.components()[0];
- if (version.components().size() < 4 && version.components().size() > 2)
- major_version += version.components()[1];
- else if (version.components().size() > 3)
+ minor_version = version.components()[version.components().size() - 2];
+ else
+ minor_version = version.components()[0];
+ UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", minor_version);
+
+ // The major version for X.Y.Z is X*256^3+Y*256+Z. If there are additional
+ // components, only the first three count, and if there are less than 3, the
+ // missing values are just replaced by zero.
waffles 2014/11/04 21:21:25 Maybe clarify that "1" the same as 1.0.0, not 0.0.
csharp 2014/11/04 21:56:49 Done.
+ DCHECK(version.components()[0] < 0x100);
+ uint32_t major_version = 0x1000000 * version.components()[0];
+ if (version.components().size() >= 2) {
+ DCHECK(version.components()[1] < 0x10000);
+ major_version += 0x100 * version.components()[1];
+ }
+ if (version.components().size() >= 3) {
+ DCHECK(version.components()[2] < 0x100);
major_version += version.components()[2];
+ }
UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version);
}
@@ -241,7 +246,7 @@ class SwReporterInstallerTraits : public ComponentInstallerTraits {
const base::FilePath& install_dir,
scoped_ptr<base::DictionaryValue> manifest) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ReportUmaVersion(version);
+ ReportVersionWithUma(version);
wcsncpy_s(version_dir_,
_MAX_PATH,
« 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