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

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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. If we don't have an end time, we can assume the
352 // cleaner has crashed.
353 bool completed = cleaner_key.HasValue(kEndTimeRegistryValueName);
354 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.Cleaner.HasCompleted", completed);
355 if (completed) {
356 int64 start_time_value;
357 cleaner_key.ReadInt64(kStartTimeRegistryValueName, &start_time_value);
358 int64 end_time_value;
359 cleaner_key.ReadInt64(kEndTimeRegistryValueName, &end_time_value);
360 cleaner_key.DeleteValue(kEndTimeRegistryValueName);
361 base::TimeDelta run_time(base::Time::FromInternalValue(end_time_value) -
362 base::Time::FromInternalValue(start_time_value));
363 UMA_HISTOGRAM_LONG_TIMES("SoftwareReporter.Cleaner.RunningTime",
364 run_time);
365 }
366 // Get exit code.
367 if (cleaner_key.HasValue(kExitCodeRegistryValueName)) {
368 DWORD exit_code;
369 cleaner_key.ReadValueDW(kExitCodeRegistryValueName, &exit_code);
370 UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.Cleaner.ExitCode",
371 exit_code);
372 cleaner_key.DeleteValue(kExitCodeRegistryValueName);
373 }
374 cleaner_key.DeleteValue(kStartTimeRegistryValueName);
375 }
376
332 // Install the component. 377 // Install the component.
333 scoped_ptr<ComponentInstallerTraits> traits( 378 scoped_ptr<ComponentInstallerTraits> traits(
334 new SwReporterInstallerTraits(prefs)); 379 new SwReporterInstallerTraits(prefs));
335 // |cus| will take ownership of |installer| during installer->Register(cus). 380 // |cus| will take ownership of |installer| during installer->Register(cus).
336 DefaultComponentInstaller* installer = 381 DefaultComponentInstaller* installer =
337 new DefaultComponentInstaller(traits.Pass()); 382 new DefaultComponentInstaller(traits.Pass());
338 installer->Register(cus); 383 installer->Register(cus);
339 } 384 }
340 385
341 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) { 386 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) {
342 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0); 387 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0);
343 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1); 388 registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1);
344 } 389 }
345 390
346 void RegisterProfilePrefsForSwReporter( 391 void RegisterProfilePrefsForSwReporter(
347 user_prefs::PrefRegistrySyncable* registry) { 392 user_prefs::PrefRegistrySyncable* registry) {
348 registry->RegisterIntegerPref( 393 registry->RegisterIntegerPref(
349 prefs::kSwReporterPromptReason, 394 prefs::kSwReporterPromptReason,
350 -1, 395 -1,
351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 396 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
352 397
353 registry->RegisterStringPref( 398 registry->RegisterStringPref(
354 prefs::kSwReporterPromptVersion, 399 prefs::kSwReporterPromptVersion,
355 "", 400 "",
356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 401 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
357 } 402 }
358 403
359 } // namespace component_updater 404 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698