Index: Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp |
diff --git a/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp b/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp |
index b64890f76fb0404c938e8cccd44523bf21787921..2ad82b68aecad589bfdc3ffeacbd3e1d5527fe06 100644 |
--- a/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp |
+++ b/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp |
@@ -36,6 +36,7 @@ |
#include "core/dom/CrossThreadTask.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExecutionContext.h" |
+#include "core/dom/ExecutionContextTask.h" |
#include "core/fileapi/Blob.h" |
#include "core/inspector/ScriptCallFrame.h" |
#include "core/inspector/ScriptCallStack.h" |
@@ -497,10 +498,7 @@ bool WorkerThreadableWebSocketChannel::Bridge::connect(const KURL& url, const St |
return false; |
RefPtrWillBeRawPtr<Bridge> protect(this); |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::connect, m_peer, url.copy(), protocol.isolatedCopy())); |
- if (!waitForMethodCompletion(task.release())) |
+ if (!waitForMethodCompletion(createCallClosureTask(&Peer::connect, m_peer, url, protocol))) |
return false; |
return m_syncHelper->connectRequestResult(); |
@@ -512,10 +510,7 @@ WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(cons |
return WebSocketChannel::SendFail; |
RefPtrWillBeRawPtr<Bridge> protect(this); |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::send, m_peer, message.isolatedCopy())); |
- if (!waitForMethodCompletion(task.release())) |
+ if (!waitForMethodCompletion(createCallClosureTask(&Peer::send, m_peer, message))) |
return WebSocketChannel::SendFail; |
return m_syncHelper->sendRequestResult(); |
@@ -532,10 +527,7 @@ WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(cons |
memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteOffset, byteLength); |
RefPtrWillBeRawPtr<Bridge> protect(this); |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::sendArrayBuffer, m_peer, data.release())); |
- if (!waitForMethodCompletion(task.release())) |
+ if (!waitForMethodCompletion(createCallClosureTask(&Peer::sendArrayBuffer, m_peer, data.release()))) |
return WebSocketChannel::SendFail; |
return m_syncHelper->sendRequestResult(); |
@@ -547,10 +539,7 @@ WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(Pass |
return WebSocketChannel::SendFail; |
RefPtrWillBeRawPtr<Bridge> protect(this); |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::sendBlob, m_peer, data)); |
- if (!waitForMethodCompletion(task.release())) |
+ if (!waitForMethodCompletion(createCallClosureTask(&Peer::sendBlob, m_peer, data))) |
return WebSocketChannel::SendFail; |
return m_syncHelper->sendRequestResult(); |
@@ -561,10 +550,7 @@ void WorkerThreadableWebSocketChannel::Bridge::close(int code, const String& rea |
if (hasTerminatedPeer()) |
return; |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::close, m_peer, code, reason.isolatedCopy())); |
- m_loaderProxy.postTaskToLoader(task.release()); |
+ m_loaderProxy.postTaskToLoader(createCallClosureTask(&Peer::close, m_peer, code, reason)); |
} |
void WorkerThreadableWebSocketChannel::Bridge::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber) |
@@ -572,10 +558,7 @@ void WorkerThreadableWebSocketChannel::Bridge::fail(const String& reason, Messag |
if (hasTerminatedPeer()) |
return; |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::fail, m_peer, reason.isolatedCopy(), level, sourceURL.isolatedCopy(), lineNumber)); |
- m_loaderProxy.postTaskToLoader(task.release()); |
+ m_loaderProxy.postTaskToLoader(createCallClosureTask(&Peer::fail, m_peer, reason, level, sourceURL, lineNumber)); |
} |
void WorkerThreadableWebSocketChannel::Bridge::disconnect() |
@@ -615,17 +598,14 @@ void WorkerThreadableWebSocketChannel::Bridge::terminatePeer() |
{ |
ASSERT(!hasTerminatedPeer()); |
- // It is important to seprate task creation from calling |
- // waitForMethodCompletion. See the above comment. |
- OwnPtr<ExecutionContextTask> task = CallClosureTask::create(bind(&Peer::destroy, m_peer)); |
#if ENABLE(OILPAN) |
// The worker thread has to wait for the main thread to complete Peer::destroy, |
// because the worker thread has to make sure that the main thread does not have any |
// references to on-heap objects allocated in the thread heap of the worker thread |
// before the worker thread shuts down. |
- waitForMethodCompletion(task.release()); |
+ waitForMethodCompletion(createCallClosureTask(&Peer::destroy, m_peer)); |
#else |
- m_loaderProxy.postTaskToLoader(task.release()); |
+ m_loaderProxy.postTaskToLoader(createCallClosureTask(&Peer::destroy, m_peer)); |
#endif |
// Peer::destroy() deletes m_peer and then m_syncHelper will be released. |