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

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: 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const char kSRTPromptOnGroup[] = "On"; 89 const char kSRTPromptOnGroup[] = "On";
90 90
91 // Exit codes that identify that a cleanup is needed. 91 // Exit codes that identify that a cleanup is needed.
92 const int kCleanupNeeded = 0; 92 const int kCleanupNeeded = 0;
93 const int kPostRebootCleanupNeeded = 4; 93 const int kPostRebootCleanupNeeded = 4;
94 94
95 void ReportUmaStep(SwReporterUmaValue value) { 95 void ReportUmaStep(SwReporterUmaValue value) {
96 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX); 96 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX);
97 } 97 }
98 98
99 void ReportUmaVersion(const base::Version& version) { 99 void ReportVersionWithUma(const base::Version& version) {
100 DCHECK(!version.components().empty()); 100 DCHECK(!version.components().empty());
101 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", 101 // The minor version is the 2nd last component of the version,
102 version.components().back()); 102 // or just the first component if there is only 1.
103 // The major version uses the 1st component value (when there is more than 103 uint32_t minor_version = 0;
104 // one, since the last one is always the minor version) as a hi word in a 104 if (version.components().size() > 1)
105 // double word. The low word is either the second component (when there are 105 minor_version = version.components()[version.components().size() - 2];
106 // only three) or the 3rd one if there are at least 4. E.g., for W.X.Y.Z, we 106 else
107 // ignore X, and Z is the minor version. We compute the major version with W 107 minor_version = version.components()[0];
108 // as the hi word, and Y as the low word. For X.Y.Z, we use X and Y as hi and 108 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", minor_version);
109 // low words, and if we would have Y.Z we would use Y as the hi word and 0 as 109
110 // the low word. major version is 0 if the version only has one component. 110 // The major version for X.Y.Z is X*256^3+Y*256+Z. If there are additional
csharp 2014/10/28 19:09:33 I removed the talked about what component maps to
MAD 2014/10/29 01:06:50 Acknowledged.
111 // components, only the first three count, and if there are less than 3, the
112 // missing values are just replaced by zero.
111 uint32_t major_version = 0; 113 uint32_t major_version = 0;
112 if (version.components().size() > 1) 114 if (version.components().size() >= 1)
MAD 2014/10/29 01:06:50 Since we DCHECK that components() is not empty abo
csharp 2014/10/31 14:29:48 Done.
113 major_version = 0x10000 * version.components()[0]; 115 major_version = 0x1000000 * version.components()[0];
MAD 2014/10/29 01:06:50 We should add DCHECKs that components are of the e
csharp 2014/10/31 14:29:48 Done.
114 if (version.components().size() < 4 && version.components().size() > 2) 116 if (version.components().size() >= 2)
115 major_version += version.components()[1]; 117 major_version += 0x100 * version.components()[1];
116 else if (version.components().size() > 3) 118 if (version.components().size() >= 3)
117 major_version += version.components()[2]; 119 major_version += version.components()[2];
118 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version); 120 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version);
119 } 121 }
120 122
121 // This function is called on the UI thread to report the SwReporter exit code 123 // This function is called on the UI thread to report the SwReporter exit code
122 // and then clear it from the registry as well as clear the execution state 124 // and then clear it from the registry as well as clear the execution state
123 // from the local state. This could be called from an interruptible worker 125 // from the local state. This could be called from an interruptible worker
124 // thread so should be resilient to unexpected shutdown. |version| is provided 126 // thread so should be resilient to unexpected shutdown. |version| is provided
125 // so the kSwReporterPromptVersion prefs can be set. 127 // so the kSwReporterPromptVersion prefs can be set.
126 void ReportAndClearExitCode(int exit_code, const std::string& version) { 128 void ReportAndClearExitCode(int exit_code, const std::string& version) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 233
232 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, 234 virtual bool OnCustomInstall(const base::DictionaryValue& manifest,
233 const base::FilePath& install_dir) { 235 const base::FilePath& install_dir) {
234 return true; 236 return true;
235 } 237 }
236 238
237 virtual void ComponentReady(const base::Version& version, 239 virtual void ComponentReady(const base::Version& version,
238 const base::FilePath& install_dir, 240 const base::FilePath& install_dir,
239 scoped_ptr<base::DictionaryValue> manifest) { 241 scoped_ptr<base::DictionaryValue> manifest) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
241 ReportUmaVersion(version); 243 ReportVersionWithUma(version);
242 244
243 wcsncpy_s(version_dir_, 245 wcsncpy_s(version_dir_,
244 _MAX_PATH, 246 _MAX_PATH,
245 install_dir.value().c_str(), 247 install_dir.value().c_str(),
246 install_dir.value().size()); 248 install_dir.value().size());
247 249
248 // A previous run may have results in the registry, so check and report 250 // A previous run may have results in the registry, so check and report
249 // them if present. 251 // them if present.
250 std::string version_string(version.GetString()); 252 std::string version_string(version.GetString());
251 base::win::RegKey srt_key( 253 base::win::RegKey srt_key(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 -1, 353 -1,
352 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 354 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
353 355
354 registry->RegisterStringPref( 356 registry->RegisterStringPref(
355 prefs::kSwReporterPromptVersion, 357 prefs::kSwReporterPromptVersion,
356 "", 358 "",
357 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 359 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
358 } 360 }
359 361
360 } // namespace component_updater 362 } // 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