diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 20:40:34 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 20:40:34 +0000 |
commit | e66d704b2fb60846d399cc45cee04d26573725ec (patch) | |
tree | b49c9dcae3598793e373ee9923c6fcade700a625 /chrome/browser/browser_main_gtk.cc | |
parent | c36a87afc467a1fd2eb4bb2309051bc8e45e4393 (diff) | |
download | chromium_src-e66d704b2fb60846d399cc45cee04d26573725ec.zip chromium_src-e66d704b2fb60846d399cc45cee04d26573725ec.tar.gz chromium_src-e66d704b2fb60846d399cc45cee04d26573725ec.tar.bz2 |
Allow overriding of X error functions
BUG=50006 (and various other reports)
TEST=Run chrome under nested window manager using Xephyr (see
http://code.google.com/p/chromium/wiki/LayoutTestsLinux)
use --enable-logging=stderr --log-level=0
kill xephyr
examine log. You should see
X IO Error detected
followed (not necessarily immediately) by
successfully saved /tmp/tx/Default/Preferences
successfully saved /tmp/tx/Local State
successfully saved /tmp/tx/Local State
successfully saved /tmp/tx/Default/Preferences
along with no crash.
There is a high ranking crash report on both linux and chromeos that happens whenever X sends an error to chrome. This change causes us to log and continue when we get a regular error from X. When we get an IO error, indicating X is gone, we attempt to shut down gracefully.
Review URL: http://codereview.chromium.org/3175038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main_gtk.cc')
-rw-r--r-- | chrome/browser/browser_main_gtk.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/browser_main_gtk.cc b/chrome/browser/browser_main_gtk.cc index 520c652..25147c8d 100644 --- a/chrome/browser/browser_main_gtk.cc +++ b/chrome/browser/browser_main_gtk.cc @@ -4,8 +4,12 @@ #include "chrome/browser/browser_main.h" +#include "app/x11_util.h" +#include "app/x11_util_internal.h" #include "base/command_line.h" #include "base/debug_util.h" +#include "chrome/browser/browser_list.h" +#include "chrome/browser/browser_main_gtk.h" #include "chrome/browser/browser_main_win.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/result_codes.h" @@ -14,6 +18,30 @@ #include "chrome/app/breakpad_linux.h" #endif +namespace { + +// Indicates that we're currently responding to an IO error (by shutting down). +bool g_in_x11_io_error_handler = false; + +int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) { + if (!g_in_x11_io_error_handler) + LOG(ERROR) << x11_util::GetErrorEventDescription(error); + return 0; +} + +int BrowserX11IOErrorHandler(Display* d) { + // If there's an IO error it likely means the X server has gone away + if (!g_in_x11_io_error_handler) { + g_in_x11_io_error_handler = true; + LOG(ERROR) << "X IO Error detected"; + BrowserList::WindowsSessionEnding(); + } + + return 0; +} + +} // namespace + void DidEndMainMessageLoop() { } @@ -46,3 +74,11 @@ bool CheckMachineLevelInstall() { void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { } + +void SetBrowserX11ErrorHandlers() { + // Set up error handlers to make sure profile gets written if X server + // goes away. + x11_util::SetX11ErrorHandlers( + BrowserX11ErrorHandler, + BrowserX11IOErrorHandler); +} |