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

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

Issue 2347753002: Adds histograms for tracking Software Reporter logs uploads in SRT Fetcher. (Closed)
Patch Set: More comments Created 4 years, 3 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) 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 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 29 matching lines...) Expand all
40 #include "components/prefs/pref_registry_simple.h" 40 #include "components/prefs/pref_registry_simple.h"
41 #include "components/update_client/update_client.h" 41 #include "components/update_client/update_client.h"
42 #include "components/update_client/utils.h" 42 #include "components/update_client/utils.h"
43 #include "components/variations/variations_associated_data.h" 43 #include "components/variations/variations_associated_data.h"
44 #include "content/public/browser/browser_thread.h" 44 #include "content/public/browser/browser_thread.h"
45 45
46 namespace component_updater { 46 namespace component_updater {
47 47
48 namespace { 48 namespace {
49 49
50 using safe_browsing::SwReporterBehaviours;
50 using safe_browsing::SwReporterInvocation; 51 using safe_browsing::SwReporterInvocation;
51 52
52 // These values are used to send UMA information and are replicated in the 53 // These values are used to send UMA information and are replicated in the
53 // histograms.xml file, so the order MUST NOT CHANGE. 54 // histograms.xml file, so the order MUST NOT CHANGE.
54 enum SRTCompleted { 55 enum SRTCompleted {
55 SRT_COMPLETED_NOT_YET = 0, 56 SRT_COMPLETED_NOT_YET = 0,
56 SRT_COMPLETED_YES = 1, 57 SRT_COMPLETED_YES = 1,
57 SRT_COMPLETED_LATER = 2, 58 SRT_COMPLETED_LATER = 2,
58 SRT_COMPLETED_MAX, 59 SRT_COMPLETED_MAX,
59 }; 60 };
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadLongestFailureRun", 113 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadLongestFailureRun",
113 longest_failure_run); 114 longest_failure_run);
114 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.LastUploadResult", last_result); 115 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.LastUploadResult", last_result);
115 } 116 }
116 117
117 void ReportExperimentError(SwReporterExperimentError error) { 118 void ReportExperimentError(SwReporterExperimentError error) {
118 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.ExperimentErrors", error, 119 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.ExperimentErrors", error,
119 SW_REPORTER_EXPERIMENT_ERROR_MAX); 120 SW_REPORTER_EXPERIMENT_ERROR_MAX);
120 } 121 }
121 122
122 // Run the software reporter on the next Chrome startup after it's downloaded. 123 // Once the Software Reporter is downloaded, schedules it to run sometime after
123 // (This is the default |reporter_runner| function passed to the 124 // the current browser startup is complete. (This is the default
124 // |SwReporterInstallerTraits| constructor in |RegisterSwReporterComponent| 125 // |reporter_runner| function passed to the |SwReporterInstallerTraits|
125 // below.) 126 // constructor in |RegisterSwReporterComponent| below.)
126 void RunSwReportersAfterStartup( 127 void RunSwReportersAfterStartup(
127 const safe_browsing::SwReporterQueue& invocations, 128 const safe_browsing::SwReporterQueue& invocations,
128 const base::Version& version) { 129 const base::Version& version) {
129 content::BrowserThread::PostAfterStartupTask( 130 content::BrowserThread::PostAfterStartupTask(
130 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), 131 FROM_HERE, base::ThreadTaskRunnerHandle::Get(),
131 base::Bind(&safe_browsing::RunSwReporters, invocations, version, 132 base::Bind(&safe_browsing::RunSwReporters, invocations, version,
132 base::ThreadTaskRunnerHandle::Get(), 133 base::ThreadTaskRunnerHandle::Get(),
133 base::WorkerPool::GetTaskRunner(true))); 134 base::WorkerPool::GetTaskRunner(true)));
134 } 135 }
135 136
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 210
210 base::CommandLine command_line(argv); 211 base::CommandLine command_line(argv);
211 212
212 // Add the histogram suffix to the command-line as well, so that the 213 // Add the histogram suffix to the command-line as well, so that the
213 // reporter will add the same suffix to registry keys where it writes 214 // reporter will add the same suffix to registry keys where it writes
214 // metrics. 215 // metrics.
215 if (!suffix.empty()) 216 if (!suffix.empty())
216 command_line.AppendSwitchASCII("registry-suffix", suffix); 217 command_line.AppendSwitchASCII("registry-suffix", suffix);
217 218
218 // "prompt" is optional, but if present must be a boolean. 219 // "prompt" is optional, but if present must be a boolean.
219 SwReporterInvocation::Flags flags = 0; 220 SwReporterBehaviours supported_behaviours =
221 SwReporterBehaviours::ALL_DISABLED;
220 const base::Value* prompt_value = nullptr; 222 const base::Value* prompt_value = nullptr;
221 if (invocation_params->Get("prompt", &prompt_value)) { 223 if (invocation_params->Get("prompt", &prompt_value)) {
222 bool prompt = false; 224 bool prompt = false;
223 if (!prompt_value->GetAsBoolean(&prompt)) { 225 if (!prompt_value->GetAsBoolean(&prompt)) {
224 ReportExperimentError(SW_REPORTER_EXPERIMENT_ERROR_BAD_PARAMS); 226 ReportExperimentError(SW_REPORTER_EXPERIMENT_ERROR_BAD_PARAMS);
225 return; 227 return;
226 } 228 }
227 if (prompt) 229 if (prompt) {
228 flags |= SwReporterInvocation::FLAG_TRIGGER_PROMPT; 230 supported_behaviours =
231 supported_behaviours | SwReporterBehaviours::TRIGGER_PROMPT;
232 }
229 } 233 }
230 234
231 auto invocation = SwReporterInvocation::FromCommandLine(command_line); 235 auto invocation = SwReporterInvocation::FromCommandLine(command_line);
232 invocation.suffix = suffix; 236 invocation.suffix = suffix;
233 invocation.flags = flags; 237 invocation.supported_behaviours = supported_behaviours;
234 invocations.push(invocation); 238 invocations.push(invocation);
235 } 239 }
236 240
237 DCHECK(!invocations.empty()); 241 DCHECK(!invocations.empty());
238 reporter_runner.Run(invocations, version); 242 reporter_runner.Run(invocations, version);
239 } 243 }
240 244
241 } // namespace 245 } // namespace
242 246
243 SwReporterInstallerTraits::SwReporterInstallerTraits( 247 SwReporterInstallerTraits::SwReporterInstallerTraits(
(...skipping 29 matching lines...) Expand all
273 const base::Version& version, 277 const base::Version& version,
274 const base::FilePath& install_dir, 278 const base::FilePath& install_dir,
275 std::unique_ptr<base::DictionaryValue> manifest) { 279 std::unique_ptr<base::DictionaryValue> manifest) {
276 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 280 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
277 const base::FilePath exe_path(install_dir.Append(kSwReporterExeName)); 281 const base::FilePath exe_path(install_dir.Append(kSwReporterExeName));
278 if (IsExperimentalEngineEnabled()) { 282 if (IsExperimentalEngineEnabled()) {
279 RunExperimentalSwReporter(exe_path, version, std::move(manifest), 283 RunExperimentalSwReporter(exe_path, version, std::move(manifest),
280 reporter_runner_); 284 reporter_runner_);
281 } else { 285 } else {
282 auto invocation = SwReporterInvocation::FromFilePath(exe_path); 286 auto invocation = SwReporterInvocation::FromFilePath(exe_path);
283 invocation.flags = SwReporterInvocation::FLAG_LOG_TO_RAPPOR | 287 invocation.supported_behaviours =
284 SwReporterInvocation::FLAG_LOG_EXIT_CODE_TO_PREFS | 288 SwReporterBehaviours::LOG_TO_RAPPOR |
285 SwReporterInvocation::FLAG_TRIGGER_PROMPT | 289 SwReporterBehaviours::LOG_EXIT_CODE_TO_PREFS |
286 SwReporterInvocation::FLAG_SEND_REPORTER_LOGS; 290 SwReporterBehaviours::TRIGGER_PROMPT |
291 SwReporterBehaviours::SEND_REPORTER_LOGS;
287 292
288 safe_browsing::SwReporterQueue invocations; 293 safe_browsing::SwReporterQueue invocations;
289 invocations.push(invocation); 294 invocations.push(invocation);
290 reporter_runner_.Run(invocations, version); 295 reporter_runner_.Run(invocations, version);
291 } 296 }
292 } 297 }
293 298
294 base::FilePath SwReporterInstallerTraits::GetRelativeInstallDir() const { 299 base::FilePath SwReporterInstallerTraits::GetRelativeInstallDir() const {
295 return base::FilePath(FILE_PATH_LITERAL("SwReporter")); 300 return base::FilePath(FILE_PATH_LITERAL("SwReporter"));
296 } 301 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 444 }
440 445
441 void RegisterProfilePrefsForSwReporter( 446 void RegisterProfilePrefsForSwReporter(
442 user_prefs::PrefRegistrySyncable* registry) { 447 user_prefs::PrefRegistrySyncable* registry) {
443 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, ""); 448 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, "");
444 449
445 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, ""); 450 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, "");
446 } 451 }
447 452
448 } // namespace component_updater 453 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698