Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_MESSAGE_PUMP_WAYLAND_H_ | |
| 6 #define BASE_MESSAGE_PUMP_WAYLAND_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/message_pump_glib.h" | |
| 11 | |
| 12 typedef struct _GMainContext GMainContext; | |
| 13 typedef struct _GPollFD GPollFD; | |
| 14 typedef struct _GSource GSource; | |
|
Evan Martin
2011/07/21 16:44:21
ChromeOS seems to be trying to get rid of glib. I
| |
| 15 | |
| 16 typedef union _WaylandEvent WaylandEvent; | |
| 17 | |
| 18 namespace base { | |
| 19 | |
| 20 // The documentation for this class is in message_pump_glib.h | |
| 21 class MessagePumpObserver { | |
| 22 public: | |
| 23 enum EventStatus { | |
| 24 EVENT_CONTINUE, // The event should be dispatched as normal. | |
| 25 EVENT_HANDLED // The event should not be processed any farther. | |
| 26 }; | |
| 27 | |
| 28 // This method is called before processing an Event. If the method returns | |
| 29 // EVENT_HANDLED, it indicates the event has already been handled, so the | |
| 30 // event is not processed any farther. If the method returns EVENT_CONTINUE, | |
| 31 // the event dispatching proceeds as normal. | |
| 32 virtual EventStatus WillProcessEvent(WaylandEvent* event); | |
| 33 | |
| 34 protected: | |
| 35 virtual ~MessagePumpObserver() {} | |
| 36 }; | |
| 37 | |
| 38 // The documentation for this class is in message_pump_glib.h | |
| 39 // | |
| 40 // The nested loop is exited by either posting a quit, or returning false | |
| 41 // from Dispatch. | |
| 42 class MessagePumpDispatcher { | |
| 43 public: | |
| 44 enum DispatchStatus { | |
| 45 EVENT_IGNORED, // The event was not processed. | |
| 46 EVENT_PROCESSED, // The event has been processed. | |
| 47 EVENT_QUIT // The event was processed and the message-loop should | |
| 48 // terminate. | |
| 49 }; | |
| 50 | |
| 51 // Dispatches the event. If true is returned processing continues as | |
| 52 // normal. If false is returned, the nested loop exits immediately. | |
| 53 virtual DispatchStatus Dispatch(WaylandEvent* event) = 0; | |
| 54 | |
| 55 protected: | |
| 56 virtual ~MessagePumpDispatcher() {} | |
| 57 }; | |
| 58 | |
| 59 class MessagePumpWayland : public MessagePumpGlib { | |
| 60 | |
| 61 public: | |
| 62 MessagePumpWayland(); | |
| 63 virtual ~MessagePumpWayland(); | |
| 64 | |
| 65 // Overridden from MessagePumpGlib | |
| 66 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; | |
| 67 private: | |
| 68 | |
| 69 // This is a GLib structure that we can add event sources to. | |
| 70 GMainContext* context_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(MessagePumpWayland); | |
| 73 }; | |
| 74 | |
| 75 typedef MessagePumpWayland MessagePumpForUI; | |
| 76 | |
| 77 } // namespace base | |
| 78 | |
| 79 #endif | |
| OLD | NEW |