diff options
author | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 00:18:24 +0000 |
---|---|---|
committer | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-13 00:18:24 +0000 |
commit | e73c0197733c2b354d4f1c30153e64951593602a (patch) | |
tree | 9ff5e77f9ed53e9d4583b7ef1ae178ec1c771b16 /chrome/browser | |
parent | cdcd319904e1ef4323a98bf52d3ae8f7ae726c09 (diff) | |
download | chromium_src-e73c0197733c2b354d4f1c30153e64951593602a.zip chromium_src-e73c0197733c2b354d4f1c30153e64951593602a.tar.gz chromium_src-e73c0197733c2b354d4f1c30153e64951593602a.tar.bz2 |
Add a couple of metrics to help us quantify two cases that can prevent us to get crash reports.
- Added env_vars to exe project instead of keep duplicating the strings.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_main.cc | 12 | ||||
-rw-r--r-- | chrome/browser/metrics_log.cc | 12 | ||||
-rw-r--r-- | chrome/browser/metrics_service.cc | 74 | ||||
-rw-r--r-- | chrome/browser/metrics_service.h | 11 |
4 files changed, 77 insertions, 32 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 45308d9..c3531a2 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -61,6 +61,7 @@ #include "chrome/browser/shell_integration.h" #include "chrome/browser/url_fixer_upper.h" #include "chrome/browser/user_data_dir_dialog.h" +#include "chrome/browser/user_metrics.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -247,6 +248,15 @@ bool CreateUniqueChromeEvent() { return already_running; } +// We record in UMA the conditions that can prevent breakpad from generating +// and sending crash reports. Namely that the crash reporting registration +// failed and that the process is being debugged. +void RecordBreakpadStatusUMA(MetricsService* metrics) { + DWORD len = ::GetEnvironmentVariableW(env_vars::kNoOOBreakpad, NULL, 0); + metrics->RecordBreakpadRegistration((len == 0)); + metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); +} + } // namespace // Main routine for running as the Browser process. @@ -488,6 +498,8 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, HandleErrorTestParameters(parsed_command_line); + RecordBreakpadStatusUMA(metrics); + int result_code = ResultCodes::NORMAL_EXIT; if (BrowserInit::ProcessCommandLine(parsed_command_line, L"", local_state, show_command, true, profile, diff --git a/chrome/browser/metrics_log.cc b/chrome/browser/metrics_log.cc index a563ed5..eb0b5be 100644 --- a/chrome/browser/metrics_log.cc +++ b/chrome/browser/metrics_log.cc @@ -362,6 +362,18 @@ void MetricsLog::WriteStabilityElement() { WriteIntAttribute("rendererhangcount", pref->GetInteger(prefs::kStabilityRendererHangCount)); pref->SetInteger(prefs::kStabilityRendererHangCount, 0); + WriteIntAttribute("breakpadregistrationok", + pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess)); + pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); + WriteIntAttribute("breakpadregistrationfail", + pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail)); + pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); + WriteIntAttribute("debuggerpresent", + pref->GetInteger(prefs::kStabilityDebuggerPresent)); + pref->SetInteger(prefs::kStabilityDebuggerPresent, 0); + WriteIntAttribute("debuggernotpresent", + pref->GetInteger(prefs::kStabilityDebuggerNotPresent)); + pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); // Uptime is stored as a string, since there's no int64 in Value/JSON. WriteAttribute("uptimesec", diff --git a/chrome/browser/metrics_service.cc b/chrome/browser/metrics_service.cc index 268e57d..85690a8 100644 --- a/chrome/browser/metrics_service.cc +++ b/chrome/browser/metrics_service.cc @@ -327,6 +327,13 @@ void MetricsService::RegisterPrefs(PrefService* local_state) { local_state->RegisterIntegerPref(prefs::kSecurityRendererOnDefaultDesktop, 0); local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); local_state->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); + local_state->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, + 0); + local_state->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess, + 0); + local_state->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); + local_state->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); + local_state->RegisterDictionaryPref(prefs::kProfileMetrics); local_state->RegisterIntegerPref(prefs::kNumBookmarksOnBookmarkBar, 0); local_state->RegisterIntegerPref(prefs::kNumFoldersOnBookmarkBar, 0); @@ -486,6 +493,20 @@ void MetricsService::RecordCompletedSessionEnd() { RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true); } +void MetricsService:: RecordBreakpadRegistration(bool success) { + if (!success) + IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail); + else + IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess); +} + +void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) { + if (!has_debugger) + IncrementPrefValue(prefs::kStabilityDebuggerNotPresent); + else + IncrementPrefValue(prefs::kStabilityDebuggerPresent); +} + //------------------------------------------------------------------------------ // private methods //------------------------------------------------------------------------------ @@ -517,23 +538,17 @@ void MetricsService::InitializeMetricsState() { DCHECK(done); // Stability bookkeeping - int launches = pref->GetInteger(prefs::kStabilityLaunchCount); - pref->SetInteger(prefs::kStabilityLaunchCount, launches + 1); + IncrementPrefValue(prefs::kStabilityLaunchCount); - bool exited_cleanly = pref->GetBoolean(prefs::kStabilityExitedCleanly); - if (!exited_cleanly) { - int crashes = pref->GetInteger(prefs::kStabilityCrashCount); - pref->SetInteger(prefs::kStabilityCrashCount, crashes + 1); + if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { + IncrementPrefValue(prefs::kStabilityCrashCount); } + + // This will be set to 'true' if we exit cleanly. pref->SetBoolean(prefs::kStabilityExitedCleanly, false); - bool shutdown_cleanly = - pref->GetBoolean(prefs::kStabilitySessionEndCompleted); - if (!shutdown_cleanly) { - int incomplete_session_end_count = pref->GetInteger( - prefs::kStabilityIncompleteSessionEndCount); - pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, - incomplete_session_end_count + 1); + if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { + IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); } // This is marked false when we get a WM_ENDSESSION. pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); @@ -1219,11 +1234,15 @@ void MetricsService::LogLoadComplete(NotificationType type, load_details->load_time()); } +void MetricsService::IncrementPrefValue(const wchar_t* path) { + PrefService* pref = g_browser_process->local_state(); + DCHECK(pref); + int value = pref->GetInteger(path); + pref->SetInteger(path, value + 1); +} + void MetricsService::LogLoadStarted() { - PrefService* prefs = g_browser_process->local_state(); - DCHECK(prefs); - int loads = prefs->GetInteger(prefs::kStabilityPageLoadCount); - prefs->SetInteger(prefs::kStabilityPageLoadCount, loads + 1); + IncrementPrefValue(prefs::kStabilityPageLoadCount); // We need to save the prefs, as page load count is a critical stat, and // it might be lost due to a crash :-(. } @@ -1231,27 +1250,18 @@ void MetricsService::LogLoadStarted() { void MetricsService::LogRendererInSandbox(bool on_sandbox_desktop) { PrefService* prefs = g_browser_process->local_state(); DCHECK(prefs); - if (on_sandbox_desktop) { - int count = prefs->GetInteger(prefs::kSecurityRendererOnSboxDesktop); - prefs->SetInteger(prefs::kSecurityRendererOnSboxDesktop, count + 1); - } else { - int count = prefs->GetInteger(prefs::kSecurityRendererOnDefaultDesktop); - prefs->SetInteger(prefs::kSecurityRendererOnDefaultDesktop, count + 1); - } + if (on_sandbox_desktop) + IncrementPrefValue(prefs::kSecurityRendererOnSboxDesktop); + else + IncrementPrefValue(prefs::kSecurityRendererOnDefaultDesktop); } void MetricsService::LogRendererCrash() { - PrefService* prefs = g_browser_process->local_state(); - DCHECK(prefs); - int crashes = prefs->GetInteger(prefs::kStabilityRendererCrashCount); - prefs->SetInteger(prefs::kStabilityRendererCrashCount, crashes + 1); + IncrementPrefValue(prefs::kStabilityRendererCrashCount); } void MetricsService::LogRendererHang() { - PrefService* prefs = g_browser_process->local_state(); - DCHECK(prefs); - int hangs = prefs->GetInteger(prefs::kStabilityRendererHangCount); - prefs->SetInteger(prefs::kStabilityRendererHangCount, hangs + 1); + IncrementPrefValue(prefs::kStabilityRendererHangCount); } void MetricsService::LogPluginChange(NotificationType type, diff --git a/chrome/browser/metrics_service.h b/chrome/browser/metrics_service.h index dc65d45..4524bc6 100644 --- a/chrome/browser/metrics_service.h +++ b/chrome/browser/metrics_service.h @@ -116,6 +116,14 @@ class MetricsService : public NotificationObserver, // that session end was successful. void RecordCompletedSessionEnd(); + // Saves in the preferences if the crash report registration was successful. + // This count is eventually send via UMA logs. + void RecordBreakpadRegistration(bool success); + + // Saves in the preferences if the browser is running under a debugger. + // This count is eventually send via UMA logs. + void RecordBreakpadHasDebugger(bool has_debugger); + // Callback to let us knew that the plugin list is warmed up. void OnGetPluginListTaskComplete(); @@ -226,6 +234,9 @@ class MetricsService : public NotificationObserver, const NotificationSource& source, const NotificationDetails& details); + // Reads, increments and then sets the specified integer preference. + void IncrementPrefValue(const wchar_t* path); + // Records a renderer process crash. void LogRendererCrash(); |