This source file includes following definitions.
- BrowserX11ErrorHandler
- WaitingForUIThreadToHandleIOError
- BrowserX11IOErrorHandler
- X11EmptyErrorHandler
- X11EmptyIOErrorHandler
- PreEarlyInitialization
- PostMainMessageLoopStart
- PostMainMessageLoopRun
#include "chrome/browser/chrome_browser_main_extra_parts_x11.h"
#include "base/bind.h"
#include "base/debug/debugger.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/common/chrome_result_codes.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/x/x11_util.h"
#include "ui/base/x/x11_util_internal.h"
using content::BrowserThread;
namespace {
bool g_in_x11_io_error_handler = false;
const int kWaitForUIThreadSeconds = 10;
int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) {
if (!g_in_x11_io_error_handler)
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ui::LogErrorEventDescription, d, *error));
return 0;
}
NOINLINE void WaitingForUIThreadToHandleIOError() {
asm("");
sleep(kWaitForUIThreadSeconds);
}
int BrowserX11IOErrorHandler(Display* d) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
WaitingForUIThreadToHandleIOError();
return 0;
}
if (!g_in_x11_io_error_handler) {
g_in_x11_io_error_handler = true;
LOG(ERROR) << "X IO error received (X server probably went away)";
chrome::SessionEnding();
}
return 0;
}
int X11EmptyErrorHandler(Display* d, XErrorEvent* error) {
return 0;
}
int X11EmptyIOErrorHandler(Display* d) {
return 0;
}
}
ChromeBrowserMainExtraPartsX11::ChromeBrowserMainExtraPartsX11() {
}
ChromeBrowserMainExtraPartsX11::~ChromeBrowserMainExtraPartsX11() {
}
void ChromeBrowserMainExtraPartsX11::PreEarlyInitialization() {
ui::SetX11ErrorHandlers(NULL, NULL);
}
void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() {
ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler);
}
void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() {
ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
}