Bug 67363 - WebSocket: Fix bufferedAmount after WebSocket is closed
Summary: WebSocket: Fix bufferedAmount after WebSocket is closed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Yuta Kitamura
URL:
Keywords:
Depends on:
Blocks: 50099
  Show dependency treegraph
 
Reported: 2011-08-31 23:14 PDT by Yuta Kitamura
Modified: 2011-09-01 02:58 PDT (History)
4 users (show)

See Also:


Attachments
Patch (7.62 KB, patch)
2011-08-31 23:26 PDT, Yuta Kitamura
no flags Details | Formatted Diff | Diff
Patch v2 (7.70 KB, patch)
2011-09-01 00:58 PDT, Yuta Kitamura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta Kitamura 2011-08-31 23:14:09 PDT
It's fairly obvious when you see the source code:

http://trac.webkit.org/browser/trunk/Source/WebCore/websockets/WebSocket.cpp?rev=94274#L257
257	        m_bufferedAmountAfterClose += message.utf8().length() + 2; // 2 for frameing

This code only assumes hixie76 protocol in which every frame has two-byte framing overhead ("\x00" and "\xFF"). Let's make this code hybi-aware.
Comment 1 Yuta Kitamura 2011-08-31 23:26:55 PDT
Created attachment 105901 [details]
Patch
Comment 2 Kent Tamura 2011-08-31 23:43:56 PDT
Comment on attachment 105901 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=105901&action=review

> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:25
> +function getExpectedFramingOverhead(payloadSize)
> +{
> +    var overhead = 2 + 4; // Base header size and masking key size.
> +    if (payloadSize > 0xFFFF)
> +        overhead += 8;
> +    else if (payloadSize > 125)
> +        overhead += 2;
> +    return overhead;
> +}

Copying the code logic in C++ to the test code makes the test meaningless.  We should have constant values of the overheads for each test cases.

> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:59
> +function doTest(message)

nit: doTest -> testBufferedAmount ?
Comment 3 Yuta Kitamura 2011-09-01 00:58:47 PDT
Created attachment 105918 [details]
Patch v2
Comment 4 Yuta Kitamura 2011-09-01 00:59:41 PDT
Comment on attachment 105901 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=105901&action=review

>> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:25
>> +}
> 
> Copying the code logic in C++ to the test code makes the test meaningless.  We should have constant values of the overheads for each test cases.

Fixed.

>> LayoutTests/http/tests/websocket/tests/hybi/bufferedAmount-after-close.html:59
>> +function doTest(message)
> 
> nit: doTest -> testBufferedAmount ?

Fixed.
Comment 5 Kent Tamura 2011-09-01 01:19:14 PDT
Comment on attachment 105918 [details]
Patch v2

ok
Comment 6 WebKit Review Bot 2011-09-01 02:57:59 PDT
Comment on attachment 105918 [details]
Patch v2

Clearing flags on attachment: 105918

Committed r94282: <http://trac.webkit.org/changeset/94282>
Comment 7 WebKit Review Bot 2011-09-01 02:58:03 PDT
All reviewed patches have been landed.  Closing bug.