Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: base/message_loop/message_pump_win.h

Issue 1156503005: Don't peek messages in the MessagePumpForUI class when we receive our kMsgHaveWork message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use an autoreset event to signal the worker that we have tasks to process Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop/message_pump_win.cc » ('j') | base/message_loop/message_pump_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1e86ba417ead854e06254273291f56cf31a22c7b 100644
--- a/base/message_loop/message_pump_win.h
+++ b/base/message_loop/message_pump_win.h
@@ -11,14 +11,18 @@
#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"
+#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "base/win/scoped_handle.h"
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 +139,31 @@ 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);
+
// 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_;
+
+ // This event is signaled when we have tasks to be processed. The worker
+ // thread waits on this event and starts posting the kMsgHaveWork message
+ // to the UI message pump.
+ WaitableEvent ui_worker_thread_signal_;
};
//-----------------------------------------------------------------------------
« no previous file with comments | « no previous file | base/message_loop/message_pump_win.cc » ('j') | base/message_loop/message_pump_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698