2011-05-29 Yuta Kitamura <yutak@chromium.org>
authoryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2011 06:22:06 +0000 (06:22 +0000)
committeryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2011 06:22:06 +0000 (06:22 +0000)
commit03f25af05a795330fb62bb638185743dc7997d49
tree057ae39ad61828e303f28d2c053bf2d160afabc3
parent160d93964dc2f16996729b868f2b462541803c2b
2011-05-29  Yuta Kitamura  <yutak@chromium.org>

        Reviewed by Kent Tamura.

        WebSocket closing handshake
        https://bugs.webkit.org/show_bug.cgi?id=35721

        * http/tests/websocket/tests/client-close-expected.txt: Added.
        * http/tests/websocket/tests/client-close.html: Added. Test client-initiated close.
        * http/tests/websocket/tests/client-close_wsh.py: Added.
        * http/tests/websocket/tests/close-before-open-expected.txt: Add a new console message.
        * http/tests/websocket/tests/close-event-expected.txt:
        * http/tests/websocket/tests/close-event.html: Test if closeEvent.wasClean is true.
        * http/tests/websocket/tests/close-unref-websocket-expected.txt: Add a new console message.
        * http/tests/websocket/tests/frame-length-longer-than-buffer_wsh.py:
        We need to stop pywebsocket from starting the closing handshake. Otherwise, pywebsocket
        waits for a close frame to arrive and this test will time out.
        * http/tests/websocket/tests/server-close-expected.txt: Added.
        * http/tests/websocket/tests/server-close.html: Added. Test server-initiated close.
        * http/tests/websocket/tests/server-close_wsh.py: Added.
        * http/tests/websocket/tests/websocket-event-target-expected.txt: Add a new console message.
2011-05-29  Yuta Kitamura  <yutak@chromium.org>

        Reviewed by Kent Tamura.

        WebSocket closing handshake
        https://bugs.webkit.org/show_bug.cgi?id=35721

        Implement WebSocket closing handshake based on Ian Hickson's
        WebSocket protocol draft 76.

        Tests: http/tests/websocket/tests/client-close.html
               http/tests/websocket/tests/server-close.html

        * platform/network/SocketStreamHandleBase.cpp:
        (WebCore::SocketStreamHandleBase::send):
        Do not send a message if we are in Closing state.
        (WebCore::SocketStreamHandleBase::close):
        Do not disconnect if we have pending data which have not been sent yet.
        In this case, the actual disconnection will happen in sendPendingData().
        (WebCore::SocketStreamHandleBase::disconnect):
        Renamed from close(). Disconnect the connection immediately.
        (WebCore::SocketStreamHandleBase::sendPendingData):
        * platform/network/SocketStreamHandleBase.h:
        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
        Add didStartClosingHandshake(). Add a function argument (ClosingHandshakeCompletionStatus)
        to didClose().
        (WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake):
        (WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
        (WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshakeCallback):
        (WebCore::ThreadableWebSocketChannelClientWrapper::didCloseCallback):
        * websockets/ThreadableWebSocketChannelClientWrapper.h:
        * websockets/WebSocket.cpp:
        (WebCore::WebSocket::send):
        (WebCore::WebSocket::close):
        Fail if close() is attempted before the connection is established.
        Otherwise, set the state to CLOSING and start the closing handshake.
        (WebCore::WebSocket::bufferedAmount):
        If the state is CLOSING, we need to consider buffered data in m_channel and sent after close().
        (WebCore::WebSocket::didConnect):
        (WebCore::WebSocket::didReceiveMessage):
        We need to invoke message event in CLOSING state as well as OPEN state.
        (WebCore::WebSocket::didReceiveMessageError):
        (WebCore::WebSocket::didStartClosingHandshake):
        (WebCore::WebSocket::didClose):
        * websockets/WebSocket.h:
        * websockets/WebSocketChannel.cpp:
        (WebCore::WebSocketChannel::WebSocketChannel):
        (WebCore::WebSocketChannel::close):
        Start the closing handshake.
        (WebCore::WebSocketChannel::disconnect):
        Disconnect the socket stream, instead of close.
        (WebCore::WebSocketChannel::didClose):
        (WebCore::WebSocketChannel::didReceiveData): Ditto.
        (WebCore::WebSocketChannel::didFail): Ditto.
        (WebCore::WebSocketChannel::processBuffer):
        Ditto.
        Handle 0xFF 0x00 byte sequence, and discard received data once the closing handshake has started.
        (WebCore::WebSocketChannel::startClosingHandshake):
        Send 0xFF 0x00 byte sequence.
        (WebCore::WebSocketChannel::closingTimerFired):
        Disconnect the socket stream if the closing handshake has timed out.
        * websockets/WebSocketChannel.h:
        m_closing is true if "the WebSocket closing handshake has started" (as stated in the protocol
        specification).
        * websockets/WebSocketChannelClient.h:
        (WebCore::WebSocketChannelClient::didStartClosingHandshake): Added.
        (WebCore::WebSocketChannelClient::didClose): Add closingHandshakeCompletion parameter.
        * websockets/WorkerThreadableWebSocketChannel.cpp:
        Add closingHandshakeCompletion parameter to didClose(), and add didStartClosingHandshake().
        (WebCore::WorkerThreadableWebSocketChannel::Peer::close):
        (WebCore::workerContextDidStartClosingHandshake):
        (WebCore::WorkerThreadableWebSocketChannel::Peer::didStartClosingHandshake):
        (WebCore::workerContextDidClose):
        (WebCore::WorkerThreadableWebSocketChannel::Peer::didClose):
        * websockets/WorkerThreadableWebSocketChannel.h:
2011-05-29  Yuta Kitamura  <yutak@chromium.org>

        Reviewed by Kent Tamura.

        WebSocket closing handshake
        https://bugs.webkit.org/show_bug.cgi?id=35721

        * Scripts/webkitpy/thirdparty/__init__.py:
        Pull in pywebsocket 0.6b1. We need to update pywebsocket
        to get the right behavior of closing handshake.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87674 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/client-close-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/client-close.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/client-close_wsh.py [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/close-before-open-expected.txt
LayoutTests/http/tests/websocket/tests/close-event-expected.txt
LayoutTests/http/tests/websocket/tests/close-event.html
LayoutTests/http/tests/websocket/tests/close-unref-websocket-expected.txt
LayoutTests/http/tests/websocket/tests/frame-length-longer-than-buffer_wsh.py
LayoutTests/http/tests/websocket/tests/server-close-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/server-close.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/server-close_wsh.py [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/websocket-event-target-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/network/SocketStreamHandleBase.cpp
Source/WebCore/platform/network/SocketStreamHandleBase.h
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
Source/WebCore/websockets/WebSocket.cpp
Source/WebCore/websockets/WebSocket.h
Source/WebCore/websockets/WebSocketChannel.cpp
Source/WebCore/websockets/WebSocketChannel.h
Source/WebCore/websockets/WebSocketChannelClient.h
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h
Tools/ChangeLog
Tools/Scripts/webkitpy/thirdparty/__init__.py