Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / base / message_loop / message_pump_gtk.h
blobb3c3b8c7415d603d19c8dd25c510b31df91b0fbe
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_GTK_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GTK_H_
8 #include "base/message_loop/message_pump_glib.h"
10 typedef union _GdkEvent GdkEvent;
11 typedef struct _XDisplay Display;
13 namespace base {
15 // The documentation for this class is in message_pump_glib.h
16 class MessagePumpGdkObserver {
17 public:
18 // This method is called before processing a message.
19 virtual void WillProcessEvent(GdkEvent* event) = 0;
21 // This method is called after processing a message.
22 virtual void DidProcessEvent(GdkEvent* event) = 0;
24 protected:
25 virtual ~MessagePumpGdkObserver() {}
28 // This class implements a message-pump for dispatching GTK events.
29 class BASE_EXPORT MessagePumpGtk : public MessagePumpGlib {
30 public:
31 MessagePumpGtk();
32 virtual ~MessagePumpGtk();
34 // Dispatch an available GdkEvent. Essentially this allows a subclass to do
35 // some task before/after calling the default handler (EventDispatcher).
36 void DispatchEvents(GdkEvent* event);
38 // Returns default X Display.
39 static Display* GetDefaultXDisplay();
41 // Adds an Observer, which will start receiving notifications immediately.
42 void AddObserver(MessagePumpGdkObserver* observer);
44 // Removes an Observer. It is safe to call this method while an Observer is
45 // receiving a notification callback.
46 void RemoveObserver(MessagePumpGdkObserver* observer);
48 private:
49 // Invoked from EventDispatcher. Notifies all observers we're about to
50 // process an event.
51 void WillProcessEvent(GdkEvent* event);
53 // Invoked from EventDispatcher. Notifies all observers we processed an
54 // event.
55 void DidProcessEvent(GdkEvent* event);
57 // Callback prior to gdk dispatching an event.
58 static void EventDispatcher(GdkEvent* event, void* data);
60 // List of observers.
61 ObserverList<MessagePumpGdkObserver> observers_;
63 DISALLOW_COPY_AND_ASSIGN(MessagePumpGtk);
66 typedef MessagePumpGtk MessagePumpForUI;
68 } // namespace base
70 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GTK_H_