summaryrefslogtreecommitdiffstats
path: root/base/message_pump_glib.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:40:05 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:40:05 +0000
commit05062e288e4b8f174a79cc698c3c97d7d12975be (patch)
tree2770b53fd364edea767213167b6703d4e8cc7251 /base/message_pump_glib.h
parentd90eaa38f5cd59970b50491b7e5bda8b230614b7 (diff)
downloadchromium_src-05062e288e4b8f174a79cc698c3c97d7d12975be.zip
chromium_src-05062e288e4b8f174a79cc698c3c97d7d12975be.tar.gz
chromium_src-05062e288e4b8f174a79cc698c3c97d7d12975be.tar.bz2
Adds an observer callback to Linux's MessagePumpForUI.
BUG=none TEST=none Review URL: http://codereview.chromium.org/112029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib.h')
-rw-r--r--base/message_pump_glib.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h
index d25ae86..c8a2e0d 100644
--- a/base/message_pump_glib.h
+++ b/base/message_pump_glib.h
@@ -5,9 +5,11 @@
#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/time.h"
namespace base {
@@ -16,6 +18,16 @@ namespace base {
// OS_LINUX platforms using GLib.
class MessagePumpForUI : public MessagePump {
public:
+ // Observer is notified prior to a GdkEvent event being dispatched. As
+ // Observers are notified of every change, they have to be FAST!
+ class Observer {
+ public:
+ virtual ~Observer() {}
+
+ // This method is called before processing a message.
+ virtual void WillProcessEvent(GdkEvent* event) = 0;
+ };
+
MessagePumpForUI();
~MessagePumpForUI();
@@ -32,6 +44,13 @@ class MessagePumpForUI : public MessagePump {
int HandlePrepare();
void HandleDispatch();
+ // Add an Observer, which will start receiving notifications immediately.
+ void AddObserver(Observer* observer);
+
+ // Remove an Observer. It is safe to call this method while an Observer is
+ // receiving a notification callback.
+ void RemoveObserver(Observer* observer);
+
private:
// We may make recursive calls to Run, so we save state that needs to be
// separate between them in this structure type.
@@ -49,6 +68,13 @@ class MessagePumpForUI : public MessagePump {
bool more_work_is_plausible;
};
+ // Invoked from EventDispatcher. Notifies all observers we're about to
+ // process an event.
+ void WillProcessEvent(GdkEvent* event);
+
+ // Callback prior to gdk dispatching an event.
+ static void EventDispatcher(GdkEvent* event, gpointer data);
+
RunState* state_;
// This is a GLib structure that we can add event sources to. We use the
@@ -71,6 +97,9 @@ class MessagePumpForUI : public MessagePump {
int wakeup_pipe_write_;
GPollFD wakeup_gpollfd_;
+ // List of observers.
+ ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
};