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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // FIXME: when 'kill a worker' html5 spec algorithm is implemented, it | 209 // FIXME: when 'kill a worker' html5 spec algorithm is implemented, it |
210 // should be used here instead of 'terminate a worker'. | 210 // should be used here instead of 'terminate a worker'. |
211 terminateWorkerContext(); | 211 terminateWorkerContext(); |
212 } | 212 } |
213 | 213 |
214 void WebWorkerImpl::clientDestroyed() | 214 void WebWorkerImpl::clientDestroyed() |
215 { | 215 { |
216 m_client = 0; | 216 m_client = 0; |
217 } | 217 } |
218 | 218 |
219 void WebWorkerImpl::dispatchTaskToMainThread(PassRefPtr<ScriptExecutionContext::Task> task) | 219 void WebWorkerImpl::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task) |
220 { | 220 { |
221 return callOnMainThread(invokeTaskMethod, task.releaseRef()); | 221 return callOnMainThread(invokeTaskMethod, task.release()); |
222 } | 222 } |
223 | 223 |
224 void WebWorkerImpl::invokeTaskMethod(void* param) | 224 void WebWorkerImpl::invokeTaskMethod(void* param) |
225 { | 225 { |
226 ScriptExecutionContext::Task* task = | 226 ScriptExecutionContext::Task* task = |
227 static_cast<ScriptExecutionContext::Task*>(param); | 227 static_cast<ScriptExecutionContext::Task*>(param); |
228 task->performTask(0); | 228 task->performTask(0); |
229 task->deref(); | 229 delete task; |
230 } | 230 } |
231 | 231 |
232 // WorkerObjectProxy ----------------------------------------------------------- | 232 // WorkerObjectProxy ----------------------------------------------------------- |
233 | 233 |
234 void WebWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, | 234 void WebWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, |
235 PassOwnPtr<MessagePortChannelArray> channels) | 235 PassOwnPtr<MessagePortChannelArray> channels) |
236 { | 236 { |
237 dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this, | 237 dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this, |
238 message->toString(), channels)); | 238 message->toString(), channels)); |
239 } | 239 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 void WebWorkerImpl::workerContextDestroyed() | 341 void WebWorkerImpl::workerContextDestroyed() |
342 { | 342 { |
343 dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask, | 343 dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask, |
344 this)); | 344 this)); |
345 } | 345 } |
346 | 346 |
347 // WorkerLoaderProxy ----------------------------------------------------------- | 347 // WorkerLoaderProxy ----------------------------------------------------------- |
348 | 348 |
349 void WebWorkerImpl::postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task> task) | 349 void WebWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task) |
350 { | 350 { |
351 ASSERT(m_loadingDocument->isDocument()); | 351 ASSERT(m_loadingDocument->isDocument()); |
352 m_loadingDocument->postTask(task); | 352 m_loadingDocument->postTask(task); |
353 } | 353 } |
354 | 354 |
355 void WebWorkerImpl::postTaskForModeToWorkerContext( | 355 void WebWorkerImpl::postTaskForModeToWorkerContext( |
356 PassRefPtr<ScriptExecutionContext::Task> task, const String& mode) | 356 PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) |
357 { | 357 { |
358 m_workerThread->runLoop().postTaskForMode(task, mode); | 358 m_workerThread->runLoop().postTaskForMode(task, mode); |
359 } | 359 } |
360 | 360 |
361 void WebWorkerImpl::workerContextDestroyedTask(ScriptExecutionContext* context, | 361 void WebWorkerImpl::workerContextDestroyedTask(ScriptExecutionContext* context, |
362 WebWorkerImpl* thisPtr) | 362 WebWorkerImpl* thisPtr) |
363 { | 363 { |
364 if (thisPtr->m_client) | 364 if (thisPtr->m_client) |
365 thisPtr->m_client->workerContextDestroyed(); | 365 thisPtr->m_client->workerContextDestroyed(); |
366 // The lifetime of this proxy is controlled by the worker context. | 366 // The lifetime of this proxy is controlled by the worker context. |
367 delete thisPtr; | 367 delete thisPtr; |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 #else | 371 #else |
372 | 372 |
373 WebWorker* WebWorker::create(WebWorkerClient* client) | 373 WebWorker* WebWorker::create(WebWorkerClient* client) |
374 { | 374 { |
375 return 0; | 375 return 0; |
376 } | 376 } |
377 | 377 |
378 #endif // ENABLE(WORKERS) | 378 #endif // ENABLE(WORKERS) |
379 | 379 |
380 } // namespace WebKit | 380 } // namespace WebKit |
OLD | NEW |