Index: chrome/browser/metrics/chrome_metrics_service_client.cc |
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc |
index b1c161d5bc73eb918639b7f7ab97953ccbd20507..ecb7dc733b96ada04381d4b3e5be95c31bcad87a 100644 |
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc |
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc |
@@ -9,6 +9,9 @@ |
#include "base/command_line.h" |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
+#include "base/strings/string16.h" |
+#include "base/strings/string_util.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "base/threading/platform_thread.h" |
#include "base/time/time.h" |
#include "chrome/browser/browser_process.h" |
@@ -17,6 +20,7 @@ |
#include "chrome/browser/memory_details.h" |
#include "chrome/browser/metrics/metrics_service.h" |
#include "chrome/browser/ui/browser_otr_state.h" |
+#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/chrome_version_info.h" |
#include "chrome/common/crash_keys.h" |
@@ -29,6 +33,12 @@ |
#include "chrome/browser/service_process/service_process_control.h" |
#endif |
+#if defined(OS_WIN) |
+#include <windows.h> |
+#include "base/win/registry.h" |
+#include "chrome/browser/metrics/google_update_metrics_provider_win.h" |
+#endif |
+ |
namespace { |
// This specifies the amount of time to wait for all renderers to send their |
@@ -82,6 +92,10 @@ ChromeMetricsServiceClient::ChromeMetricsServiceClient() |
DCHECK(thread_checker_.CalledOnValidThread()); |
RecordCommandLineMetrics(); |
RegisterForNotifications(); |
+ |
+#if defined(OS_WIN) |
+ CountBrowserCrashDumpAttempts(); |
+#endif // defined(OS_WIN) |
} |
ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { |
@@ -289,3 +303,55 @@ void ChromeMetricsServiceClient::StartGatheringMetrics( |
// TODO(blundell): Move metrics gathering tasks from MetricsService to here. |
done_callback.Run(); |
} |
+ |
+#if defined(OS_WIN) |
+void ChromeMetricsServiceClient::CountBrowserCrashDumpAttempts() { |
+ // Open the registry key for iteration. |
+ base::win::RegKey regkey; |
+ if (regkey.Open(HKEY_CURRENT_USER, |
+ chrome::kBrowserCrashDumpAttemptsRegistryPath, |
+ KEY_ALL_ACCESS) != ERROR_SUCCESS) { |
+ return; |
+ } |
+ |
+ // 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, &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; |
+ } |
+ } |
+ |
+ // 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) |