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

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

Issue 660563004: Added UMA statistics for Chrome Cleaner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responded to comments. 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 0xf4, 0xc9, 0x78, 0x6c, 0x0c, 0x24, 0x73, 0x3e, 75 0xf4, 0xc9, 0x78, 0x6c, 0x0c, 0x24, 0x73, 0x3e,
76 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c, 76 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c,
77 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7}; 77 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7};
78 78
79 const base::FilePath::CharType kSwReporterExeName[] = 79 const base::FilePath::CharType kSwReporterExeName[] =
80 FILE_PATH_LITERAL("software_reporter_tool.exe"); 80 FILE_PATH_LITERAL("software_reporter_tool.exe");
81 81
82 // Where to fetch the reporter exit code in the registry. 82 // Where to fetch the reporter exit code in the registry.
83 const wchar_t kSoftwareRemovalToolRegistryKey[] = 83 const wchar_t kSoftwareRemovalToolRegistryKey[] =
84 L"Software\\Google\\Software Removal Tool"; 84 L"Software\\Google\\Software Removal Tool";
85 const wchar_t kCleanerSuffixRegistryKey[] = L"Cleaner";
85 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode"; 86 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode";
87 const wchar_t kVersionRegistryValueName[] = L"Version";
88 const wchar_t kStartTimeRegistryValueName[] = L"StartTime";
89 const wchar_t kEndTimeRegistryValueName[] = L"EndTime";
86 90
87 // Field trial strings. 91 // Field trial strings.
88 const char kSRTPromptTrialName[] = "SRTPromptFieldTrial"; 92 const char kSRTPromptTrialName[] = "SRTPromptFieldTrial";
89 const char kSRTPromptOnGroup[] = "On"; 93 const char kSRTPromptOnGroup[] = "On";
90 94
91 // Exit codes that identify that a cleanup is needed. 95 // Exit codes that identify that a cleanup is needed.
92 const int kCleanupNeeded = 0; 96 const int kCleanupNeeded = 0;
93 const int kPostRebootCleanupNeeded = 4; 97 const int kPostRebootCleanupNeeded = 4;
94 98
95 void ReportUmaStep(SwReporterUmaValue value) { 99 void ReportUmaStep(SwReporterUmaValue value) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 void RegisterSwReporterComponent(ComponentUpdateService* cus, 326 void RegisterSwReporterComponent(ComponentUpdateService* cus,
323 PrefService* prefs) { 327 PrefService* prefs) {
324 // The Sw reporter doesn't need to run if the user isn't reporting metrics and 328 // The Sw reporter doesn't need to run if the user isn't reporting metrics and
325 // isn't in the SRTPrompt field trial "On" group. 329 // isn't in the SRTPrompt field trial "On" group.
326 if (!ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() && 330 if (!ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() &&
327 base::FieldTrialList::FindFullName(kSRTPromptTrialName) != 331 base::FieldTrialList::FindFullName(kSRTPromptTrialName) !=
328 kSRTPromptOnGroup) { 332 kSRTPromptOnGroup) {
329 return; 333 return;
330 } 334 }
331 335
336 // Check if we have information from Cleaner and record UMA statistics.
337 base::string16 cleaner_key_name(kSoftwareRemovalToolRegistryKey);
338 cleaner_key_name.append(1, L'\\').append(kCleanerSuffixRegistryKey);
339 base::win::RegKey cleaner_key(
340 HKEY_CURRENT_USER, cleaner_key_name.c_str(), KEY_ALL_ACCESS);
341 // Cleaner is assumed to have run if we have a start time.
342 if (cleaner_key.Valid() &&
343 cleaner_key.HasValue(kStartTimeRegistryValueName)) {
344 // Get version number.
345 if (cleaner_key.HasValue(kVersionRegistryValueName)) {
346 DWORD version;
347 cleaner_key.ReadValueDW(kVersionRegistryValueName, &version);
348 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.Cleaner.Version", version);
349 cleaner_key.DeleteValue(kVersionRegistryValueName);
350 }
351 // Get start & end time.
352 if (cleaner_key.HasValue(kEndTimeRegistryValueName)) {
353 int64 start_time_value;
354 cleaner_key.ReadInt64(kStartTimeRegistryValueName, &start_time_value);
355 int64 end_time_value;
356 cleaner_key.ReadInt64(kEndTimeRegistryValueName, &end_time_value);
357 cleaner_key.DeleteValue(kEndTimeRegistryValueName);
358 base::TimeDelta run_time(base::Time::FromInternalValue(end_time_value) -
359 base::Time::FromInternalValue(start_time_value));
360 UMA_HISTOGRAM_LONG_TIMES("SoftwareReporter.Cleaner.RunningTime",
361 run_time);
362 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.Cleaner.HasCompleted", true);
363 } else {
364 // If we don't have an end time, we can assume the cleaner crashed.
365 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.Cleaner.HasCompleted", false);
Alexei Svitkine (slow) 2014/10/30 14:02:24 Nit: Each histogram macro actually expands to a no
Georges Khalil 2014/10/30 14:44:53 Done.
366 }
367 // Get exit code.
368 if (cleaner_key.HasValue(kExitCodeRegistryValueName)) {
369 DWORD exit_code;
370 cleaner_key.ReadValueDW(kExitCodeRegistryValueName, &exit_code);
371 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.Cleaner.ExitCode",
372 exit_code);
373 cleaner_key.DeleteValue(kExitCodeRegistryValueName);
374 }
375 cleaner_key.DeleteValue(kStartTimeRegistryValueName);
376 }
377
332 // Install the component. 378 // Install the component.
333 scoped_ptr<ComponentInstallerTraits> traits( 379 scoped_ptr<ComponentInstallerTraits> traits(
334 new SwReporterInstallerTraits(prefs)); 380 new SwReporterInstallerTraits(prefs));
335 // |cus| will take ownership of |installer| during installer->Register(cus). 381 // |cus| will take ownership of |installer| during installer->Register(cus).
336 DefaultComponentInstaller* installer = 382 DefaultComponentInstaller* installer =
337 new DefaultComponentInstaller(traits.Pass()); 383 new DefaultComponentInstaller(traits.Pass());
338 installer->Register(cus); 384 installer->Register(cus);
339 } 385 }
340 386
341 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) { 387 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) {
342 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0); 388 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0);
343 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1); 389 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1);
344 } 390 }
345 391
346 void RegisterProfilePrefsForSwReporter( 392 void RegisterProfilePrefsForSwReporter(
347 user_prefs::PrefRegistrySyncable* registry) { 393 user_prefs::PrefRegistrySyncable* registry) {
348 registry->RegisterIntegerPref( 394 registry->RegisterIntegerPref(
349 prefs::kSwReporterPromptReason, 395 prefs::kSwReporterPromptReason,
350 -1, 396 -1,
351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 397 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
352 398
353 registry->RegisterStringPref( 399 registry->RegisterStringPref(
354 prefs::kSwReporterPromptVersion, 400 prefs::kSwReporterPromptVersion,
355 "", 401 "",
356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 402 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
357 } 403 }
358 404
359 } // namespace component_updater 405 } // 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