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

Unified Diff: chrome/browser/browser_main_gtk.cc

Issue 3175038: Allow overriding of X error functions (Closed)
Patch Set: Messed up #ifdef Created 10 years, 3 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/browser_main_gtk.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_main_gtk.cc
diff --git a/chrome/browser/browser_main_gtk.cc b/chrome/browser/browser_main_gtk.cc
index 520c652bbd7053e4c712bb2a913c6cf30e05b345..25147c8df1567ff4cbe6e3d1e20b63496d30b631 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);
+}
« no previous file with comments | « chrome/browser/browser_main_gtk.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698