summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 20:45:54 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 20:45:54 +0000
commit831a32d135fdeeea1f906742074f3b72312e9669 (patch)
treec692080f8a9a25101e9adca2c8c3797233bf1eb6
parentf16785b4bbd3449580e7998d83a80b0b2fb6dcd1 (diff)
downloadchromium_src-831a32d135fdeeea1f906742074f3b72312e9669.zip
chromium_src-831a32d135fdeeea1f906742074f3b72312e9669.tar.gz
chromium_src-831a32d135fdeeea1f906742074f3b72312e9669.tar.bz2
Avoid including gtk & glib headers in message_pump_glib.h, saves 1 sec on do-nothing make.
TEST=manual browser test, trybots BUG=none Review URL: http://codereview.chromium.org/464031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33851 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/message_pump_glib.cc14
-rw-r--r--base/message_pump_glib.h14
-rw-r--r--chrome/browser/extensions/browser_action_apitest.cc6
-rw-r--r--chrome/browser/gtk/first_run_dialog.h2
-rw-r--r--chrome/browser/gtk/view_id_util_browsertest.cc2
-rw-r--r--chrome/plugin/plugin_thread.cc4
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc4
-rw-r--r--chrome/test/ui_test_utils_linux.cc2
8 files changed, 38 insertions, 10 deletions
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index 6f050ba..29bc64e 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -7,6 +7,9 @@
#include <fcntl.h>
#include <math.h>
+#include <gtk/gtk.h>
+#include <glib.h>
+
#include "base/eintr_wrapper.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
@@ -124,18 +127,19 @@ namespace base {
MessagePumpForUI::MessagePumpForUI()
: state_(NULL),
- context_(g_main_context_default()) {
+ context_(g_main_context_default()),
+ wakeup_gpollfd_(new GPollFD) {
// Create our wakeup pipe, which is used to flag when work was scheduled.
int fds[2];
CHECK(pipe(fds) == 0);
wakeup_pipe_read_ = fds[0];
wakeup_pipe_write_ = fds[1];
- wakeup_gpollfd_.fd = wakeup_pipe_read_;
- wakeup_gpollfd_.events = G_IO_IN;
+ wakeup_gpollfd_->fd = wakeup_pipe_read_;
+ wakeup_gpollfd_->events = G_IO_IN;
work_source_ = g_source_new(&WorkSourceFuncs, sizeof(WorkSource));
static_cast<WorkSource*>(work_source_)->pump = this;
- g_source_add_poll(work_source_, &wakeup_gpollfd_);
+ g_source_add_poll(work_source_, wakeup_gpollfd_.get());
// Use a low priority so that we let other events in the queue go first.
g_source_set_priority(work_source_, G_PRIORITY_DEFAULT_IDLE);
// This is needed to allow Run calls inside Dispatch.
@@ -229,7 +233,7 @@ bool MessagePumpForUI::HandleCheck() {
// We should only ever have a single message on the wakeup pipe, since we
// are only signaled when the queue went from empty to non-empty. The glib
// poll will tell us whether there was data, so this read shouldn't block.
- if (wakeup_gpollfd_.revents & G_IO_IN) {
+ if (wakeup_gpollfd_->revents & G_IO_IN) {
char msg;
if (HANDLE_EINTR(read(wakeup_pipe_read_, &msg, 1)) != 1 || msg != '!') {
NOTREACHED() << "Error reading from the wakeup pipe.";
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h
index 08e1964..d140dbf 100644
--- a/base/message_pump_glib.h
+++ b/base/message_pump_glib.h
@@ -5,13 +5,16 @@
#ifndef BASE_MESSAGE_PUMP_GLIB_H_
#define BASE_MESSAGE_PUMP_GLIB_H_
-#include <gtk/gtk.h>
-#include <glib.h>
-
#include "base/message_pump.h"
#include "base/observer_list.h"
+#include "base/scoped_ptr.h"
#include "base/time.h"
+typedef union _GdkEvent GdkEvent;
+typedef struct _GMainContext GMainContext;
+typedef struct _GPollFD GPollFD;
+typedef struct _GSource GSource;
+
namespace base {
// This class implements a MessagePump needed for TYPE_UI MessageLoops on
@@ -103,7 +106,7 @@ class MessagePumpForUI : public MessagePump {
void DidProcessEvent(GdkEvent* event);
// Callback prior to gdk dispatching an event.
- static void EventDispatcher(GdkEvent* event, gpointer data);
+ static void EventDispatcher(GdkEvent* event, void* data);
RunState* state_;
@@ -125,7 +128,8 @@ class MessagePumpForUI : public MessagePump {
// Dispatch() will be called.
int wakeup_pipe_read_;
int wakeup_pipe_write_;
- GPollFD wakeup_gpollfd_;
+ // Use a scoped_ptr to avoid needing the definition of GPollFD in the header.
+ scoped_ptr<GPollFD> wakeup_gpollfd_;
// List of observers.
ObserverList<Observer> observers_;
diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc
index 37802c7..2636b2f 100644
--- a/chrome/browser/extensions/browser_action_apitest.cc
+++ b/chrome/browser/extensions/browser_action_apitest.cc
@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
+#if defined(TOOLKIT_GTK)
+#include <gtk/gtk.h>
+#endif
+
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/extension_apitest.h"
diff --git a/chrome/browser/gtk/first_run_dialog.h b/chrome/browser/gtk/first_run_dialog.h
index 1f97fe91..b0f7e61 100644
--- a/chrome/browser/gtk/first_run_dialog.h
+++ b/chrome/browser/gtk/first_run_dialog.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_GTK_FIRST_RUN_DIALOG_H_
#define CHROME_BROWSER_GTK_FIRST_RUN_DIALOG_H_
+#include <gtk/gtk.h>
+
#include "chrome/browser/first_run.h"
#include "chrome/browser/importer/importer.h"
diff --git a/chrome/browser/gtk/view_id_util_browsertest.cc b/chrome/browser/gtk/view_id_util_browsertest.cc
index fe50605..ba5fe83 100644
--- a/chrome/browser/gtk/view_id_util_browsertest.cc
+++ b/chrome/browser/gtk/view_id_util_browsertest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <gtk/gtk.h>
+
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/gtk/view_id_util.h"
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 9ef6c45..91c763b 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -6,6 +6,10 @@
#include "build/build_config.h"
+#if defined(OS_LINUX)
+#include <gtk/gtk.h>
+#endif
+
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/process_util.h"
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 2e24172..66aa755 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -6,6 +6,10 @@
#include <algorithm>
+#if defined(OS_LINUX)
+#include <gtk/gtk.h>
+#endif
+
#include "app/gfx/blit.h"
#include "app/gfx/canvas.h"
#include "app/gfx/native_widget_types.h"
diff --git a/chrome/test/ui_test_utils_linux.cc b/chrome/test/ui_test_utils_linux.cc
index 95f757e..ddcd1b8 100644
--- a/chrome/test/ui_test_utils_linux.cc
+++ b/chrome/test/ui_test_utils_linux.cc
@@ -4,6 +4,8 @@
#include "chrome/test/ui_test_utils.h"
+#include <gtk/gtk.h>
+
#include "base/logging.h"
#include "base/message_loop.h"
#include "chrome/browser/browser.h"