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

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

Issue 296013005: [Metrics] Move Windows-specific CountBrowserCrashDumpAttempts() out of MetricsService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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/browser/metrics/chrome_metrics_service_client.h ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.h ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698