| 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 | |
| 65 virtual void Run(Delegate* delegate) { RunWithDispatcher(delegate, NULL); } | 60 virtual void Run(Delegate* delegate) { RunWithDispatcher(delegate, NULL); } |
| 66 virtual void Quit(); | 61 virtual void Quit(); |
| 67 virtual void ScheduleWork(); | 62 virtual void ScheduleWork(); |
| 68 virtual void ScheduleDelayedWork(const Time& delayed_work_time); | 63 virtual void ScheduleDelayedWork(const Time& delayed_work_time); |
| 69 | 64 |
| 70 // Internal methods used for processing the pump callbacks. They are | 65 // Internal methods used for processing the pump callbacks. They are |
| 71 // public for simplicity but should not be used directly. HandlePrepare | 66 // public for simplicity but should not be used directly. HandlePrepare |
| 72 // is called during the prepare step of glib, and returns a timeout that | 67 // is called during the prepare step of glib, and returns a timeout that |
| 73 // will be passed to the poll. HandleCheck is called after the poll | 68 // will be passed to the poll. HandleCheck is called after the poll |
| 74 // has completed, and returns whether or not HandleDispatch should be called. | 69 // has completed, and returns whether or not HandleDispatch should be called. |
| 75 // HandleDispatch is called if HandleCheck returned true. | 70 // HandleDispatch is called if HandleCheck returned true. |
| 76 int HandlePrepare(); | 71 int HandlePrepare(); |
| 77 bool HandleCheck(); | 72 bool HandleCheck(); |
| 78 void HandleDispatch(); | 73 void HandleDispatch(); |
| 79 | 74 |
| 80 // Adds an Observer, which will start receiving notifications immediately. | 75 // Adds an Observer, which will start receiving notifications immediately. |
| 81 void AddObserver(Observer* observer); | 76 void AddObserver(Observer* observer); |
| 82 | 77 |
| 83 // Removes an Observer. It is safe to call this method while an Observer is | 78 // Removes an Observer. It is safe to call this method while an Observer is |
| 84 // receiving a notification callback. | 79 // receiving a notification callback. |
| 85 void RemoveObserver(Observer* observer); | 80 void RemoveObserver(Observer* observer); |
| 86 | 81 |
| 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 | |
| 91 private: | 82 private: |
| 92 // We may make recursive calls to Run, so we save state that needs to be | 83 // We may make recursive calls to Run, so we save state that needs to be |
| 93 // separate between them in this structure type. | 84 // separate between them in this structure type. |
| 94 struct RunState; | 85 struct RunState; |
| 95 | 86 |
| 96 // Invoked from EventDispatcher. Notifies all observers we're about to | 87 // Invoked from EventDispatcher. Notifies all observers we're about to |
| 97 // process an event. | 88 // process an event. |
| 98 void WillProcessEvent(GdkEvent* event); | 89 void WillProcessEvent(GdkEvent* event); |
| 99 | 90 |
| 100 // Invoked from EventDispatcher. Notifies all observers we processed an | 91 // Invoked from EventDispatcher. Notifies all observers we processed an |
| (...skipping 28 matching lines...) Expand all Loading... |
| 129 | 120 |
| 130 // List of observers. | 121 // List of observers. |
| 131 ObserverList<Observer> observers_; | 122 ObserverList<Observer> observers_; |
| 132 | 123 |
| 133 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); | 124 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); |
| 134 }; | 125 }; |
| 135 | 126 |
| 136 } // namespace base | 127 } // namespace base |
| 137 | 128 |
| 138 #endif // BASE_MESSAGE_PUMP_GLIB_H_ | 129 #endif // BASE_MESSAGE_PUMP_GLIB_H_ |
| OLD | NEW |