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

Unified Diff: base/message_loop/message_pump_gtk.h

Issue 23537016: gtk: Some code cleanup for the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_loop/message_pump_glib.cc ('k') | base/message_loop/message_pump_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_gtk.h
diff --git a/base/message_loop/message_pump_gtk.h b/base/message_loop/message_pump_gtk.h
index 947ab885afec34a61b2249c98c223da7af89eaff..b3c3b8c7415d603d19c8dd25c510b31df91b0fbe 100644
--- a/base/message_loop/message_pump_gtk.h
+++ b/base/message_loop/message_pump_gtk.h
@@ -13,7 +13,7 @@ typedef struct _XDisplay Display;
namespace base {
// The documentation for this class is in message_pump_glib.h
-class MessagePumpObserver {
+class MessagePumpGdkObserver {
public:
// This method is called before processing a message.
virtual void WillProcessEvent(GdkEvent* event) = 0;
@@ -22,21 +22,7 @@ class MessagePumpObserver {
virtual void DidProcessEvent(GdkEvent* event) = 0;
protected:
- virtual ~MessagePumpObserver() {}
-};
-
-// The documentation for this class is in message_pump_glib.h
-//
-// The nested loop is exited by either posting a quit, or returning false
-// from Dispatch.
-class MessagePumpDispatcher {
- public:
- // Dispatches the event. If true is returned processing continues as
- // normal. If false is returned, the nested loop exits immediately.
- virtual bool Dispatch(GdkEvent* event) = 0;
-
- protected:
- virtual ~MessagePumpDispatcher() {}
+ virtual ~MessagePumpGdkObserver() {}
};
// This class implements a message-pump for dispatching GTK events.
@@ -52,6 +38,13 @@ class BASE_EXPORT MessagePumpGtk : public MessagePumpGlib {
// Returns default X Display.
static Display* GetDefaultXDisplay();
+ // Adds an Observer, which will start receiving notifications immediately.
+ void AddObserver(MessagePumpGdkObserver* observer);
+
+ // Removes an Observer. It is safe to call this method while an Observer is
+ // receiving a notification callback.
+ void RemoveObserver(MessagePumpGdkObserver* observer);
+
private:
// Invoked from EventDispatcher. Notifies all observers we're about to
// process an event.
@@ -64,6 +57,9 @@ class BASE_EXPORT MessagePumpGtk : public MessagePumpGlib {
// Callback prior to gdk dispatching an event.
static void EventDispatcher(GdkEvent* event, void* data);
+ // List of observers.
+ ObserverList<MessagePumpGdkObserver> observers_;
+
DISALLOW_COPY_AND_ASSIGN(MessagePumpGtk);
};
« no previous file with comments | « base/message_loop/message_pump_glib.cc ('k') | base/message_loop/message_pump_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698