| OLD | NEW |
| 1 // Copyright (c) 2011 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 #include "chrome_frame/task_marshaller.h" | 5 #include "chrome_frame/task_marshaller.h" |
| 6 #include "base/task.h" | 6 #include "base/task.h" |
| 7 | 7 |
| 8 TaskMarshallerThroughMessageQueue::TaskMarshallerThroughMessageQueue() | 8 TaskMarshallerThroughMessageQueue::TaskMarshallerThroughMessageQueue() |
| 9 : wnd_(NULL), | 9 : wnd_(NULL), |
| 10 msg_(0xFFFF) { | 10 msg_(0xFFFF) { |
| 11 } | 11 } |
| 12 | 12 |
| 13 TaskMarshallerThroughMessageQueue::~TaskMarshallerThroughMessageQueue() { | 13 TaskMarshallerThroughMessageQueue::~TaskMarshallerThroughMessageQueue() { |
| 14 ClearTasks(); | 14 ClearTasks(); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void TaskMarshallerThroughMessageQueue::PostTask( | 17 void TaskMarshallerThroughMessageQueue::PostTask( |
| 18 const tracked_objects::Location& from_here, const base::Closure& task) { | 18 const tracked_objects::Location& from_here, const base::Closure& task) { |
| 19 DCHECK(wnd_ != NULL); | 19 DCHECK(wnd_ != NULL); |
| 20 |
| 20 lock_.Acquire(); | 21 lock_.Acquire(); |
| 21 bool has_work = !pending_tasks_.empty(); | 22 bool has_work = !pending_tasks_.empty(); |
| 22 pending_tasks_.push(task); | 23 pending_tasks_.push(task); |
| 23 lock_.Release(); | 24 lock_.Release(); |
| 24 | 25 |
| 25 // Don't post message if there is already one. | 26 // Don't post message if there is already one. |
| 26 if (has_work) | 27 if (has_work) |
| 27 return; | 28 return; |
| 28 | 29 |
| 29 if (!::PostMessage(wnd_, msg_, 0, 0)) { | 30 if (!::PostMessage(wnd_, msg_, 0, 0)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 base::AutoLock lock(lock_); | 125 base::AutoLock lock(lock_); |
| 125 DVLOG_IF(1, !pending_tasks_.empty()) << "Destroying " | 126 DVLOG_IF(1, !pending_tasks_.empty()) << "Destroying " |
| 126 << pending_tasks_.size() | 127 << pending_tasks_.size() |
| 127 << " pending tasks."; | 128 << " pending tasks."; |
| 128 while (!pending_tasks_.empty()) | 129 while (!pending_tasks_.empty()) |
| 129 pending_tasks_.pop(); | 130 pending_tasks_.pop(); |
| 130 | 131 |
| 131 while (!delayed_tasks_.empty()) | 132 while (!delayed_tasks_.empty()) |
| 132 delayed_tasks_.pop(); | 133 delayed_tasks_.pop(); |
| 133 } | 134 } |
| OLD | NEW |