| OLD | NEW |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadLongestFailureRun", | 112 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadLongestFailureRun", |
| 113 longest_failure_run); | 113 longest_failure_run); |
| 114 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.LastUploadResult", last_result); | 114 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.LastUploadResult", last_result); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ReportExperimentError(SwReporterExperimentError error) { | 117 void ReportExperimentError(SwReporterExperimentError error) { |
| 118 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.ExperimentErrors", error, | 118 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.ExperimentErrors", error, |
| 119 SW_REPORTER_EXPERIMENT_ERROR_MAX); | 119 SW_REPORTER_EXPERIMENT_ERROR_MAX); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Run the software reporter on the next Chrome startup after it's downloaded. | 122 // Once the Software Reporter is downloaded, schedules it to run sometime after |
| 123 // (This is the default |reporter_runner| function passed to the | 123 // the current browser startup is complete. (This is the default |
| 124 // |SwReporterInstallerTraits| constructor in |RegisterSwReporterComponent| | 124 // |reporter_runner| function passed to the |SwReporterInstallerTraits| |
| 125 // below.) | 125 // constructor in |RegisterSwReporterComponent| below.) |
| 126 void RunSwReportersAfterStartup( | 126 void RunSwReportersAfterStartup( |
| 127 const safe_browsing::SwReporterQueue& invocations, | 127 const safe_browsing::SwReporterQueue& invocations, |
| 128 const base::Version& version) { | 128 const base::Version& version) { |
| 129 content::BrowserThread::PostAfterStartupTask( | 129 content::BrowserThread::PostAfterStartupTask( |
| 130 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), | 130 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), |
| 131 base::Bind(&safe_browsing::RunSwReporters, invocations, version, | 131 base::Bind(&safe_browsing::RunSwReporters, invocations, version, |
| 132 base::ThreadTaskRunnerHandle::Get(), | 132 base::ThreadTaskRunnerHandle::Get(), |
| 133 base::WorkerPool::GetTaskRunner(true))); | 133 base::WorkerPool::GetTaskRunner(true))); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 base::CommandLine command_line(argv); | 210 base::CommandLine command_line(argv); |
| 211 | 211 |
| 212 // Add the histogram suffix to the command-line as well, so that the | 212 // 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 | 213 // reporter will add the same suffix to registry keys where it writes |
| 214 // metrics. | 214 // metrics. |
| 215 if (!suffix.empty()) | 215 if (!suffix.empty()) |
| 216 command_line.AppendSwitchASCII("registry-suffix", suffix); | 216 command_line.AppendSwitchASCII("registry-suffix", suffix); |
| 217 | 217 |
| 218 // "prompt" is optional, but if present must be a boolean. | 218 // "prompt" is optional, but if present must be a boolean. |
| 219 SwReporterInvocation::Flags flags = 0; | 219 SwReporterInvocation::Behaviours supported_behaviours = 0; |
| 220 const base::Value* prompt_value = nullptr; | 220 const base::Value* prompt_value = nullptr; |
| 221 if (invocation_params->Get("prompt", &prompt_value)) { | 221 if (invocation_params->Get("prompt", &prompt_value)) { |
| 222 bool prompt = false; | 222 bool prompt = false; |
| 223 if (!prompt_value->GetAsBoolean(&prompt)) { | 223 if (!prompt_value->GetAsBoolean(&prompt)) { |
| 224 ReportExperimentError(SW_REPORTER_EXPERIMENT_ERROR_BAD_PARAMS); | 224 ReportExperimentError(SW_REPORTER_EXPERIMENT_ERROR_BAD_PARAMS); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 if (prompt) | 227 if (prompt) |
| 228 flags |= SwReporterInvocation::FLAG_TRIGGER_PROMPT; | 228 supported_behaviours |= SwReporterInvocation::BEHAVIOUR_TRIGGER_PROMPT; |
| 229 } | 229 } |
| 230 | 230 |
| 231 auto invocation = SwReporterInvocation::FromCommandLine(command_line); | 231 auto invocation = SwReporterInvocation::FromCommandLine(command_line); |
| 232 invocation.suffix = suffix; | 232 invocation.suffix = suffix; |
| 233 invocation.flags = flags; | 233 invocation.supported_behaviours = supported_behaviours; |
| 234 invocations.push(invocation); | 234 invocations.push(invocation); |
| 235 } | 235 } |
| 236 | 236 |
| 237 DCHECK(!invocations.empty()); | 237 DCHECK(!invocations.empty()); |
| 238 reporter_runner.Run(invocations, version); | 238 reporter_runner.Run(invocations, version); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace | 241 } // namespace |
| 242 | 242 |
| 243 SwReporterInstallerTraits::SwReporterInstallerTraits( | 243 SwReporterInstallerTraits::SwReporterInstallerTraits( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 273 const base::Version& version, | 273 const base::Version& version, |
| 274 const base::FilePath& install_dir, | 274 const base::FilePath& install_dir, |
| 275 std::unique_ptr<base::DictionaryValue> manifest) { | 275 std::unique_ptr<base::DictionaryValue> manifest) { |
| 276 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 276 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 277 const base::FilePath exe_path(install_dir.Append(kSwReporterExeName)); | 277 const base::FilePath exe_path(install_dir.Append(kSwReporterExeName)); |
| 278 if (IsExperimentalEngineEnabled()) { | 278 if (IsExperimentalEngineEnabled()) { |
| 279 RunExperimentalSwReporter(exe_path, version, std::move(manifest), | 279 RunExperimentalSwReporter(exe_path, version, std::move(manifest), |
| 280 reporter_runner_); | 280 reporter_runner_); |
| 281 } else { | 281 } else { |
| 282 auto invocation = SwReporterInvocation::FromFilePath(exe_path); | 282 auto invocation = SwReporterInvocation::FromFilePath(exe_path); |
| 283 invocation.flags = SwReporterInvocation::FLAG_LOG_TO_RAPPOR | | 283 invocation.supported_behaviours = |
| 284 SwReporterInvocation::FLAG_LOG_EXIT_CODE_TO_PREFS | | 284 SwReporterInvocation::BEHAVIOUR_LOG_TO_RAPPOR | |
| 285 SwReporterInvocation::FLAG_TRIGGER_PROMPT | | 285 SwReporterInvocation::BEHAVIOUR_LOG_EXIT_CODE_TO_PREFS | |
| 286 SwReporterInvocation::FLAG_SEND_REPORTER_LOGS; | 286 SwReporterInvocation::BEHAVIOUR_TRIGGER_PROMPT | |
| 287 SwReporterInvocation::BEHAVIOUR_ALLOW_SEND_REPORTER_LOGS; |
| 287 | 288 |
| 288 safe_browsing::SwReporterQueue invocations; | 289 safe_browsing::SwReporterQueue invocations; |
| 289 invocations.push(invocation); | 290 invocations.push(invocation); |
| 290 reporter_runner_.Run(invocations, version); | 291 reporter_runner_.Run(invocations, version); |
| 291 } | 292 } |
| 292 } | 293 } |
| 293 | 294 |
| 294 base::FilePath SwReporterInstallerTraits::GetRelativeInstallDir() const { | 295 base::FilePath SwReporterInstallerTraits::GetRelativeInstallDir() const { |
| 295 return base::FilePath(FILE_PATH_LITERAL("SwReporter")); | 296 return base::FilePath(FILE_PATH_LITERAL("SwReporter")); |
| 296 } | 297 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 440 } |
| 440 | 441 |
| 441 void RegisterProfilePrefsForSwReporter( | 442 void RegisterProfilePrefsForSwReporter( |
| 442 user_prefs::PrefRegistrySyncable* registry) { | 443 user_prefs::PrefRegistrySyncable* registry) { |
| 443 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, ""); | 444 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, ""); |
| 444 | 445 |
| 445 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, ""); | 446 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, ""); |
| 446 } | 447 } |
| 447 | 448 |
| 448 } // namespace component_updater | 449 } // namespace component_updater |
| OLD | NEW |