ThreadableWebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(Blob& binaryData) { if (!m_workerClientWrapper || !m_peer) return ThreadableWebSocketChannel::SendFail; setMethodNotCompleted(); Peer* peer = m_peer; URLCapture capturedURL(binaryData.url()); StringCapture capturedType(binaryData.type()); long long size = binaryData.size(); m_loaderProxy.postTaskToLoader([peer, capturedURL, capturedType, size] (ScriptExecutionContext& context) { ASSERT(isMainThread()); ASSERT_UNUSED(context, context.isDocument()); ASSERT(peer); peer->send(Blob::deserialize(capturedURL.url(), capturedType.string(), size)); }); Ref<Bridge> protect(*this); waitForMethodCompletion(); ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get(); if (!clientWrapper) return ThreadableWebSocketChannel::SendFail; return clientWrapper->sendRequestResult(); }
void AsyncFileStream::write(const URL& blobURL, long long position, int length) { URLCapture capturedURL(blobURL); perform([capturedURL, position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> { int bytesWritten = stream.write(capturedURL.url(), position, length); return [bytesWritten](FileStreamClient& client) { client.didWrite(bytesWritten); }; }); }
void WorkerThreadableWebSocketChannel::Bridge::connect(const URL& url, const String& protocol) { ASSERT(m_workerClientWrapper); if (!m_peer) return; Peer* peer = m_peer; URLCapture capturedURL(url); StringCapture capturedProtocol(protocol); m_loaderProxy.postTaskToLoader([peer, capturedURL, capturedProtocol] (ScriptExecutionContext& context) { ASSERT(isMainThread()); ASSERT_UNUSED(context, context.isDocument()); ASSERT(peer); peer->connect(capturedURL.url(), capturedProtocol.string()); }); }