Skip to content
  • yutak@chromium.org's avatar
    WebSocket: Send ArrayBuffer as WebSocket binary message · 4b47d620
    yutak@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=67477
    
    Reviewed by Kent Tamura.
    
    Source/WebCore:
    
    Tests: http/tests/websocket/tests/hybi/send-arraybuffer.html
           http/tests/websocket/tests/hybi/workers/send-arraybuffer.html
           http/tests/websocket/tests/hybi/bufferedAmount-after-close.html (updated)
    
    * bindings/js/JSWebSocketCustom.cpp:
    (WebCore::JSWebSocket::send):
    * bindings/v8/custom/V8WebSocketCustom.cpp:
    (WebCore::V8WebSocket::sendCallback):
    * websockets/ThreadableWebSocketChannel.h:
    * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
    (WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
    (WebCore::ThreadableWebSocketChannelClientWrapper::sendRequestResult):
    (WebCore::ThreadableWebSocketChannelClientWrapper::setSendRequestResult):
    * websockets/ThreadableWebSocketChannelClientWrapper.h:
    Rename "sent" to "sendRequestResult" to clarify the meaning. Messages from the script may not
    be sent immediately, thus the return value of WebSocketChannel::send() indicates whether the
    message has been queued successfully, rather than whether the message has been sent or not.
    * websockets/WebSocket.cpp:
    (WebCore::WebSocket::send):
    Case of sending "[object ArrayBuffer]" is covered by an existing test
    http/tests/websocket/tests/{hybi,hixie76}/send-object.html.
    * websockets/WebSocket.h:
    * websockets/WebSocket.idl:
    * websockets/WebSocketChannel.cpp:
    (WebCore::WebSocketChannel::send):
    * websockets/WebSocketChannel.h:
    * websockets/WorkerThreadableWebSocketChannel.cpp:
    (WebCore::WorkerThreadableWebSocketChannel::send):
    (WebCore::workerContextDidSend):
    (WebCore::WorkerThreadableWebSocketChannel::Peer::send):
    (WebCore::WorkerThreadableWebSocketChannel::mainThreadSendArrayBuffer):
    Construct an ArrayBuffer from the data on Vector<char>.
    (WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
    Copy the content into temporary buffer of Vector<char>, and send it to the main thread.
    * websockets/WorkerThreadableWebSocketChannel.h:
    
    LayoutTests:
    
    * http/tests/websocket/tests/hybi/bufferedAmount-after-close-expected.txt:
    * http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:
    Add tests to send ArrayBuffers.
    * http/tests/websocket/tests/hybi/check-binary-messages_wsh.py:
    Renamed from LayoutTests/http/tests/websocket/tests/hybi/send-blob_wsh.py, because this handler
    is used from send-blob.html and send-arraybuffer.html.
    * http/tests/websocket/tests/hybi/send-arraybuffer-expected.txt: Added.
    * http/tests/websocket/tests/hybi/send-arraybuffer.html:
    Added. Send three small binary messages as ArrayBuffers.
    * http/tests/websocket/tests/hybi/send-blob.html:
    * http/tests/websocket/tests/hybi/workers/resources/check-binary-messages_wsh.py:
    Renamed from LayoutTests/http/tests/websocket/tests/hybi/workers/resources/send-blob_wsh.py.
    * http/tests/websocket/tests/hybi/workers/resources/send-arraybuffer.js:
    Added. Same as send-arraybuffer.html, except that this test is run on the worker.
    * http/tests/websocket/tests/hybi/workers/resources/send-blob.js:
    Removed the definition of unnecessary function startsWith().
    * http/tests/websocket/tests/hybi/workers/send-arraybuffer-expected.txt: Added.
    * http/tests/websocket/tests/hybi/workers/send-arraybuffer.html: Added
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    4b47d620