| OLD | NEW |
| 1 // Copyright (c) 2008 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_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" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 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 | 61 // that an event was handled. |block| indicates if it should wait if no event |
| 62 // is ready for processing. | 62 // is ready for processing. |
| 63 virtual bool RunOnce(GMainContext* context, bool block); | 63 virtual bool RunOnce(GMainContext* context, bool block); |
| 64 | 64 |
| 65 virtual void Run(Delegate* delegate); | |
| 66 virtual void Quit(); | |
| 67 virtual void ScheduleWork(); | |
| 68 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); | |
| 69 | |
| 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 | 82 // Dispatch an available GdkEvent. Essentially this allows a subclass to do |
| 88 // some task before/after calling the default handler (EventDispatcher). | 83 // some task before/after calling the default handler (EventDispatcher). |
| 89 virtual void DispatchEvents(GdkEvent* event); | 84 virtual void DispatchEvents(GdkEvent* event); |
| 90 | 85 |
| 86 // Overridden from MessagePump: |
| 87 virtual void Run(Delegate* delegate); |
| 88 virtual void Quit(); |
| 89 virtual void ScheduleWork(); |
| 90 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); |
| 91 |
| 91 protected: | 92 protected: |
| 92 // Returns the dispatcher for the current run state (|state_->dispatcher|). | 93 // Returns the dispatcher for the current run state (|state_->dispatcher|). |
| 93 Dispatcher* GetDispatcher(); | 94 Dispatcher* GetDispatcher(); |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 // We may make recursive calls to Run, so we save state that needs to be | 97 // We may make recursive calls to Run, so we save state that needs to be |
| 97 // separate between them in this structure type. | 98 // separate between them in this structure type. |
| 98 struct RunState; | 99 struct RunState; |
| 99 | 100 |
| 100 // Invoked from EventDispatcher. Notifies all observers we're about to | 101 // Invoked from EventDispatcher. Notifies all observers we're about to |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 134 |
| 134 // List of observers. | 135 // List of observers. |
| 135 ObserverList<Observer> observers_; | 136 ObserverList<Observer> observers_; |
| 136 | 137 |
| 137 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); | 138 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 } // namespace base | 141 } // namespace base |
| 141 | 142 |
| 142 #endif // BASE_MESSAGE_PUMP_GLIB_H_ | 143 #endif // BASE_MESSAGE_PUMP_GLIB_H_ |
| OLD | NEW |