| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" | 5 #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/debugger.h" | 8 #include "base/debug/debugger.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/browser_shutdown.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
| 11 #include "chrome/common/chrome_result_codes.h" | 12 #include "chrome/common/chrome_result_codes.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "ui/base/x/x11_util.h" | 14 #include "ui/base/x/x11_util.h" |
| 14 #include "ui/base/x/x11_util_internal.h" | 15 #include "ui/base/x/x11_util_internal.h" |
| 15 | 16 |
| 16 using content::BrowserThread; | 17 using content::BrowserThread; |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 // to get the error. We can't call shutdown from this thread without | 48 // to get the error. We can't call shutdown from this thread without |
| 48 // tripping an error. Doing it through a function so that we'll be able | 49 // tripping an error. Doing it through a function so that we'll be able |
| 49 // to see it in any crash dumps. | 50 // to see it in any crash dumps. |
| 50 WaitingForUIThreadToHandleIOError(); | 51 WaitingForUIThreadToHandleIOError(); |
| 51 return 0; | 52 return 0; |
| 52 } | 53 } |
| 53 // If there's an IO error it likely means the X server has gone away | 54 // If there's an IO error it likely means the X server has gone away |
| 54 if (!g_in_x11_io_error_handler) { | 55 if (!g_in_x11_io_error_handler) { |
| 55 g_in_x11_io_error_handler = true; | 56 g_in_x11_io_error_handler = true; |
| 56 LOG(ERROR) << "X IO error received (X server probably went away)"; | 57 LOG(ERROR) << "X IO error received (X server probably went away)"; |
| 58 browser_shutdown::SetShuttingDownWithoutClosingBrowsers(true); |
| 57 chrome::SessionEnding(); | 59 chrome::SessionEnding(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 return 0; | 62 return 0; |
| 61 } | 63 } |
| 62 | 64 |
| 63 int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { | 65 int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { |
| 64 return 0; | 66 return 0; |
| 65 } | 67 } |
| 66 | 68 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 89 // if X exits before us. | 91 // if X exits before us. |
| 90 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); | 92 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); |
| 91 } | 93 } |
| 92 | 94 |
| 93 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { | 95 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { |
| 94 // Unset the X11 error handlers. The X11 error handlers log the errors using a | 96 // Unset the X11 error handlers. The X11 error handlers log the errors using a |
| 95 // |PostTask()| on the message-loop. But since the message-loop is in the | 97 // |PostTask()| on the message-loop. But since the message-loop is in the |
| 96 // process of terminating, this can cause errors. | 98 // process of terminating, this can cause errors. |
| 97 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); | 99 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); |
| 98 } | 100 } |
| OLD | NEW |