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

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

Issue 901903005: Add SRT log upload result metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: facepalm Created 5 years, 10 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 <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/metrics/field_trial.h" 20 #include "base/metrics/field_trial.h"
21 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
22 #include "base/metrics/sparse_histogram.h" 22 #include "base/metrics/sparse_histogram.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "base/prefs/pref_registry_simple.h" 24 #include "base/prefs/pref_registry_simple.h"
25 #include "base/prefs/pref_service.h" 25 #include "base/prefs/pref_service.h"
26 #include "base/process/kill.h" 26 #include "base/process/kill.h"
27 #include "base/process/launch.h" 27 #include "base/process/launch.h"
28 #include "base/strings/string_tokenizer.h"
28 #include "base/task_runner_util.h" 29 #include "base/task_runner_util.h"
29 #include "base/threading/worker_pool.h" 30 #include "base/threading/worker_pool.h"
30 #include "base/time/time.h" 31 #include "base/time/time.h"
31 #include "base/win/registry.h" 32 #include "base/win/registry.h"
32 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
33 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 34 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
34 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/safe_browsing/srt_global_error_win.h" 36 #include "chrome/browser/safe_browsing/srt_global_error_win.h"
36 #include "chrome/browser/ui/browser_finder.h" 37 #include "chrome/browser/ui/browser_finder.h"
37 #include "chrome/browser/ui/global_error/global_error_service.h" 38 #include "chrome/browser/ui/global_error/global_error_service.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c, 81 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c,
81 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7}; 82 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7};
82 83
83 const base::FilePath::CharType kSwReporterExeName[] = 84 const base::FilePath::CharType kSwReporterExeName[] =
84 FILE_PATH_LITERAL("software_reporter_tool.exe"); 85 FILE_PATH_LITERAL("software_reporter_tool.exe");
85 86
86 // Where to fetch the reporter exit code in the registry. 87 // Where to fetch the reporter exit code in the registry.
87 const wchar_t kSoftwareRemovalToolRegistryKey[] = 88 const wchar_t kSoftwareRemovalToolRegistryKey[] =
88 L"Software\\Google\\Software Removal Tool"; 89 L"Software\\Google\\Software Removal Tool";
89 const wchar_t kCleanerSuffixRegistryKey[] = L"Cleaner"; 90 const wchar_t kCleanerSuffixRegistryKey[] = L"Cleaner";
91 const wchar_t kEndTimeRegistryValueName[] = L"EndTime";
90 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode"; 92 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode";
93 const wchar_t kStartTimeRegistryValueName[] = L"StartTime";
94 const wchar_t kUploadResultsValueName[] = L"UploadResults";
91 const wchar_t kVersionRegistryValueName[] = L"Version"; 95 const wchar_t kVersionRegistryValueName[] = L"Version";
92 const wchar_t kStartTimeRegistryValueName[] = L"StartTime";
93 const wchar_t kEndTimeRegistryValueName[] = L"EndTime";
94 96
95 // Field trial strings. 97 // Field trial strings.
96 const char kSRTPromptTrialName[] = "SRTPromptFieldTrial"; 98 const char kSRTPromptTrialName[] = "SRTPromptFieldTrial";
97 const char kSRTPromptOnGroup[] = "On"; 99 const char kSRTPromptOnGroup[] = "On";
98 const char kSRTPromptSeedParamName[] = "Seed"; 100 const char kSRTPromptSeedParamName[] = "Seed";
99 101
100 // Exit codes that identify that a cleanup is needed. 102 // Exit codes that identify that a cleanup is needed.
101 const int kCleanupNeeded = 0; 103 const int kCleanupNeeded = 0;
102 const int kNothingFound = 2; 104 const int kNothingFound = 2;
103 const int kPostRebootCleanupNeeded = 4; 105 const int kPostRebootCleanupNeeded = 4;
(...skipping 23 matching lines...) Expand all
127 DCHECK_LT(version.components()[1], 0x10000); 129 DCHECK_LT(version.components()[1], 0x10000);
128 major_version += 0x100 * version.components()[1]; 130 major_version += 0x100 * version.components()[1];
129 } 131 }
130 if (version.components().size() >= 3) { 132 if (version.components().size() >= 3) {
131 DCHECK_LT(version.components()[2], 0x100); 133 DCHECK_LT(version.components()[2], 0x100);
132 major_version += version.components()[2]; 134 major_version += version.components()[2];
133 } 135 }
134 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version); 136 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version);
135 } 137 }
136 138
139 void ReportUploadsWithUma(const base::string16& upload_results) {
140 base::WStringTokenizer tokenizer(upload_results, L";");
141 int failure_count = 0;
142 int success_count = 0;
143 int longest_failure_run = 0;
144 int current_failure_run = 0;
145 bool last_result = false;
146 while (tokenizer.GetNext()) {
147 if (tokenizer.token() == L"0") {
148 ++failure_count;
149 ++current_failure_run;
150 last_result = false;
151 } else {
152 ++success_count;
153 current_failure_run = 0;
154 last_result = true;
155 }
156
157 if (current_failure_run > longest_failure_run)
158 longest_failure_run = current_failure_run;
159 }
160
161 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadFailureCount",
162 failure_count);
163 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadSuccessCount",
164 success_count);
165 UMA_HISTOGRAM_COUNTS_100("SoftwareReporter.UploadLongestFailureRun",
166 longest_failure_run);
167 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.LastUploadResult", last_result);
168 }
169
137 // This function is called on the UI thread to report the SwReporter exit code 170 // This function is called on the UI thread to report the SwReporter exit code
138 // and then clear it from the registry as well as clear the execution state 171 // and then clear it from the registry as well as clear the execution state
139 // from the local state. This could be called from an interruptible worker 172 // from the local state. This could be called from an interruptible worker
140 // thread so should be resilient to unexpected shutdown. |version| is provided 173 // thread so should be resilient to unexpected shutdown. |version| is provided
141 // so the kSwReporterPromptVersion prefs can be set. 174 // so the kSwReporterPromptVersion prefs can be set.
142 void ReportAndClearExitCode(int exit_code, const std::string& version) { 175 void ReportAndClearExitCode(int exit_code, const std::string& version) {
143 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.ExitCode", exit_code); 176 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.ExitCode", exit_code);
144 base::win::RegKey srt_key(HKEY_CURRENT_USER, kSoftwareRemovalToolRegistryKey, 177 base::win::RegKey srt_key(HKEY_CURRENT_USER, kSoftwareRemovalToolRegistryKey,
145 KEY_WRITE); 178 KEY_WRITE);
146 srt_key.DeleteValue(kExitCodeRegistryValueName); 179 srt_key.DeleteValue(kExitCodeRegistryValueName);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (exit_code == kPostRebootCleanupNeeded || 442 if (exit_code == kPostRebootCleanupNeeded ||
410 exit_code == kDelayedPostRebootCleanupNeeded) { 443 exit_code == kDelayedPostRebootCleanupNeeded) {
411 // Check if we are running after the user has rebooted. 444 // Check if we are running after the user has rebooted.
412 base::TimeDelta elapsed(base::Time::Now() - 445 base::TimeDelta elapsed(base::Time::Now() -
413 base::Time::FromInternalValue(start_time_value)); 446 base::Time::FromInternalValue(start_time_value));
414 DCHECK_GT(elapsed.InMilliseconds(), 0); 447 DCHECK_GT(elapsed.InMilliseconds(), 0);
415 UMA_HISTOGRAM_BOOLEAN( 448 UMA_HISTOGRAM_BOOLEAN(
416 "SoftwareReporter.Cleaner.HasRebooted", 449 "SoftwareReporter.Cleaner.HasRebooted",
417 static_cast<uint64>(elapsed.InMilliseconds()) > ::GetTickCount()); 450 static_cast<uint64>(elapsed.InMilliseconds()) > ::GetTickCount());
418 } 451 }
452
453 if (cleaner_key.HasValue(kUploadResultsValueName)) {
454 base::string16 upload_results;
455 cleaner_key.ReadValue(kUploadResultsValueName, &upload_results);
456 ReportUploadsWithUma(upload_results);
457 }
419 } 458 }
420 459
421 // Install the component. 460 // Install the component.
422 scoped_ptr<ComponentInstallerTraits> traits( 461 scoped_ptr<ComponentInstallerTraits> traits(
423 new SwReporterInstallerTraits(prefs)); 462 new SwReporterInstallerTraits(prefs));
424 // |cus| will take ownership of |installer| during installer->Register(cus). 463 // |cus| will take ownership of |installer| during installer->Register(cus).
425 DefaultComponentInstaller* installer = 464 DefaultComponentInstaller* installer =
426 new DefaultComponentInstaller(traits.Pass()); 465 new DefaultComponentInstaller(traits.Pass());
427 installer->Register(cus); 466 installer->Register(cus);
428 } 467 }
(...skipping 12 matching lines...) Expand all
441 registry->RegisterStringPref( 480 registry->RegisterStringPref(
442 prefs::kSwReporterPromptVersion, "", 481 prefs::kSwReporterPromptVersion, "",
443 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 482 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
444 483
445 registry->RegisterStringPref( 484 registry->RegisterStringPref(
446 prefs::kSwReporterPromptSeed, "", 485 prefs::kSwReporterPromptSeed, "",
447 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 486 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
448 } 487 }
449 488
450 } // namespace component_updater 489 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698