OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_MESSAGE_PUMP_WAYLAND_H_ | 5 #ifndef BASE_MESSAGE_PUMP_WAYLAND_H_ |
6 #define BASE_MESSAGE_PUMP_WAYLAND_H_ | 6 #define BASE_MESSAGE_PUMP_WAYLAND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_pump_glib.h" | 10 #include "base/message_pump_glib.h" |
11 #include "base/message_pump_observer.h" | 11 #include "base/message_pump_observer.h" |
12 | 12 |
| 13 typedef struct _GMainContext GMainContext; |
| 14 typedef struct _GPollFD GPollFD; |
| 15 typedef struct _GSource GSource; |
| 16 |
13 namespace base { | 17 namespace base { |
14 | 18 |
15 namespace wayland { | 19 namespace wayland { |
16 union WaylandEvent; | 20 union WaylandEvent; |
17 } | 21 } |
18 | 22 |
19 // The documentation for this class is in message_pump_glib.h | 23 // The documentation for this class is in message_pump_glib.h |
20 // | 24 // |
21 // The nested loop is exited by either posting a quit, or returning false | 25 // The nested loop is exited by either posting a quit, or returning false |
22 // from Dispatch. | 26 // from Dispatch. |
23 class MessagePumpDispatcher { | 27 class MessagePumpDispatcher { |
24 public: | 28 public: |
25 enum DispatchStatus { | 29 enum DispatchStatus { |
26 EVENT_IGNORED, // The event was not processed. | 30 EVENT_IGNORED, // The event was not processed. |
27 EVENT_PROCESSED, // The event has been processed. | 31 EVENT_PROCESSED, // The event has been processed. |
28 EVENT_QUIT // The event was processed and the message-loop should | 32 EVENT_QUIT // The event was processed and the message-loop should |
29 // terminate. | 33 // terminate. |
30 }; | 34 }; |
31 | 35 |
32 // Dispatches the event. If true is returned processing continues as | 36 // Dispatches the event. If true is returned processing continues as |
33 // normal. If false is returned, the nested loop exits immediately. | 37 // normal. If false is returned, the nested loop exits immediately. |
34 virtual DispatchStatus Dispatch(wayland::WaylandEvent* event) = 0; | 38 virtual DispatchStatus Dispatch(wayland::WaylandEvent* event) = 0; |
35 | 39 |
36 protected: | 40 protected: |
37 virtual ~MessagePumpDispatcher() {} | 41 virtual ~MessagePumpDispatcher() {} |
38 }; | 42 }; |
39 | 43 |
40 typedef MessagePumpGlib MessagePumpForUI; | 44 class BASE_EXPORT MessagePumpWayland : public MessagePumpGlib { |
| 45 |
| 46 public: |
| 47 MessagePumpWayland(); |
| 48 virtual ~MessagePumpWayland(); |
| 49 |
| 50 // Overridden from MessagePumpGlib |
| 51 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; |
| 52 private: |
| 53 |
| 54 // This is a GLib structure that we can add event sources to. |
| 55 GMainContext* context_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(MessagePumpWayland); |
| 58 }; |
| 59 |
| 60 typedef MessagePumpWayland MessagePumpForUI; |
41 | 61 |
42 } // namespace base | 62 } // namespace base |
43 | 63 |
44 #endif // BASE_MESSAGE_PUMP_WAYLAND_H_ | 64 #endif // BASE_MESSAGE_PUMP_WAYLAND_H_ |
OLD | NEW |