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/command_line.h" |
8 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
9 #include "base/location.h" | 10 #include "base/location.h" |
10 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" |
11 #include "base/threading/sequenced_task_runner_handle.h" | 13 #include "base/threading/sequenced_task_runner_handle.h" |
12 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
13 #include "chrome/common/chrome_result_codes.h" | 15 #include "chrome/common/chrome_result_codes.h" |
| 16 #include "chrome/common/chrome_switches.h" |
14 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
15 #include "ui/base/x/x11_util.h" | 18 #include "ui/base/x/x11_util.h" |
16 #include "ui/base/x/x11_util_internal.h" | 19 #include "ui/base/x/x11_util_internal.h" |
| 20 #include "ui/events/platform/x11/x11_event_source.h" |
17 | 21 |
18 using content::BrowserThread; | 22 using content::BrowserThread; |
19 | 23 |
20 namespace { | 24 namespace { |
21 | 25 |
22 // Indicates that we're currently responding to an IO error (by shutting down). | 26 // Indicates that we're currently responding to an IO error (by shutting down). |
23 bool g_in_x11_io_error_handler = false; | 27 bool g_in_x11_io_error_handler = false; |
24 | 28 |
25 // Number of seconds to wait for UI thread to get an IO error if we get it on | 29 // Number of seconds to wait for UI thread to get an IO error if we get it on |
26 // the background thread. | 30 // the background thread. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // startup. They simply print error messages and exit because | 90 // startup. They simply print error messages and exit because |
87 // we can't shutdown properly while creating and initializing services. | 91 // we can't shutdown properly while creating and initializing services. |
88 ui::SetX11ErrorHandlers(NULL, NULL); | 92 ui::SetX11ErrorHandlers(NULL, NULL); |
89 } | 93 } |
90 | 94 |
91 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() { | 95 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() { |
92 // Installs the X11 error handlers for the browser process after the | 96 // Installs the X11 error handlers for the browser process after the |
93 // main message loop has started. This will allow us to exit cleanly | 97 // main message loop has started. This will allow us to exit cleanly |
94 // if X exits before us. | 98 // if X exits before us. |
95 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); | 99 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); |
| 100 |
| 101 #if !defined(OS_CHROMEOS) |
| 102 // Get a timestamp from the X server. This makes our requests to the server |
| 103 // less likely to be thrown away by the window manager. Put the timestamp in |
| 104 // a command line flag so we can forward it to an existing browser process if |
| 105 // necessary. |
| 106 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 107 switches::kWmUserTimeMs, |
| 108 base::Uint64ToString( |
| 109 ui::X11EventSource::GetInstance()->UpdateServerTime())); |
| 110 #endif |
96 } | 111 } |
97 | 112 |
98 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { | 113 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { |
99 // Unset the X11 error handlers. The X11 error handlers log the errors using a | 114 // Unset the X11 error handlers. The X11 error handlers log the errors using a |
100 // |PostTask()| on the message-loop. But since the message-loop is in the | 115 // |PostTask()| on the message-loop. But since the message-loop is in the |
101 // process of terminating, this can cause errors. | 116 // process of terminating, this can cause errors. |
102 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); | 117 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); |
103 } | 118 } |
OLD | NEW |