| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_GLIB_H_ | 5 #ifndef BASE_MESSAGE_PUMP_GLIB_H_ |
| 6 #define BASE_MESSAGE_PUMP_GLIB_H_ | 6 #define BASE_MESSAGE_PUMP_GLIB_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // normal. If false is returned, the nested loop exits immediately. | 50 // normal. If false is returned, the nested loop exits immediately. |
| 51 virtual bool Dispatch(GdkEvent* event) = 0; | 51 virtual bool Dispatch(GdkEvent* event) = 0; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 MessagePumpForUI(); | 54 MessagePumpForUI(); |
| 55 virtual ~MessagePumpForUI(); | 55 virtual ~MessagePumpForUI(); |
| 56 | 56 |
| 57 // Like MessagePump::Run, but GdkEvent objects are routed through dispatcher. | 57 // Like MessagePump::Run, but GdkEvent objects are routed through dispatcher. |
| 58 virtual void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher); | 58 virtual void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher); |
| 59 | 59 |
| 60 // Run a single iteration of the mainloop. A return value of true indicates |
| 61 // that an event was handled. |block| indicates if it should wait if no event |
| 62 // is ready for processing. |
| 63 virtual bool RunOnce(GMainContext* context, bool block); |
| 64 |
| 60 virtual void Run(Delegate* delegate) { RunWithDispatcher(delegate, NULL); } | 65 virtual void Run(Delegate* delegate) { RunWithDispatcher(delegate, NULL); } |
| 61 virtual void Quit(); | 66 virtual void Quit(); |
| 62 virtual void ScheduleWork(); | 67 virtual void ScheduleWork(); |
| 63 virtual void ScheduleDelayedWork(const Time& delayed_work_time); | 68 virtual void ScheduleDelayedWork(const Time& delayed_work_time); |
| 64 | 69 |
| 65 // Internal methods used for processing the pump callbacks. They are | 70 // Internal methods used for processing the pump callbacks. They are |
| 66 // public for simplicity but should not be used directly. HandlePrepare | 71 // public for simplicity but should not be used directly. HandlePrepare |
| 67 // is called during the prepare step of glib, and returns a timeout that | 72 // is called during the prepare step of glib, and returns a timeout that |
| 68 // will be passed to the poll. HandleCheck is called after the poll | 73 // will be passed to the poll. HandleCheck is called after the poll |
| 69 // has completed, and returns whether or not HandleDispatch should be called. | 74 // has completed, and returns whether or not HandleDispatch should be called. |
| 70 // HandleDispatch is called if HandleCheck returned true. | 75 // HandleDispatch is called if HandleCheck returned true. |
| 71 int HandlePrepare(); | 76 int HandlePrepare(); |
| 72 bool HandleCheck(); | 77 bool HandleCheck(); |
| 73 void HandleDispatch(); | 78 void HandleDispatch(); |
| 74 | 79 |
| 75 // Adds an Observer, which will start receiving notifications immediately. | 80 // Adds an Observer, which will start receiving notifications immediately. |
| 76 void AddObserver(Observer* observer); | 81 void AddObserver(Observer* observer); |
| 77 | 82 |
| 78 // Removes an Observer. It is safe to call this method while an Observer is | 83 // Removes an Observer. It is safe to call this method while an Observer is |
| 79 // receiving a notification callback. | 84 // receiving a notification callback. |
| 80 void RemoveObserver(Observer* observer); | 85 void RemoveObserver(Observer* observer); |
| 81 | 86 |
| 87 // Dispatch an available GdkEvent. Essentially this allows a subclass to do |
| 88 // some task before/after calling the default handler (EventDispatcher). |
| 89 virtual void DispatchEvents(GdkEvent* event); |
| 90 |
| 82 private: | 91 private: |
| 83 // We may make recursive calls to Run, so we save state that needs to be | 92 // We may make recursive calls to Run, so we save state that needs to be |
| 84 // separate between them in this structure type. | 93 // separate between them in this structure type. |
| 85 struct RunState; | 94 struct RunState; |
| 86 | 95 |
| 87 // Invoked from EventDispatcher. Notifies all observers we're about to | 96 // Invoked from EventDispatcher. Notifies all observers we're about to |
| 88 // process an event. | 97 // process an event. |
| 89 void WillProcessEvent(GdkEvent* event); | 98 void WillProcessEvent(GdkEvent* event); |
| 90 | 99 |
| 91 // Invoked from EventDispatcher. Notifies all observers we processed an | 100 // Invoked from EventDispatcher. Notifies all observers we processed an |
| (...skipping 28 matching lines...) Expand all Loading... |
| 120 | 129 |
| 121 // List of observers. | 130 // List of observers. |
| 122 ObserverList<Observer> observers_; | 131 ObserverList<Observer> observers_; |
| 123 | 132 |
| 124 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); | 133 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); |
| 125 }; | 134 }; |
| 126 | 135 |
| 127 } // namespace base | 136 } // namespace base |
| 128 | 137 |
| 129 #endif // BASE_MESSAGE_PUMP_GLIB_H_ | 138 #endif // BASE_MESSAGE_PUMP_GLIB_H_ |
| OLD | NEW |