Index: third_party/WebKit/WebCore/dom/WorkerMessagingProxy.cpp |
=================================================================== |
--- third_party/WebKit/WebCore/dom/WorkerMessagingProxy.cpp (revision 9118) |
+++ third_party/WebKit/WebCore/dom/WorkerMessagingProxy.cpp (working copy) |
@@ -33,14 +33,14 @@ |
#include "DOMWindow.h" |
#include "Document.h" |
#include "MessageEvent.h" |
+#include "ScriptExecutionContext.h" |
#include "Worker.h" |
#include "WorkerContext.h" |
-#include "WorkerTask.h" |
#include "WorkerThread.h" |
namespace WebCore { |
-class MessageWorkerContextTask : public WorkerTask { |
+class MessageWorkerContextTask : public ScriptExecutionContext::Task { |
public: |
static PassRefPtr<MessageWorkerContextTask> create(const String& message) |
{ |
@@ -53,8 +53,11 @@ |
{ |
} |
- virtual void performTask(WorkerContext* context) |
+ virtual void performTask(ScriptExecutionContext* scriptContext) |
{ |
+ ASSERT(scriptContext->isWorkerContext()); |
+ WorkerContext* context = static_cast<WorkerContext*>(scriptContext); |
+ |
RefPtr<Event> evt = MessageEvent::create(m_message, "", "", 0, 0); |
if (context->onmessage()) { |
@@ -213,17 +216,22 @@ |
void WorkerMessagingProxy::postMessageToWorkerContext(const String& message) |
{ |
+ postTaskToWorkerContext(MessageWorkerContextTask::create(message)); |
+} |
+ |
+void WorkerMessagingProxy::postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task> task) |
+{ |
if (m_askedToTerminate) |
return; |
if (m_workerThread) { |
++m_unconfirmedMessageCount; |
- m_workerThread->runLoop().postTask(MessageWorkerContextTask::create(message)); |
+ m_workerThread->runLoop().postTask(task); |
} else |
- m_queuedEarlyTasks.append(MessageWorkerContextTask::create(message)); |
+ m_queuedEarlyTasks.append(task); |
} |
-void WorkerMessagingProxy::postTaskToParentContext(PassRefPtr<ScriptExecutionContext::Task> task) |
+void WorkerMessagingProxy::postTaskToWorkerObject(PassRefPtr<ScriptExecutionContext::Task> task) |
{ |
m_scriptExecutionContext->postTask(task); |
} |
@@ -257,7 +265,7 @@ |
if (m_workerThread) |
terminate(); |
else |
- workerContextDestroyedInternal(); // It never existed, just do our cleanup. |
+ workerContextDestroyedInternal(); |
} |
void WorkerMessagingProxy::workerContextDestroyed() |
@@ -270,6 +278,7 @@ |
{ |
// WorkerContextDestroyedTask is always the last to be performed, so the proxy is not needed for communication |
// in either side any more. However, the Worker object may still exist, and it assumes that the proxy exists, too. |
+ m_workerThread = 0; |
if (!m_workerObject) |
delete this; |
} |