diff options
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/breakpad.cc | 26 | ||||
-rw-r--r-- | chrome/app/breakpad.h | 4 | ||||
-rw-r--r-- | chrome/app/main.cc | 3 |
3 files changed, 30 insertions, 3 deletions
diff --git a/chrome/app/breakpad.cc b/chrome/app/breakpad.cc index 6cbea27..26bafd7 100644 --- a/chrome/app/breakpad.cc +++ b/chrome/app/breakpad.cc @@ -108,8 +108,6 @@ const wchar_t kEnvShowRestart[] = L"CHROME_CRASHED"; const wchar_t kRtlLocaleDirection[] = L"RIGHT_TO_LEFT"; const wchar_t kLtrLocaleDirection[] = L"LEFT_TO_RIGHT"; -} // namespace - // This callback is executed when the browser process has crashed, after // the crash dump has been created. We need to minimize the amount of work // done here since we have potentially corrupted process. Our job is to @@ -137,6 +135,23 @@ bool DumpDoneCallback(const wchar_t*, const wchar_t*, void*, return true; } +// Previous unhandled filter. Will be called if not null when we +// intercept a crash. +LPTOP_LEVEL_EXCEPTION_FILTER previous_filter = NULL; + +// Exception filter used when breakpad is not enabled. We just display +// the "Do you want to restart" message and then we call the previous filter. +long WINAPI ChromeExceptionFilter(EXCEPTION_POINTERS* info) { + DumpDoneCallback(NULL, NULL, NULL, info, NULL, false); + + if (previous_filter) + return previous_filter(info); + + return EXCEPTION_EXECUTE_HANDLER; +} + +} // namespace + // This function is executed by the child process that DumpDoneCallback() // spawned and basically just shows the 'chrome has crashed' dialog if // the CHROME_CRASHED environment variable is present. @@ -221,9 +236,16 @@ unsigned __stdcall InitCrashReporterThread(void* param) { return 0; } +void InitDefaultCrashCallback() { + previous_filter = SetUnhandledExceptionFilter(ChromeExceptionFilter); +} + void InitCrashReporter(std::wstring dll_path) { CommandLine command; if (!command.HasSwitch(switches::kDisableBreakpad)) { + // Disable the message box for assertions. + _CrtSetReportMode(_CRT_ASSERT, 0); + // Query the custom_info now because if we do it in the thread it's going to // fail in the sandbox. The thread will delete this object. CrashReporterInfo* info = new CrashReporterInfo; diff --git a/chrome/app/breakpad.h b/chrome/app/breakpad.h index ad87567..2d0f9f8e 100644 --- a/chrome/app/breakpad.h +++ b/chrome/app/breakpad.h @@ -37,6 +37,10 @@ // or directly for the plugin and renderer process. void InitCrashReporter(std::wstring dll_path); +// Intercepts a crash but does not process it, just ask if we want to restart +// the browser or not. +void InitDefaultCrashCallback(); + // Initializes the crash reporter in chrome. unsigned __stdcall InitCrashReporterThread(void* param); diff --git a/chrome/app/main.cc b/chrome/app/main.cc index f309e17..cbcfdee 100644 --- a/chrome/app/main.cc +++ b/chrome/app/main.cc @@ -71,8 +71,9 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance, // Initialize the crash reporter. if (GoogleUpdateSettings::GetCollectStatsConsent()) { - _CrtSetReportMode(_CRT_ASSERT, 0); InitCrashReporter(client.GetDLLPath()); + } else { + InitDefaultCrashCallback(); } bool exit_now = false; |