bufferedAmount calculation is wrong in CLOSING and CLOSED state.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 01:58:49 +0000 (01:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 01:58:49 +0000 (01:58 +0000)
commite1f3fd82f2faca8b60d7e6510236e650fbe866e7
tree68beea0a8bc4c08c95292e8a2370c72396cc06a0
parent37a2badcc49c1d22a4e93971587cdbb1f5c15f92
bufferedAmount calculation is wrong in CLOSING and CLOSED state.
https://bugs.webkit.org/show_bug.cgi?id=73404

Patch by Takashi Toyoshima <toyoshim@chromium.org> on 2011-12-01
Reviewed by Kent Tamura.

Source/WebCore:

WebSocket::bufferedAmount() must return buffered frame size including
disposed frames which are passed via send() calls after close().

Old implementation had a problem at CLOSING state. Buffered frame size
was added to m_bufferedAmountAfterClose at close(). But the function
returns the sum of m_bufferedAmountAfterClose and internally buffered
frame size, or m_channel->bufferedAmount(). So, buffered frames was
double counted.

In new implementation, m_bufferedAmount always represents buffered
frame size and m_bufferedAmountAfterClose does disposed frame size.
As a result, bufferedAmount() implementation become just to return the
sum of m_bufferedAmount and m_bufferedAmountAfterClose.

Test: http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html

* websockets/WebSocket.cpp: Implement new bufferedAmount handling.
(WebCore::saturateAdd):
(WebCore::WebSocket::WebSocket):
(WebCore::WebSocket::send):
(WebCore::WebSocket::close):
(WebCore::WebSocket::bufferedAmount):
(WebCore::WebSocket::didUpdateBufferedAmount):
(WebCore::WebSocket::didClose):
* websockets/WebSocket.h:

LayoutTests:

Add a layout test to check the WebSocket bufferedAmount property.
This test close the socket channel when it is busy and buffer some
message frames, then check the property's value in CLOSING and CLOSED
state.

* http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt: Added.
* http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close-in-busy.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/websockets/WebSocket.cpp
Source/WebCore/websockets/WebSocket.h