diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 16:02:26 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 16:02:26 +0000 |
commit | 11b6e60b413fe6b596cbf08f78e689a360faeb61 (patch) | |
tree | 04d332597120edd9a87f42efab62f3b1d7f4f8f4 /chrome_frame/task_marshaller.cc | |
parent | 18004a3331147f8f84ad8a21caa2ce695d75c28a (diff) | |
download | chromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.zip chromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.tar.gz chromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.tar.bz2 |
Review URL: http://codereview.chromium.org/3685006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/task_marshaller.cc')
-rw-r--r-- | chrome_frame/task_marshaller.cc | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/chrome_frame/task_marshaller.cc b/chrome_frame/task_marshaller.cc index ba1df2c..b8a504a5 100644 --- a/chrome_frame/task_marshaller.cc +++ b/chrome_frame/task_marshaller.cc @@ -14,34 +14,54 @@ TaskMarshallerThroughMessageQueue::~TaskMarshallerThroughMessageQueue() { } void TaskMarshallerThroughMessageQueue::PostTask( - const tracked_objects::Location& from_here, Task* task) { - task->SetBirthPlace(from_here); - lock_.Acquire(); - bool has_work = !pending_tasks_.empty(); - pending_tasks_.push(task); - lock_.Release(); - - // Don't post message if there is already one. - if (has_work) - return; - - if (!::PostMessage(wnd_, msg_, 0, 0)) { - DLOG(INFO) << "Dropping MSG_EXECUTE_TASK message for destroyed window."; - DeleteAll(); - } + const tracked_objects::Location& from_here, Task* task) { + DCHECK(wnd_ != NULL); + task->SetBirthPlace(from_here); + lock_.Acquire(); + bool has_work = !pending_tasks_.empty(); + pending_tasks_.push(task); + lock_.Release(); + + // Don't post message if there is already one. + if (has_work) + return; + + if (!::PostMessage(wnd_, msg_, 0, 0)) { + DLOG(INFO) << "Dropping MSG_EXECUTE_TASK message for destroyed window."; + DeleteAll(); + } } void TaskMarshallerThroughMessageQueue::PostDelayedTask( - const tracked_objects::Location& source, Task* task, - base::TimeDelta& delay) { - AutoLock lock(lock_); - DelayedTask delayed_task(task, base::Time::Now() + delay); - delayed_tasks_.push(delayed_task); - // If we become the 'top' task - reschedule the timer. - if (delayed_tasks_.top().task == task) { - ::SetTimer(wnd_, reinterpret_cast<UINT_PTR>(this), - static_cast<DWORD>(delay.InMilliseconds()), NULL); - } + const tracked_objects::Location& source, Task* task, + base::TimeDelta& delay) { + DCHECK(wnd_ != NULL); + AutoLock lock(lock_); + DelayedTask delayed_task(task, base::Time::Now() + delay); + delayed_tasks_.push(delayed_task); + // If we become the 'top' task - reschedule the timer. + if (delayed_tasks_.top().task == task) { + ::SetTimer(wnd_, reinterpret_cast<UINT_PTR>(this), + static_cast<DWORD>(delay.InMilliseconds()), NULL); + } +} + +BOOL TaskMarshallerThroughMessageQueue::ProcessWindowMessage(HWND hWnd, + UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, + DWORD dwMsgMapID) { + if (hWnd == wnd_ && uMsg == msg_) { + ExecuteQueuedTasks(); + lResult = 0; + return TRUE; + } + + if (hWnd == wnd_ && uMsg == WM_TIMER) { + ExecuteDelayedTasks(); + lResult = 0; + return TRUE; + } + + return FALSE; } Task* TaskMarshallerThroughMessageQueue::PopTask() { |