diff options
author | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-08 17:46:13 +0000 |
---|---|---|
committer | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-08 17:46:13 +0000 |
commit | 2945789a07147c28645bc0175004bfb70fe02b0c (patch) | |
tree | f56ec53713ea761eea85a0457fe8669f320c770d /base/message_pump_win.cc | |
parent | 17d64785b8f1e6d48646477978a35d348d8bad59 (diff) | |
download | chromium_src-2945789a07147c28645bc0175004bfb70fe02b0c.zip chromium_src-2945789a07147c28645bc0175004bfb70fe02b0c.tar.gz chromium_src-2945789a07147c28645bc0175004bfb70fe02b0c.tar.bz2 |
Replace PeekMessage for TSF awareness
Replace PeekMessage with TSF interface's one in MessagePumpForIO
Add MessagePumpTSFInternal class for above replacing.
BUG=137627
TEST=
Review URL: https://chromiumcodereview.appspot.com/10826223
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_win.cc')
-rw-r--r-- | base/message_pump_win.cc | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc index 40118da..fb962ca 100644 --- a/base/message_pump_win.cc +++ b/base/message_pump_win.cc @@ -95,7 +95,9 @@ int MessagePumpWin::GetCurrentDelay() const { //----------------------------------------------------------------------------- // MessagePumpForUI public: -MessagePumpForUI::MessagePumpForUI() : instance_(NULL) { +MessagePumpForUI::MessagePumpForUI() + : instance_(NULL), + message_filter_(new MessageFilter) { InitMessageWnd(); } @@ -295,16 +297,17 @@ void MessagePumpForUI::WaitForWork() { // If a parent child relationship exists between windows across threads // then their thread inputs are implicitly attached. // This causes the MsgWaitForMultipleObjectsEx API to return indicating - // that messages are ready for processing (specifically mouse messages - // intended for the child window. Occurs if the child window has capture) - // The subsequent PeekMessages call fails to return any messages thus + // that messages are ready for processing (Specifically, mouse messages + // intended for the child window may appear if the child window has + // capture). + // The subsequent PeekMessages call may fail to return any messages thus // causing us to enter a tight loop at times. // The WaitMessage call below is a workaround to give the child window - // sometime to process its input messages. + // some time to process its input messages. MSG msg = {0}; DWORD queue_status = GetQueueStatus(QS_MOUSE); if (HIWORD(queue_status) & QS_MOUSE && - !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) { + !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) { WaitMessage(); } return; @@ -361,7 +364,7 @@ bool MessagePumpForUI::ProcessNextWindowsMessage() { sent_messages_in_queue = true; MSG msg; - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + if (message_filter_->DoPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) return ProcessMessageHelper(msg); return sent_messages_in_queue; @@ -387,12 +390,14 @@ bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) { WillProcessMessage(msg); - if (state_->dispatcher) { - if (!state_->dispatcher->Dispatch(msg)) - state_->should_quit = true; - } else { - TranslateMessage(&msg); - DispatchMessage(&msg); + if (!message_filter_->ProcessMessage(msg)) { + if (state_->dispatcher) { + if (!state_->dispatcher->Dispatch(msg)) + state_->should_quit = true; + } else { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } DidProcessMessage(msg); @@ -419,7 +424,8 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() { have_message = PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) || PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE); } else { - have_message = (0 != PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)); + have_message = !!message_filter_->DoPeekMessage(&msg, NULL, 0, 0, + PM_REMOVE); } DCHECK(!have_message || kMsgHaveWork != msg.message || @@ -441,6 +447,11 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() { return ProcessMessageHelper(msg); } +void MessagePumpForUI::SetMessageFilter( + scoped_ptr<MessageFilter> message_filter) { + message_filter_ = message_filter.Pass(); +} + //----------------------------------------------------------------------------- // MessagePumpForIO public: |