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

Side by Side Diff: chrome/browser/chrome_browser_main_extra_parts_x11.cc

Issue 2199063003: Linux: Add xcb FD to glib event loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « build/linux/system.gyp ('k') | chrome/installer/linux/debian/expected_deps_ia32 » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/threading/sequenced_task_runner_handle.h" 13 #include "base/threading/sequenced_task_runner_handle.h"
14 #include "chrome/browser/lifetime/application_lifetime.h" 14 #include "chrome/browser/lifetime/application_lifetime.h"
15 #include "chrome/common/chrome_result_codes.h" 15 #include "chrome/common/chrome_result_codes.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "ui/base/x/x11_util.h" 18 #include "ui/base/x/x11_util.h"
19 #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" 20 #include "ui/events/platform/x11/x11_event_source.h"
21 21
22 #ifdef USE_GLIB
23 #include "ui/base/x/x11_window_cache.h"
24 #include "ui/base/x/x11_window_cache_event_source.h"
25 #endif
26
22 using content::BrowserThread; 27 using content::BrowserThread;
23 28
24 namespace { 29 namespace {
25 30
26 // Indicates that we're currently responding to an IO error (by shutting down). 31 // Indicates that we're currently responding to an IO error (by shutting down).
27 bool g_in_x11_io_error_handler = false; 32 bool g_in_x11_io_error_handler = false;
28 33
29 // Number of seconds to wait for UI thread to get an IO error if we get it on 34 // Number of seconds to wait for UI thread to get an IO error if we get it on
30 // the background thread. 35 // the background thread.
31 const int kWaitForUIThreadSeconds = 10; 36 const int kWaitForUIThreadSeconds = 10;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // we can't shutdown properly while creating and initializing services. 96 // we can't shutdown properly while creating and initializing services.
92 ui::SetX11ErrorHandlers(NULL, NULL); 97 ui::SetX11ErrorHandlers(NULL, NULL);
93 } 98 }
94 99
95 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() { 100 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() {
96 // Installs the X11 error handlers for the browser process after the 101 // Installs the X11 error handlers for the browser process after the
97 // main message loop has started. This will allow us to exit cleanly 102 // main message loop has started. This will allow us to exit cleanly
98 // if X exits before us. 103 // if X exits before us.
99 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); 104 ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler);
100 105
106 new ui::XWindowCacheEventSource(new ui::XWindowCache(
107 gfx::GetXDisplay(), DefaultRootWindow(gfx::GetXDisplay())));
108
101 #if !defined(OS_CHROMEOS) 109 #if !defined(OS_CHROMEOS)
102 // It is possible for X11EventSource to not have been created (e.g. when 110 // It is possible for X11EventSource to not have been created (e.g. when
103 // running as a mus client). 111 // running as a mus client).
104 if (ui::X11EventSource::HasInstance()) { 112 if (ui::X11EventSource::HasInstance()) {
105 // Get a timestamp from the X server. This makes our requests to the server 113 // Get a timestamp from the X server. This makes our requests to the server
106 // less likely to be thrown away by the window manager. Put the timestamp 114 // less likely to be thrown away by the window manager. Put the timestamp
107 // in a command line flag so we can forward it to an existing browser 115 // in a command line flag so we can forward it to an existing browser
108 // process if necessary. 116 // process if necessary.
109 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 117 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
110 switches::kWmUserTimeMs, 118 switches::kWmUserTimeMs,
111 base::Uint64ToString( 119 base::Uint64ToString(
112 ui::X11EventSource::GetInstance()->UpdateLastSeenServerTime())); 120 ui::X11EventSource::GetInstance()->UpdateLastSeenServerTime()));
113 } 121 }
114 #endif 122 #endif
115 } 123 }
116 124
117 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { 125 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() {
118 // Unset the X11 error handlers. The X11 error handlers log the errors using a 126 // Unset the X11 error handlers. The X11 error handlers log the errors using a
119 // |PostTask()| on the message-loop. But since the message-loop is in the 127 // |PostTask()| on the message-loop. But since the message-loop is in the
120 // process of terminating, this can cause errors. 128 // process of terminating, this can cause errors.
121 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); 129 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
122 } 130 }
OLDNEW
« no previous file with comments | « build/linux/system.gyp ('k') | chrome/installer/linux/debian/expected_deps_ia32 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698