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

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: Fixed histograms. 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)) {
Alexei Svitkine (slow) 2014/10/29 21:47:51 Could it happen that the kEndTime was from a previ
Georges Khalil 2014/10/30 13:57:58 The registry is cleared every time the cleaner sta
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.RunTime", run_time);
361 } else {
362 // If we don't have an end time, we can assume the cleaner crashed and we
363 // represent this using an infinite delta.
364 UMA_HISTOGRAM_LONG_TIMES("SoftwareReporter.Cleaner.RunTime",
365 base::TimeDelta::Max());
Alexei Svitkine (slow) 2014/10/29 21:47:51 Are you sure you want to do this? This will make
Georges Khalil 2014/10/30 13:57:57 Added a histogram for whether the cleaner has comp
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
378
Alexei Svitkine (slow) 2014/10/29 21:47:51 Nit: Remove blank line.
Georges Khalil 2014/10/30 13:57:57 Done.
332 // Install the component. 379 // Install the component.
333 scoped_ptr<ComponentInstallerTraits> traits( 380 scoped_ptr<ComponentInstallerTraits> traits(
334 new SwReporterInstallerTraits(prefs)); 381 new SwReporterInstallerTraits(prefs));
335 // |cus| will take ownership of |installer| during installer->Register(cus). 382 // |cus| will take ownership of |installer| during installer->Register(cus).
336 DefaultComponentInstaller* installer = 383 DefaultComponentInstaller* installer =
337 new DefaultComponentInstaller(traits.Pass()); 384 new DefaultComponentInstaller(traits.Pass());
338 installer->Register(cus); 385 installer->Register(cus);
339 } 386 }
340 387
341 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) { 388 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) {
342 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0); 389 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0);
343 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1); 390 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1);
344 } 391 }
345 392
346 void RegisterProfilePrefsForSwReporter( 393 void RegisterProfilePrefsForSwReporter(
347 user_prefs::PrefRegistrySyncable* registry) { 394 user_prefs::PrefRegistrySyncable* registry) {
348 registry->RegisterIntegerPref( 395 registry->RegisterIntegerPref(
349 prefs::kSwReporterPromptReason, 396 prefs::kSwReporterPromptReason,
350 -1, 397 -1,
351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 398 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
352 399
353 registry->RegisterStringPref( 400 registry->RegisterStringPref(
354 prefs::kSwReporterPromptVersion, 401 prefs::kSwReporterPromptVersion,
355 "", 402 "",
356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 403 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
357 } 404 }
358 405
359 } // namespace component_updater 406 } // 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