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

Unified Diff: chrome/browser/metrics/metrics_service.cc

Issue 23453032: Chrome.BrowserCrashDumpAttempts needs to account for multiple dumps from the same browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retry git cl upload Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service.cc
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index b356a00dbb3d2c85966f560613760558055b2810..3fd4301bf69ebe433615c63d9c65816266d4aedd 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -797,29 +797,53 @@ void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) {
#if defined(OS_WIN)
void MetricsService::CountBrowserCrashDumpAttempts() {
- base::string16 key_str(chrome::kBrowserCrashDumpAttemptsRegistryPath);
- key_str += L"\\";
- key_str += UTF8ToWide(chrome::kChromeVersion);
-
+ // Open the registry key for iteration.
base::win::RegKey regkey;
if (regkey.Open(HKEY_CURRENT_USER,
- key_str.c_str(),
+ chrome::kBrowserCrashDumpAttemptsRegistryPath,
KEY_ALL_ACCESS) != ERROR_SUCCESS) {
return;
}
- base::string16 temp_name;
- DWORD temp_value = 0;
- int crash_dump_attempts = 0;
+ // The values we're interested in counting are all prefixed with the version.
+ base::string16 chrome_version(base::ASCIIToUTF16(chrome::kChromeVersion));
+
+ // Track a list of values to delete. We don't modify the registry key while
+ // we're iterating over its values.
+ typedef std::vector<base::string16> StringVector;
+ StringVector to_delete;
+
+ // Iterate over the values in the key counting dumps with and without crashes.
+ // We directly walk the values instead of using RegistryValueIterator in order
+ // to read all of the values as DWORDS instead of strings.
+ base::string16 name;
+ DWORD value = 0;
+ int dumps_with_crash = 0;
+ int dumps_with_no_crash = 0;
for (int i = regkey.GetValueCount() - 1; i >= 0; --i) {
- if (regkey.GetValueNameAt(i, &temp_name) == ERROR_SUCCESS &&
- regkey.ReadValueDW(temp_name.c_str(), &temp_value) == ERROR_SUCCESS) {
- regkey.DeleteValue(temp_name.c_str());
- if (temp_value != 0)
- ++crash_dump_attempts;
+ if (regkey.GetValueNameAt(i, &name) == ERROR_SUCCESS &&
+ StartsWith(name, chrome_version, false) &&
+ regkey.ReadValueDW(name.c_str(), &value) == ERROR_SUCCESS) {
+ to_delete.push_back(name);
+ if (value == 0)
+ ++dumps_with_no_crash;
+ else
+ ++dumps_with_crash;
}
}
- UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", crash_dump_attempts);
+
+ // Delete the registry keys we've just counted.
+ for (StringVector::iterator i = to_delete.begin(); i != to_delete.end(); ++i)
+ regkey.DeleteValue(i->c_str());
+
+ // Capture the histogram samples.
+ if (dumps_with_crash != 0)
+ UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash);
+ if (dumps_with_no_crash != 0)
+ UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash);
+ int total_dumps = dumps_with_crash + dumps_with_no_crash;
+ if (total_dumps != 0)
+ UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps);
}
#endif // defined(OS_WIN)
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698