x11: Remove X11 message-pump.

The remaining use of the X11 mesage-pump was opening the connection to the
X11 server. This patch moves that out of the message-pump, into gfx. This
allows us to remove the X11 message-pump, and just use the base Glib-based
message-pump on Linux and ChromeOS.

BUG=354062
R=darin@chromium.org, sky@chromium.org

Previously landed in r263726, but reverted in r263733 to allow reverting another CL.

Review URL: https://codereview.chromium.org/235043005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263777 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 82f884d6ffb1406788add09179de956d1d53c19a
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 6539c65..07f9105 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -34,14 +34,10 @@
 #include "base/message_loop/message_pump_libevent.h"
 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
 
-#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
-#include "base/message_loop/message_pump_x11.h"
+#if defined(USE_GLIB) && !defined(OS_NACL)
+#include "base/message_loop/message_pump_glib.h"
 #elif !defined(OS_ANDROID_HOST)
-#define USE_GTK_MESSAGE_PUMP
-#include "base/message_loop/message_pump_gtk.h"
-#if defined(TOOLKIT_GTK)
-#include "base/message_loop/message_pump_x11.h"
-#endif
+#include "base/message_loop/message_pump_glib.h"
 #endif
 
 #endif
@@ -95,8 +91,6 @@
  public:
 #if defined(OS_WIN)
   typedef MessagePumpObserver Observer;
-#elif defined(USE_GTK_MESSAGE_PUMP)
-  typedef MessagePumpGdkObserver Observer;
 #endif
 
   // A MessageLoop has a particular type, which indicates the set of
@@ -413,13 +407,6 @@
   MessagePumpLibevent* pump_libevent() {
     return static_cast<MessagePumpLibevent*>(pump_.get());
   }
-#if defined(TOOLKIT_GTK)
-  friend class MessagePumpX11;
-  MessagePumpX11* pump_gpu() {
-    DCHECK_EQ(TYPE_GPU, type());
-    return static_cast<MessagePumpX11*>(pump_.get());
-  }
-#endif
 #endif
 
   scoped_ptr<MessagePump> pump_;
@@ -593,10 +580,6 @@
 #endif
 
  protected:
-#if defined(USE_X11)
-  friend class MessagePumpX11;
-#endif
-
 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
   // TODO(rvargas): Make this platform independent.
   MessagePumpForUI* pump_ui() {
diff --git a/base/message_loop/message_pump_glib.h b/base/message_loop/message_pump_glib.h
index 0211b0f..9acc472 100644
--- a/base/message_loop/message_pump_glib.h
+++ b/base/message_loop/message_pump_glib.h
@@ -94,6 +94,8 @@
   DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
 };
 
+typedef MessagePumpGlib MessagePumpForUI;
+
 }  // namespace base
 
 #endif  // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
diff --git a/base/message_loop/message_pump_x11.cc b/base/message_loop/message_pump_x11.cc
deleted file mode 100644
index fb40b1d..0000000
--- a/base/message_loop/message_pump_x11.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/message_loop/message_pump_x11.h"
-
-#include <glib.h>
-#include <X11/X.h>
-#include <X11/extensions/XInput2.h>
-#include <X11/XKBlib.h>
-
-#include "base/basictypes.h"
-#include "base/message_loop/message_loop.h"
-
-namespace base {
-
-namespace {
-
-// The connection is essentially a global that's accessed through a static
-// method and destroyed whenever ~MessagePumpX11() is called. We do this
-// for historical reasons so user code can call
-// MessagePumpForUI::GetDefaultXDisplay() where MessagePumpForUI is a typedef
-// to whatever type in the current build.
-//
-// TODO(erg): This can be changed to something more sane like
-// MessagePumpX11::Current()->display() once MessagePumpGtk goes away.
-Display* g_xdisplay = NULL;
-
-}  // namespace
-
-MessagePumpX11::MessagePumpX11() : MessagePumpGlib() {
-  GetDefaultXDisplay();
-}
-
-MessagePumpX11::~MessagePumpX11() {
-  if (g_xdisplay) {
-    XCloseDisplay(g_xdisplay);
-    g_xdisplay = NULL;
-  }
-}
-
-// static
-Display* MessagePumpX11::GetDefaultXDisplay() {
-  if (!g_xdisplay)
-    g_xdisplay = XOpenDisplay(NULL);
-  return g_xdisplay;
-}
-
-#if defined(TOOLKIT_GTK)
-// static
-MessagePumpX11* MessagePumpX11::Current() {
-  MessageLoop* loop = MessageLoop::current();
-  return static_cast<MessagePumpX11*>(loop->pump_gpu());
-}
-#else
-// static
-MessagePumpX11* MessagePumpX11::Current() {
-  MessageLoopForUI* loop = MessageLoopForUI::current();
-  return static_cast<MessagePumpX11*>(loop->pump_ui());
-}
-#endif
-
-}  // namespace base
diff --git a/base/message_loop/message_pump_x11.h b/base/message_loop/message_pump_x11.h
deleted file mode 100644
index 5fdfeea..0000000
--- a/base/message_loop/message_pump_x11.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
-#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
-
-#include <bitset>
-#include <map>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_pump.h"
-#include "base/message_loop/message_pump_glib.h"
-#include "base/observer_list.h"
-
-typedef struct _XDisplay Display;
-
-namespace base {
-
-// This class implements a message-pump for dispatching X events.
-class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib {
- public:
-  MessagePumpX11();
-  virtual ~MessagePumpX11();
-
-  // Returns default X Display.
-  static Display* GetDefaultXDisplay();
-
-  // Returns the UI or GPU message pump.
-  static MessagePumpX11* Current();
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(MessagePumpX11);
-};
-
-#if !defined(TOOLKIT_GTK)
-typedef MessagePumpX11 MessagePumpForUI;
-#endif
-
-}  // namespace base
-
-#endif  // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H