Bug 158539 - Modernize WebSocket code
Summary: Modernize WebSocket code
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-08 13:52 PDT by Alex Christensen
Modified: 2016-06-08 15:26 PDT (History)
2 users (show)

See Also:


Attachments
Patch (35.96 KB, patch)
2016-06-08 14:04 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (35.97 KB, patch)
2016-06-08 14:31 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (37.14 KB, patch)
2016-06-08 15:03 PDT, Alex Christensen
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-06-08 13:52:14 PDT
Modernize WebSocket code
Comment 1 Alex Christensen 2016-06-08 14:04:38 PDT
Created attachment 280835 [details]
Patch
Comment 2 Alex Christensen 2016-06-08 14:05:56 PDT
Comment on attachment 280835 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        No new tests (OOPS!).

I'll put "no change in behavior" here
Comment 3 WebKit Commit Bot 2016-06-08 14:06:17 PDT
Attachment 280835 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Alex Christensen 2016-06-08 14:31:11 PDT
Created attachment 280840 [details]
Patch
Comment 5 Brady Eidson 2016-06-08 14:58:45 PDT
Comment on attachment 280840 [details]
Patch

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

> Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp:175
> -    RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper;
> +    RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper.copyRef();
>      m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = WTFMove(workerClientWrapper), sendRequestResult] (ScriptExecutionContext&) {

This can be written as 1 line.

m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = Ref<ThreadableWebSocketChannelClientWrapper>(*m_workerClientWrapper), sendRequestResult] (ScriptExecutionContext&) mutable {

All the other ones like it, too!
Comment 6 Brady Eidson 2016-06-08 14:59:34 PDT
(In reply to comment #5)
> Comment on attachment 280840 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280840&action=review
> 
> > Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp:175
> > -    RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper;
> > +    RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper = m_workerClientWrapper.copyRef();
> >      m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = WTFMove(workerClientWrapper), sendRequestResult] (ScriptExecutionContext&) {
> 
> This can be written as 1 line.
> 
> m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper =
> Ref<ThreadableWebSocketChannelClientWrapper>(*m_workerClientWrapper),
> sendRequestResult] (ScriptExecutionContext&) mutable {
> 
> All the other ones like it, too!

Also, there should be no space between the capture list and the open paren:

m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper =
> Ref<ThreadableWebSocketChannelClientWrapper>(*m_workerClientWrapper),
> sendRequestResult](ScriptExecutionContext&) mutable {
Comment 7 Alex Christensen 2016-06-08 15:03:42 PDT
Created attachment 280845 [details]
Patch
Comment 8 Brady Eidson 2016-06-08 15:12:19 PDT
Comment on attachment 280845 [details]
Patch

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

> Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp:355
> +    auto peer = std::make_unique<Peer>(clientWrapper.copyRef(), loaderProxy, context, taskMode);
> +    bool sent = loaderProxy.postTaskForModeToWorkerGlobalScope({
>          ScriptExecutionContext::Task::CleanupTask,
> -        [clientWrapper, loaderProxy, peer = WTFMove(peer)] (ScriptExecutionContext& context) mutable {
> +        [clientWrapper = clientWrapper.copyRef(), &loaderProxy, peer = WTFMove(peer)] (ScriptExecutionContext& context) mutable {

You could move the peer creation into the capture list.
Comment 9 Alex Christensen 2016-06-08 15:26:36 PDT
http://trac.webkit.org/changeset/201837