OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 void WorkerRunLoop::terminate() | 194 void WorkerRunLoop::terminate() |
195 { | 195 { |
196 m_messageQueue.kill(); | 196 m_messageQueue.kill(); |
197 } | 197 } |
198 | 198 |
199 void WorkerRunLoop::postTask(PassOwnPtr<ScriptExecutionContext::Task> task) | 199 void WorkerRunLoop::postTask(PassOwnPtr<ScriptExecutionContext::Task> task) |
200 { | 200 { |
201 postTaskForMode(task, defaultMode()); | 201 postTaskForMode(task, defaultMode()); |
202 } | 202 } |
203 | 203 |
| 204 void WorkerRunLoop::postTaskAndTerminate(PassOwnPtr<ScriptExecutionContext::Task
> task) |
| 205 { |
| 206 m_messageQueue.appendAndKill(Task::create(task, defaultMode().isolatedCopy()
)); |
| 207 } |
| 208 |
204 void WorkerRunLoop::postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task> tas
k, const String& mode) | 209 void WorkerRunLoop::postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task> tas
k, const String& mode) |
205 { | 210 { |
206 m_messageQueue.append(Task::create(task, mode.isolatedCopy())); | 211 m_messageQueue.append(Task::create(task, mode.isolatedCopy())); |
207 } | 212 } |
208 | 213 |
209 PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExe
cutionContext::Task> task, const String& mode) | 214 PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExe
cutionContext::Task> task, const String& mode) |
210 { | 215 { |
211 return adoptPtr(new Task(task, mode)); | 216 return adoptPtr(new Task(task, mode)); |
212 } | 217 } |
213 | 218 |
214 void WorkerRunLoop::Task::performTask(const WorkerRunLoop& runLoop, ScriptExecut
ionContext* context) | 219 void WorkerRunLoop::Task::performTask(const WorkerRunLoop& runLoop, ScriptExecut
ionContext* context) |
215 { | 220 { |
216 WorkerContext* workerContext = static_cast<WorkerContext *>(context); | 221 WorkerContext* workerContext = static_cast<WorkerContext *>(context); |
217 if ((!workerContext->isClosing() && !runLoop.terminated()) || m_task->isClea
nupTask()) | 222 if ((!workerContext->isClosing() && !runLoop.terminated()) || m_task->isClea
nupTask()) |
218 m_task->performTask(context); | 223 m_task->performTask(context); |
219 } | 224 } |
220 | 225 |
221 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S
tring& mode) | 226 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S
tring& mode) |
222 : m_task(task) | 227 : m_task(task) |
223 , m_mode(mode.isolatedCopy()) | 228 , m_mode(mode.isolatedCopy()) |
224 { | 229 { |
225 } | 230 } |
226 | 231 |
227 } // namespace WebCore | 232 } // namespace WebCore |
228 | 233 |
229 #endif // ENABLE(WORKERS) | 234 #endif // ENABLE(WORKERS) |
OLD | NEW |