Bug 78557

Summary: [WebSocket] Add extension attribute support
Product: WebKit Reporter: Kenichi Ishibashi <bashi>
Component: WebKit Misc.Assignee: Kenichi Ishibashi <bashi>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, macpherson, menard, tkent, toyoshim, tyoshino, webkit.review.bot, yutak
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 77522    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Kenichi Ishibashi 2012-02-13 17:43:25 PST
Add extension attribute support.
Comment 1 Kenichi Ishibashi 2012-02-13 18:07:24 PST
Created attachment 126880 [details]
Patch
Comment 2 Yuta Kitamura 2012-02-13 23:49:18 PST
Comment on attachment 126880 [details]
Patch

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

Generally looks fine except for one comment. [Note: I don't have r+ privilege]

> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:228
> +                    if (!acceptedExtensions.contains(extensionToken))

This code requires O(N^2)-time for N extension items, right? O(N^2) algorithm is not acceptable.
Comment 3 Kenichi Ishibashi 2012-02-14 01:47:22 PST
Created attachment 126937 [details]
Patch
Comment 4 Kenichi Ishibashi 2012-02-14 01:47:56 PST
Comment on attachment 126880 [details]
Patch

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

>> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:228
>> +                    if (!acceptedExtensions.contains(extensionToken))
> 
> This code requires O(N^2)-time for N extension items, right? O(N^2) algorithm is not acceptable.

Used Vector<bool> as flags to determine whether the extensionToken should be appended.
Comment 5 Kenichi Ishibashi 2012-02-14 01:49:18 PST
Kent-san, Alexey,

Could you review the patch?
Comment 6 Kenichi Ishibashi 2012-02-14 02:08:23 PST
Comment on attachment 126937 [details]
Patch

Talked with Yuta-san in person. I'll change the behavior.
Comment 7 Kenichi Ishibashi 2012-02-14 02:49:33 PST
Created attachment 126946 [details]
Patch
Comment 8 WebKit Review Bot 2012-02-14 02:52:45 PST
Attachment 126946 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit']" exit_code: 9

Updating OpenSource
First, rewinding head to replay your work on top of it...
Applying: [Mac][Win][WK2] Switch to RFC 6455 protocol for WebSockets
Using index info to reconstruct a base tree...
<stdin>:1578: trailing whitespace.
        
<stdin>:1647: trailing whitespace.
    
<stdin>:1657: trailing whitespace.
    
<stdin>:1672: trailing whitespace.
        return 0;        
<stdin>:1674: trailing whitespace.
    
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.
Falling back to patching base and 3-way merge...
warning: too many files (created: 168766 deleted: 3), skipping inexact rename detection
Auto-merging LayoutTests/ChangeLog
CONFLICT (content): Merge conflict in LayoutTests/ChangeLog
Auto-merging Source/WebCore/ChangeLog
CONFLICT (content): Merge conflict in Source/WebCore/ChangeLog
Auto-merging Tools/ChangeLog
CONFLICT (content): Merge conflict in Tools/ChangeLog
Failed to merge in the changes.
Patch failed at 0001 [Mac][Win][WK2] Switch to RFC 6455 protocol for WebSockets

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/origin/master: command returned error: 1

Died at Tools/Scripts/update-webkit line 164.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Yuta Kitamura 2012-02-14 03:56:07 PST
Comment on attachment 126946 [details]
Patch

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

Looks OK. [Note: I don't have r+ privilege yet.]

> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:181
> +    for (HashMap<String, String>::const_iterator iterator = extensionParameters.begin(); iterator != extensionParameters.end(); ++iterator) {

Please add a FIXME comment which indicates there's a possibility of changing the order of parameters due to HashMap. (As we told off-line, I assume you are going to fix this as a separate issue.)
Comment 10 Kenichi Ishibashi 2012-02-14 04:10:28 PST
Created attachment 126954 [details]
Patch
Comment 11 Kenichi Ishibashi 2012-02-14 04:10:57 PST
Comment on attachment 126946 [details]
Patch

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

>> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:181
>> +    for (HashMap<String, String>::const_iterator iterator = extensionParameters.begin(); iterator != extensionParameters.end(); ++iterator) {
> 
> Please add a FIXME comment which indicates there's a possibility of changing the order of parameters due to HashMap. (As we told off-line, I assume you are going to fix this as a separate issue.)

Done.
Comment 12 WebKit Review Bot 2012-02-14 04:13:28 PST
Attachment 126954 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit']" exit_code: 9

Updating OpenSource
First, rewinding head to replay your work on top of it...
Applying: [Mac][Win][WK2] Switch to RFC 6455 protocol for WebSockets
Using index info to reconstruct a base tree...
<stdin>:1578: trailing whitespace.
        
<stdin>:1647: trailing whitespace.
    
<stdin>:1657: trailing whitespace.
    
<stdin>:1672: trailing whitespace.
        return 0;        
<stdin>:1674: trailing whitespace.
    
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.
Falling back to patching base and 3-way merge...
warning: too many files (created: 168768 deleted: 3), skipping inexact rename detection
Auto-merging LayoutTests/ChangeLog
CONFLICT (content): Merge conflict in LayoutTests/ChangeLog
Auto-merging Source/WebCore/ChangeLog
Auto-merging Tools/ChangeLog
CONFLICT (content): Merge conflict in Tools/ChangeLog
Failed to merge in the changes.
Patch failed at 0001 [Mac][Win][WK2] Switch to RFC 6455 protocol for WebSockets

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/origin/master: command returned error: 1

Died at Tools/Scripts/update-webkit line 164.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Kent Tamura 2012-02-14 16:05:35 PST
Comment on attachment 126954 [details]
Patch

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

> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:268
> +    return m_acceptedExtensionsBuilder.toAtomicString().string();

Why toAtomicString().string() instead of toString()?
Comment 14 Kenichi Ishibashi 2012-02-14 16:16:43 PST
(In reply to comment #13)
> (From update of attachment 126954 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=126954&action=review
> 
> > Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:268
> > +    return m_acceptedExtensionsBuilder.toAtomicString().string();
> 
> Why toAtomicString().string() instead of toString()?

StringBuilder::toString() isn't a const member function so I can't call it in acceptedExtensions(), which is a const member function. Looks like win EWS is red and I can't call toAtomicString() here so I'll make m_acceptedExtensionsBuilder mutable.
Comment 15 Kent Tamura 2012-02-14 16:24:33 PST
Comment on attachment 126954 [details]
Patch

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

>>> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:268
>>> +    return m_acceptedExtensionsBuilder.toAtomicString().string();
>> 
>> Why toAtomicString().string() instead of toString()?
> 
> StringBuilder::toString() isn't a const member function so I can't call it in acceptedExtensions(), which is a const member function. Looks like win EWS is red and I can't call toAtomicString() here so I'll make m_acceptedExtensionsBuilder mutable.

Ah, I see. StringBuilder::toString() is not const.
How about StringBuilder::toStringPreserveCapacity()?
Comment 16 Kenichi Ishibashi 2012-02-14 16:53:39 PST
Created attachment 127081 [details]
Patch
Comment 17 Kenichi Ishibashi 2012-02-14 16:54:20 PST
Comment on attachment 126954 [details]
Patch

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

>>>> Source/WebCore/websockets/WebSocketExtensionDispatcher.cpp:268
>>>> +    return m_acceptedExtensionsBuilder.toAtomicString().string();
>>> 
>>> Why toAtomicString().string() instead of toString()?
>> 
>> StringBuilder::toString() isn't a const member function so I can't call it in acceptedExtensions(), which is a const member function. Looks like win EWS is red and I can't call toAtomicString() here so I'll make m_acceptedExtensionsBuilder mutable.
> 
> Ah, I see. StringBuilder::toString() is not const.
> How about StringBuilder::toStringPreserveCapacity()?

It works. Thank you!
Comment 18 Kent Tamura 2012-02-14 17:26:56 PST
Comment on attachment 127081 [details]
Patch

ok
Comment 19 Kenichi Ishibashi 2012-02-14 17:32:48 PST
Comment on attachment 127081 [details]
Patch

Thanks!
Comment 20 WebKit Review Bot 2012-02-14 18:12:03 PST
Comment on attachment 127081 [details]
Patch

Clearing flags on attachment: 127081

Committed r107769: <http://trac.webkit.org/changeset/107769>
Comment 21 WebKit Review Bot 2012-02-14 18:12:09 PST
All reviewed patches have been landed.  Closing bug.