diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 20:45:54 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 20:45:54 +0000 |
commit | 831a32d135fdeeea1f906742074f3b72312e9669 (patch) | |
tree | c692080f8a9a25101e9adca2c8c3797233bf1eb6 /base | |
parent | f16785b4bbd3449580e7998d83a80b0b2fb6dcd1 (diff) | |
download | chromium_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
Diffstat (limited to 'base')
-rw-r--r-- | base/message_pump_glib.cc | 14 | ||||
-rw-r--r-- | base/message_pump_glib.h | 14 |
2 files changed, 18 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_; |