| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 DeleteAll(); | 14 DeleteAll(); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void TaskMarshallerThroughMessageQueue::PostTask( | 17 void TaskMarshallerThroughMessageQueue::PostTask( |
| 18 const tracked_objects::Location& from_here, Task* task) { | 18 const tracked_objects::Location& from_here, Task* task) { |
| 19 DCHECK(wnd_ != NULL); | 19 DCHECK(wnd_ != NULL); |
| 20 task->SetBirthPlace(from_here); | |
| 21 lock_.Acquire(); | 20 lock_.Acquire(); |
| 22 bool has_work = !pending_tasks_.empty(); | 21 bool has_work = !pending_tasks_.empty(); |
| 23 pending_tasks_.push(task); | 22 pending_tasks_.push(task); |
| 24 lock_.Release(); | 23 lock_.Release(); |
| 25 | 24 |
| 26 // Don't post message if there is already one. | 25 // Don't post message if there is already one. |
| 27 if (has_work) | 26 if (has_work) |
| 28 return; | 27 return; |
| 29 | 28 |
| 30 if (!::PostMessage(wnd_, msg_, 0, 0)) { | 29 if (!::PostMessage(wnd_, msg_, 0, 0)) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (run_at < other.run_at) | 148 if (run_at < other.run_at) |
| 150 return false; | 149 return false; |
| 151 | 150 |
| 152 if (run_at > other.run_at) | 151 if (run_at > other.run_at) |
| 153 return true; | 152 return true; |
| 154 | 153 |
| 155 // If the times happen to match, then we use the sequence number to decide. | 154 // If the times happen to match, then we use the sequence number to decide. |
| 156 // Compare the difference to support integer roll-over. | 155 // Compare the difference to support integer roll-over. |
| 157 return (seq - other.seq) > 0; | 156 return (seq - other.seq) > 0; |
| 158 } | 157 } |
| OLD | NEW |