Chromium Code Reviews| Index: base/message_loop/message_pump_win.h |
| diff --git a/base/message_loop/message_pump_win.h b/base/message_loop/message_pump_win.h |
| index 00a1e77e2798cf24695cb42210b5f6c6f131f4c0..c8d058168735f74cd351838204a73e8800030e15 100644 |
| --- a/base/message_loop/message_pump_win.h |
| +++ b/base/message_loop/message_pump_win.h |
| @@ -11,6 +11,7 @@ |
| #include "base/base_export.h" |
| #include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/message_loop/message_pump.h" |
| #include "base/message_loop/message_pump_dispatcher.h" |
| #include "base/observer_list.h" |
| @@ -19,6 +20,8 @@ |
| namespace base { |
| +class Thread; |
| + |
| // MessagePumpWin serves as the base for specialized versions of the MessagePump |
| // for Windows. It provides basic functionality like handling of observers and |
| // controlling the lifetime of the message pump. |
| @@ -135,11 +138,38 @@ class BASE_EXPORT MessagePumpForUI : public MessagePumpWin { |
| bool ProcessMessageHelper(const MSG& msg); |
| bool ProcessPumpReplacementMessage(); |
| + // We spawn a worker thread to periodically post (3 ms) the kMsgHaveWork |
| + // message to the UI message pump. This is to ensure that the main thread |
| + // gets to process tasks and delayed tasks when there is no activity in the |
| + // Windows message pump or when there is a nested modal loop (sizing/moving/ |
| + // drag drop/message boxes) etc. |
| + void DoWorkerThreadRunLoop(); |
| + |
| + // This function is posted as part of a user mode APC to shutdown the worker |
| + // thread when the main message pump is shutting down. |
| + static void CALLBACK ShutdownWorkerThread(ULONG_PTR param); |
| + |
| + // Helper function for posting the kMsgHaveWork message to wake up the pump |
| + // for processing tasks. |
| + void PostWorkMessage(); |
| + |
| + // Helper function to set the waitable timer used to wake up the UI worker |
| + // thread for processing delayed tasks. |
| + void SetWakeupTimer(int64 delay); |
|
scottmg
2015/06/09 16:22:42
nit; "delay_ms" (and in the .cc) would be better s
ananta
2015/06/09 18:25:43
Done.
|
| + |
| // Atom representing the registered window class. |
| ATOM atom_; |
| // A hidden message-only window. |
| HWND message_hwnd_; |
| + |
| + // This thread is used to periodically wake up the main thread to process |
| + // tasks. |
| + scoped_ptr<base::Thread> ui_worker_thread_; |
| + |
| + // The UI worker thread waits on this timer indefinitely. When the main |
| + // thread has tasks ready to be processed it sets the timer. |
| + base::win::ScopedHandle ui_worker_thread_timer_; |
| }; |
| //----------------------------------------------------------------------------- |