RESOLVED FIXED 159774
Use SocketProvider to create SocketStreamHandles
https://bugs.webkit.org/show_bug.cgi?id=159774
Summary Use SocketProvider to create SocketStreamHandles
Alex Christensen
Reported 2016-07-14 11:17:22 PDT
Use SocketProvider to create SocketStreamHandles
Attachments
Patch (56.37 KB, patch)
2016-07-14 11:20 PDT, Alex Christensen
no flags
Patch (56.93 KB, patch)
2016-07-14 11:26 PDT, Alex Christensen
no flags
Patch (79.38 KB, patch)
2016-07-14 11:58 PDT, Alex Christensen
no flags
Patch (80.66 KB, patch)
2016-07-14 13:06 PDT, Alex Christensen
no flags
Patch (80.55 KB, patch)
2016-07-14 13:55 PDT, Alex Christensen
no flags
Patch (80.49 KB, patch)
2016-07-14 14:16 PDT, Alex Christensen
beidson: review+
Alex Christensen
Comment 1 2016-07-14 11:20:26 PDT
Alex Christensen
Comment 2 2016-07-14 11:26:10 PDT
Brady Eidson
Comment 3 2016-07-14 11:33:54 PDT
Comment on attachment 283664 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=283664&action=review > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:45 > +#include "ThreadableWebSocketChannel.h" > + > +#include "Document.h" > +#include "ScriptExecutionContext.h" > +#include "ThreadableWebSocketChannelClientWrapper.h" > +#include "WebSocketChannel.h" > +#include "WebSocketChannelClient.h" > +#include "WorkerGlobalScope.h" > +#include "WorkerRunLoop.h" > +#include "WorkerThread.h" > +#include "WorkerThreadableWebSocketChannel.h" > +#include <wtf/text/StringBuilder.h> Really needs all of these? > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:49 > +static const char webSocketChannelMode[] = "webSocketChannelMode"; ASCIILiteral? > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:57 > + mode.appendLiteral(webSocketChannelMode); And move the ASCIILiteral here, the only place it's actually used? > Source/WebKit/mac/Misc/WebSocketProvider.mm:51 > +RefPtr<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, NetworkingContext& context, SessionID sessionID) > { > - if (is<WorkerGlobalScope>(context)) { > - WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context); > - WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop(); > - StringBuilder mode; > - mode.appendLiteral(webSocketChannelMode); > - mode.appendNumber(runLoop.createUniqueId()); > - return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString()); > - } > - > - return WebSocketChannel::create(downcast<Document>(context), client); > + return SocketStreamHandle::create(url, client, context, sessionID); Default WebCore::SocketProvider should just do this, and the WebKit2 one should override.
Alex Christensen
Comment 4 2016-07-14 11:58:56 PDT
Alex Christensen
Comment 5 2016-07-14 12:06:28 PDT
(In reply to comment #3) > Comment on attachment 283664 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=283664&action=review > > > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:45 > > +#include "ThreadableWebSocketChannel.h" > > + > > +#include "Document.h" > > +#include "ScriptExecutionContext.h" > > +#include "ThreadableWebSocketChannelClientWrapper.h" > > +#include "WebSocketChannel.h" > > +#include "WebSocketChannelClient.h" > > +#include "WorkerGlobalScope.h" > > +#include "WorkerRunLoop.h" > > +#include "WorkerThread.h" > > +#include "WorkerThreadableWebSocketChannel.h" > > +#include <wtf/text/StringBuilder.h> > > Really needs all of these? Yes. > > > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:49 > > +static const char webSocketChannelMode[] = "webSocketChannelMode"; > > ASCIILiteral? > > > Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:57 > > + mode.appendLiteral(webSocketChannelMode); > > And move the ASCIILiteral here, the only place it's actually used? StringBuilder has a nice appendLiteral(const char (&characters)[charactersCount]) which counts the characters at compile time. > > > Source/WebKit/mac/Misc/WebSocketProvider.mm:51 > > +RefPtr<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, NetworkingContext& context, SessionID sessionID) > > { > > - if (is<WorkerGlobalScope>(context)) { > > - WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context); > > - WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop(); > > - StringBuilder mode; > > - mode.appendLiteral(webSocketChannelMode); > > - mode.appendNumber(runLoop.createUniqueId()); > > - return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString()); > > - } > > - > > - return WebSocketChannel::create(downcast<Document>(context), client); > > + return SocketStreamHandle::create(url, client, context, sessionID); > > Default WebCore::SocketProvider should just do this, and the WebKit2 one > should override. Done.
Alex Christensen
Comment 6 2016-07-14 13:06:31 PDT
Alex Christensen
Comment 7 2016-07-14 13:55:53 PDT
Alex Christensen
Comment 8 2016-07-14 14:16:16 PDT
Alex Christensen
Comment 9 2016-07-14 14:44:07 PDT
Csaba Osztrogonác
Comment 10 2016-07-26 07:00:08 PDT
(In reply to comment #9) > https://trac.webkit.org/changeset/203244 It broke the !ENABLE(WEB_SOCKETS) build, because WebCore::SocketProvider is defined inside guards, but this change uses it without guard: ../../Source/WebCore/inspector/InspectorOverlay.cpp: In member function 'WebCore::Page* WebCore::InspectorOverlay::overlayPage()': ../../Source/WebCore/inspector/InspectorOverlay.cpp:867:77: error: 'create' is not a member of 'WebCore::SocketProvider'
Csaba Osztrogonác
Comment 11 2016-07-26 07:16:46 PDT
This snippet in Source/WebCore/page/SocketProvider.h fixes the build, but I'm not sure if it is the proper fix here. I don't have any time to investigate and/or prepare patch, feel free to pick it up or fix it however you want. -#if ENABLE(WEB_SOCKETS) static Ref<SocketProvider> create() { return adoptRef(*new SocketProvider); } +#if ENABLE(WEB_SOCKETS)
Note You need to log in before you can comment on or make changes to this bug.