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.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.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/browser_shutdown.h" | 10 #include "chrome/browser/browser_shutdown.h" |
11 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
12 #include "chrome/browser/metrics/metrics_service.h" | |
13 #include "chrome/common/chrome_result_codes.h" | 12 #include "chrome/common/chrome_result_codes.h" |
14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
15 #include "ui/base/x/x11_util.h" | 14 #include "ui/base/x/x11_util.h" |
16 #include "ui/base/x/x11_util_internal.h" | 15 #include "ui/base/x/x11_util_internal.h" |
17 | 16 |
18 #if defined(USE_LINUX_BREAKPAD) | |
19 #include "chrome/app/breakpad_linux.h" | |
20 #endif | |
21 | |
22 using content::BrowserThread; | 17 using content::BrowserThread; |
23 | 18 |
24 namespace { | 19 namespace { |
25 | 20 |
26 // Indicates that we're currently responding to an IO error (by shutting down). | 21 // Indicates that we're currently responding to an IO error (by shutting down). |
27 bool g_in_x11_io_error_handler = false; | 22 bool g_in_x11_io_error_handler = false; |
28 | 23 |
29 // Number of seconds to wait for UI thread to get an IO error if we get it on | 24 // Number of seconds to wait for UI thread to get an IO error if we get it on |
30 // the background thread. | 25 // the background thread. |
31 const int kWaitForUIThreadSeconds = 10; | 26 const int kWaitForUIThreadSeconds = 10; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { | 65 int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { |
71 return 0; | 66 return 0; |
72 } | 67 } |
73 | 68 |
74 int X11EmptyIOErrorHandler(Display* d) { | 69 int X11EmptyIOErrorHandler(Display* d) { |
75 return 0; | 70 return 0; |
76 } | 71 } |
77 | 72 |
78 } // namespace | 73 } // namespace |
79 | 74 |
80 void RecordBreakpadStatusUMA(MetricsService* metrics) { | 75 ChromeBrowserMainExtraPartsX11::ChromeBrowserMainExtraPartsX11() { |
81 #if defined(USE_LINUX_BREAKPAD) | |
82 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); | |
83 #else | |
84 metrics->RecordBreakpadRegistration(false); | |
85 #endif | |
86 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); | |
87 } | 76 } |
88 | 77 |
89 void WarnAboutMinimumSystemRequirements() { | 78 ChromeBrowserMainExtraPartsX11::~ChromeBrowserMainExtraPartsX11() { |
90 // Nothing to warn about on X11 right now. | |
91 } | 79 } |
92 | 80 |
93 // From browser_main_win.h, stubs until we figure out the right thing... | 81 void ChromeBrowserMainExtraPartsX11::PreEarlyInitialization() { |
94 | 82 // Installs the X11 error handlers for the browser process used during |
95 int DoUninstallTasks(bool chrome_still_running) { | 83 // startup. They simply print error messages and exit because |
96 return content::RESULT_CODE_NORMAL_EXIT; | 84 // we can't shutdown properly while creating and initializing services. |
97 } | |
98 | |
99 void SetBrowserX11ErrorHandlersPreEarlyInitialization() { | |
100 // Use default error handlers during startup. | |
101 ui::SetX11ErrorHandlers(NULL, NULL); | 85 ui::SetX11ErrorHandlers(NULL, NULL); |
102 } | 86 } |
103 | 87 |
104 void SetBrowserX11ErrorHandlersPostMainMessageLoopStart() { | 88 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() { |
105 // Set up error handlers to make sure profile gets written if X server | 89 // Installs the X11 error handlers for the browser process after the |
106 // goes away. | 90 // main message loop has started. This will allow us to exit cleanly |
| 91 // if X exits before us. |
107 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); | 92 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); |
108 } | 93 } |
109 | 94 |
110 void UnsetBrowserX11ErrorHandlers() { | 95 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { |
| 96 // Unset the X11 error handlers. The X11 error handlers log the errors using a |
| 97 // |PostTask()| on the message-loop. But since the message-loop is in the |
| 98 // process of terminating, this can cause errors. |
111 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); | 99 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); |
112 } | 100 } |
OLD | NEW |