WebKit Bugzilla
Attachment 372916 Details for
Bug 199151
: [SOUP] Use libsoup WebSockets API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wk2-soup-websockets.diff (text/plain), 23.68 KB, created by
Carlos Garcia Campos
on 2019-06-26 05:02:04 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2019-06-26 05:02:04 PDT
Size:
23.68 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e3c86f6388f..fa51daec854 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2019-06-26 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [SOUP] Use libsoup WebSockets API >+ https://bugs.webkit.org/show_bug.cgi?id=199151 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use createWebSocketChannel() from the provider also for libsoup when WEBKIT_USE_SOUP_WEBSOCKETS env var is set. >+ >+ * Modules/websockets/ThreadableWebSocketChannel.cpp: >+ (WebCore::ThreadableWebSocketChannel::create): >+ > 2019-06-25 Fujii Hironori <Hironori.Fujii@sony.com> > > [WinCairo] incorrect font height for 'Google Sans Display' font >diff --git a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >index 7142ea9e661..00e206da66c 100644 >--- a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >+++ b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >@@ -58,12 +58,19 @@ Ref<ThreadableWebSocketChannel> ThreadableWebSocketChannel::create(ScriptExecuti > > auto& document = downcast<Document>(context); > >+ bool shouldProviderCreateSocketChannel = false; > #if HAVE(NSURLSESSION_WEBSOCKET) >- if (RuntimeEnabledFeatures::sharedFeatures().isNSURLSessionWebSocketEnabled()) { >+ shouldProviderCreateSocketChannel = RuntimeEnabledFeatures::sharedFeatures().isNSURLSessionWebSocketEnabled(); >+#endif >+#if USE(SOUP) >+ shouldProviderCreateSocketChannel = getenv("WEBKIT_USE_SOUP_WEBSOCKETS"); >+#endif >+ >+ if (shouldProviderCreateSocketChannel) { > if (auto channel = provider.createWebSocketChannel(document, client)) > return channel.releaseNonNull(); > } >-#endif >+ > return WebSocketChannel::create(document, client, provider); > } > >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 4cc8c2158b5..8aa7b9a47c2 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,50 @@ >+2019-06-26 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [SOUP] Use libsoup WebSockets API >+ https://bugs.webkit.org/show_bug.cgi?id=199151 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use the new WebSockets code path that depends on platform specific WebSockets implementation using the libsoup >+ API. This is an initial implementation manually tested using the layout tests, which most of them fail due to >+ missing console messages, missing features in the new code path or differences in the platform >+ implementation. It will be disabled by default until it's feature complete compared to the internal WebKit >+ implementation. >+ >+ * NetworkProcess/NetworkSocketChannel.cpp: >+ (WebKit::NetworkSocketChannel::NetworkSocketChannel): Null check m_socket before using it, because >+ createWebSocketTask() can return nullptr; >+ (WebKit::NetworkSocketChannel::didConnect): Receive the protocol accepted by the server. >+ (WebKit::NetworkSocketChannel::didFail): Something failed in the server side. >+ * NetworkProcess/NetworkSocketChannel.h: >+ * NetworkProcess/WebSocketTask.h: >+ * NetworkProcess/soup/NetworkSessionSoup.cpp: >+ (WebKit::NetworkSessionSoup::createWebSocketTask): Create a WebSocketTask. >+ * NetworkProcess/soup/NetworkSessionSoup.h: >+ * NetworkProcess/soup/WebSocketTaskSoup.cpp: Added. >+ (WebKit::WebSocketTask::WebSocketTask): >+ (WebKit::WebSocketTask::~WebSocketTask): >+ (WebKit::WebSocketTask::didConnect): >+ (WebKit::WebSocketTask::didReceiveMessageCallback): >+ (WebKit::WebSocketTask::didReceiveErrorCallback): >+ (WebKit::WebSocketTask::didFail): >+ (WebKit::WebSocketTask::didCloseCallback): >+ (WebKit::WebSocketTask::didClose): >+ (WebKit::WebSocketTask::sendString): >+ (WebKit::WebSocketTask::sendData): >+ (WebKit::WebSocketTask::close): >+ (WebKit::WebSocketTask::cancel): >+ (WebKit::WebSocketTask::resume): >+ * NetworkProcess/soup/WebSocketTaskSoup.h: Copied from Source/WebKit/NetworkProcess/WebSocketTask.h. >+ * SourcesGTK.txt: >+ * WebProcess/Network/WebSocketChannel.cpp: >+ (WebKit::WebSocketChannel::subprotocol): Return the protocol accepted by the server. >+ (WebKit::WebSocketChannel::didConnect): Set the protocol accepted by the server. >+ (WebKit::WebSocketChannel::didFail): It's now an IPC message handler and receives the reason as parameter. >+ (WebKit::WebSocketChannel::networkProcessCrashed): Pass empty reason. >+ * WebProcess/Network/WebSocketChannel.h: >+ * WebProcess/Network/WebSocketChannel.messages.in: >+ > 2019-06-25 Jiewen Tan <jiewen_tan@apple.com> > > Implement a new SPI to inform clients about AppSSO >diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp b/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp >index 9483adabbc1..27410c892a4 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp >@@ -55,9 +55,10 @@ NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connec > return; > > m_socket = m_session->createWebSocketTask(*this, request, protocol); >- >- m_session->addWebSocketTask(*m_socket); >- m_socket->resume(); >+ if (m_socket) { >+ m_session->addWebSocketTask(*m_socket); >+ m_socket->resume(); >+ } > } > > NetworkSocketChannel::~NetworkSocketChannel() >@@ -96,9 +97,9 @@ void NetworkSocketChannel::close(int32_t code, const String& reason) > finishClosingIfPossible(); > } > >-void NetworkSocketChannel::didConnect() >+void NetworkSocketChannel::didConnect(const String& subprotocol) > { >- send(Messages::WebSocketChannel::DidConnect { }); >+ send(Messages::WebSocketChannel::DidConnect { subprotocol }); > } > > void NetworkSocketChannel::didReceiveText(const String& text) >@@ -117,6 +118,11 @@ void NetworkSocketChannel::didClose(unsigned short code, const String& reason) > finishClosingIfPossible(); > } > >+void NetworkSocketChannel::didFail(const String& reason) >+{ >+ send(Messages::WebSocketChannel::DidFail { reason }); >+} >+ > IPC::Connection* NetworkSocketChannel::messageSenderConnection() const > { > return &m_connectionToWebProcess.connection(); >diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.h b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h >index d07693745fb..c32049b8423 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSocketChannel.h >+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h >@@ -59,10 +59,11 @@ public: > friend class WebSocketTask; > > private: >- void didConnect(); >+ void didConnect(const String& subprotocol); > void didReceiveText(const String&); > void didReceiveBinaryData(const uint8_t* data, size_t length); > void didClose(unsigned short code, const String& reason); >+ void didFail(const String& reason); > > void sendString(const String&, CompletionHandler<void()>&&); > void sendData(const IPC::DataReference&, CompletionHandler<void()>&&); >diff --git a/Source/WebKit/NetworkProcess/WebSocketTask.h b/Source/WebKit/NetworkProcess/WebSocketTask.h >index 939f601860d..3a59ffa6a1a 100644 >--- a/Source/WebKit/NetworkProcess/WebSocketTask.h >+++ b/Source/WebKit/NetworkProcess/WebSocketTask.h >@@ -27,6 +27,8 @@ > > #if PLATFORM(COCOA) && HAVE(NSURLSESSION_WEBSOCKET) > #include "WebSocketTaskCocoa.h" >+#elif USE(SOUP) >+#include "WebSocketTaskSoup.h" > #else > > namespace WebKit { >diff --git a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp >index b24e831a229..5337f8417e5 100644 >--- a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp >+++ b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp >@@ -29,7 +29,9 @@ > #include "NetworkProcess.h" > #include "NetworkSessionCreationParameters.h" > #include "WebCookieManager.h" >+#include "WebSocketTaskSoup.h" > #include <WebCore/NetworkStorageSession.h> >+#include <WebCore/ResourceRequest.h> > #include <WebCore/SoupNetworkSession.h> > #include <libsoup/soup.h> > >@@ -65,4 +67,15 @@ void NetworkSessionSoup::clearCredentials() > #endif > } > >+std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol) >+{ >+ GUniquePtr<SoupURI> soupURI = request.createSoupURI(); >+ if (!soupURI) >+ return nullptr; >+ >+ GRefPtr<SoupMessage> soupMessage = adoptGRef(soup_message_new_from_uri(SOUP_METHOD_GET, soupURI.get())); >+ request.updateSoupMessage(soupMessage.get()); >+ return std::make_unique<WebSocketTask>(channel, soupSession(), soupMessage.get(), protocol); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h >index dd864dd642c..c3130568262 100644 >--- a/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h >+++ b/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h >@@ -31,6 +31,8 @@ typedef struct _SoupSession SoupSession; > > namespace WebKit { > >+class NetworkSocketChannel; >+class WebSocketTask; > struct NetworkSessionCreationParameters; > > class NetworkSessionSoup final : public NetworkSession { >@@ -46,6 +48,8 @@ public: > private: > NetworkSessionSoup(NetworkProcess&, NetworkSessionCreationParameters&&); > >+ std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) override; >+ > void clearCredentials() override; > }; > >diff --git a/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp b/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp >new file mode 100644 >index 00000000000..b502fa0510c >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp >@@ -0,0 +1,181 @@ >+/* >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WebSocketTaskSoup.h" >+ >+#include "DataReference.h" >+#include "NetworkSocketChannel.h" >+#include <WebCore/HTTPParsers.h> >+#include <wtf/glib/GUniquePtr.h> >+ >+namespace WebKit { >+ >+WebSocketTask::WebSocketTask(NetworkSocketChannel& channel, SoupSession* session, SoupMessage* msg, const String& protocol) >+ : m_channel(channel) >+ , m_cancellable(adoptGRef(g_cancellable_new())) >+{ >+ auto protocolList = protocol.split(','); >+ GUniquePtr<char*> protocols; >+ if (!protocolList.isEmpty()) { >+ protocols.reset(static_cast<char**>(g_new0(char*, protocolList.size() + 1))); >+ unsigned i = 0; >+ for (auto& subprotocol : protocolList) >+ protocols.get()[i++] = g_strdup(WebCore::stripLeadingAndTrailingHTTPSpaces(subprotocol).utf8().data()); >+ } >+ soup_session_websocket_connect_async(session, msg, nullptr, protocols.get(), m_cancellable.get(), >+ [] (GObject* session, GAsyncResult* result, gpointer userData) { >+ GUniqueOutPtr<GError> error; >+ GRefPtr<SoupWebsocketConnection> connection = adoptGRef(soup_session_websocket_connect_finish(SOUP_SESSION(session), result, &error.outPtr())); >+ if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) >+ return; >+ auto* task = static_cast<WebSocketTask*>(userData); >+ if (connection) >+ task->didConnect(WTFMove(connection)); >+ else >+ task->didFail(String::fromUTF8(error->message)); >+ }, this); >+} >+ >+WebSocketTask::~WebSocketTask() >+{ >+ cancel(); >+} >+ >+void WebSocketTask::didConnect(GRefPtr<SoupWebsocketConnection>&& connection) >+{ >+ m_connection = WTFMove(connection); >+ >+#if SOUP_CHECK_VERSION(2, 56, 0) >+ // Use the same maximum payload length as WebKit internal implementation for backwards compatibility. >+ static const uint64_t maxPayloadLength = UINT64_C(0x7FFFFFFFFFFFFFFF); >+ soup_websocket_connection_set_max_incoming_payload_size(m_connection.get(), maxPayloadLength); >+#endif >+ >+ g_signal_connect_swapped(m_connection.get(), "message", reinterpret_cast<GCallback>(didReceiveMessageCallback), this); >+ g_signal_connect_swapped(m_connection.get(), "error", reinterpret_cast<GCallback>(didReceiveErrorCallback), this); >+ g_signal_connect_swapped(m_connection.get(), "closed", reinterpret_cast<GCallback>(didCloseCallback), this); >+ >+ m_channel.didConnect(soup_websocket_connection_get_protocol(m_connection.get())); >+} >+ >+void WebSocketTask::didReceiveMessageCallback(WebSocketTask* task, SoupWebsocketDataType dataType, GBytes* message) >+{ >+ if (g_cancellable_is_cancelled(task->m_cancellable.get())) >+ return; >+ >+ switch (dataType) { >+ case SOUP_WEBSOCKET_DATA_TEXT: >+ task->m_channel.didReceiveText(String::fromUTF8(static_cast<const char*>(g_bytes_get_data(message, nullptr)))); >+ break; >+ case SOUP_WEBSOCKET_DATA_BINARY: { >+ gsize dataSize; >+ auto data = g_bytes_get_data(message, &dataSize); >+ task->m_channel.didReceiveBinaryData(static_cast<const uint8_t*>(data), dataSize); >+ break; >+ } >+ } >+} >+ >+void WebSocketTask::didReceiveErrorCallback(WebSocketTask* task, GError* error) >+{ >+ if (g_cancellable_is_cancelled(task->m_cancellable.get())) >+ return; >+ >+ task->didFail(String::fromUTF8(error->message)); >+} >+ >+void WebSocketTask::didFail(const String& reason) >+{ >+ if (m_receivedDidFail) >+ return; >+ >+ m_receivedDidFail = true; >+ m_channel.didFail(reason); >+ if (!m_connection) { >+ didClose(SOUP_WEBSOCKET_CLOSE_ABNORMAL, { }); >+ return; >+ } >+ >+ if (soup_websocket_connection_get_state(m_connection.get()) == SOUP_WEBSOCKET_STATE_OPEN) >+ didClose(0, { }); >+} >+ >+void WebSocketTask::didCloseCallback(WebSocketTask* task) >+{ >+ task->didClose(soup_websocket_connection_get_close_code(task->m_connection.get()), String::fromUTF8(soup_websocket_connection_get_close_data(task->m_connection.get()))); >+} >+ >+void WebSocketTask::didClose(unsigned short code, const String& reason) >+{ >+ if (m_receivedDidClose) >+ return; >+ >+ m_receivedDidClose = true; >+ m_channel.didClose(code, reason); >+} >+ >+void WebSocketTask::sendString(const String& text, CompletionHandler<void()>&& callback) >+{ >+ if (m_connection && soup_websocket_connection_get_state(m_connection.get()) == SOUP_WEBSOCKET_STATE_OPEN) >+ soup_websocket_connection_send_text(m_connection.get(), text.utf8().data()); >+ callback(); >+} >+ >+void WebSocketTask::sendData(const IPC::DataReference& data, CompletionHandler<void()>&& callback) >+{ >+ if (m_connection && soup_websocket_connection_get_state(m_connection.get()) == SOUP_WEBSOCKET_STATE_OPEN) >+ soup_websocket_connection_send_binary(m_connection.get(), data.data(), data.size()); >+ callback(); >+} >+ >+void WebSocketTask::close(int32_t code, const String& reason) >+{ >+ if (m_receivedDidClose) >+ return; >+ >+ if (m_connection) >+ soup_websocket_connection_close(m_connection.get(), code, reason.utf8().data()); >+ else { >+ g_cancellable_cancel(m_cancellable.get()); >+ didClose(code ? code : SOUP_WEBSOCKET_CLOSE_ABNORMAL, reason); >+ } >+} >+ >+void WebSocketTask::cancel() >+{ >+ g_cancellable_cancel(m_cancellable.get()); >+ >+ if (m_connection) { >+ g_signal_handlers_disconnect_matched(m_connection.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); >+ m_connection = nullptr; >+ } >+} >+ >+void WebSocketTask::resume() >+{ >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h b/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h >new file mode 100644 >index 00000000000..712ee6ac200 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <libsoup/soup.h> >+#include <wtf/glib/GRefPtr.h> >+ >+namespace IPC { >+class DataReference; >+} >+ >+namespace WebKit { >+class NetworkSocketChannel; >+ >+class WebSocketTask { >+public: >+ WebSocketTask(NetworkSocketChannel&, SoupSession*, SoupMessage*, const String& protocol); >+ ~WebSocketTask(); >+ >+ void sendString(const String&, CompletionHandler<void()>&&); >+ void sendData(const IPC::DataReference&, CompletionHandler<void()>&&); >+ void close(int32_t code, const String& reason); >+ >+ void cancel(); >+ void resume(); >+ >+private: >+ void didConnect(GRefPtr<SoupWebsocketConnection>&&); >+ void didFail(const String& reason); >+ void didClose(unsigned short code, const String& reason); >+ >+ static void didReceiveMessageCallback(WebSocketTask*, SoupWebsocketDataType, GBytes*); >+ static void didReceiveErrorCallback(WebSocketTask*, GError*); >+ static void didCloseCallback(WebSocketTask*); >+ >+ NetworkSocketChannel& m_channel; >+ GRefPtr<SoupWebsocketConnection> m_connection; >+ GRefPtr<GCancellable> m_cancellable; >+ bool m_receivedDidFail { false }; >+ bool m_receivedDidClose { false }; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/SourcesGTK.txt b/Source/WebKit/SourcesGTK.txt >index d3fea01b28b..d9a0aec686c 100644 >--- a/Source/WebKit/SourcesGTK.txt >+++ b/Source/WebKit/SourcesGTK.txt >@@ -42,6 +42,7 @@ NetworkProcess/soup/NetworkProcessSoup.cpp > NetworkProcess/soup/NetworkSessionSoup.cpp > NetworkProcess/soup/RemoteNetworkingContextSoup.cpp > NetworkProcess/soup/WebKitSoupRequestInputStream.cpp >+NetworkProcess/soup/WebSocketTaskSoup.cpp > > NetworkProcess/webrtc/LibWebRTCSocketClient.cpp > NetworkProcess/webrtc/NetworkRTCMonitor.cpp >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp b/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp >index bc222e44efc..e3a23a44aa4 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp >@@ -67,8 +67,7 @@ uint64_t WebSocketChannel::messageSenderDestinationID() const > > String WebSocketChannel::subprotocol() > { >- // FIXME: support subprotocol. >- return emptyString(); >+ return m_subprotocol.isNull() ? emptyString() : m_subprotocol; > } > > String WebSocketChannel::extensions() >@@ -162,7 +161,7 @@ void WebSocketChannel::disconnect() > MessageSender::send(Messages::NetworkSocketChannel::Close { 0, { } }); > } > >-void WebSocketChannel::didConnect() >+void WebSocketChannel::didConnect(const String& subprotocol) > { > if (m_isClosing) > return; >@@ -171,12 +170,13 @@ void WebSocketChannel::didConnect() > return; > > if (m_isSuspended) { >- enqueueTask([this] { >- didConnect(); >+ enqueueTask([this, subprotocol] { >+ didConnect(subprotocol); > }); > return; > } > >+ m_subprotocol = subprotocol; > m_client->didConnect(); > } > >@@ -234,24 +234,25 @@ void WebSocketChannel::didClose(unsigned short code, const String& reason) > m_client->didClose(m_bufferedAmount, (m_isClosing || code == WebCore::WebSocketChannel::CloseEventCodeNormalClosure) ? WebCore::WebSocketChannelClient::ClosingHandshakeComplete : WebCore::WebSocketChannelClient::ClosingHandshakeIncomplete, code, reason); > } > >-void WebSocketChannel::didFail() >+void WebSocketChannel::didFail(const String& reason) > { > if (!m_client) > return; > > if (m_isSuspended) { >- enqueueTask([this] { >- didFail(); >+ enqueueTask([this, reason] { >+ didFail(reason); > }); > return; > } > >+ // FIXME: do something with reason. > m_client->didReceiveMessageError(); > } > > void WebSocketChannel::networkProcessCrashed() > { >- didFail(); >+ didFail({ }); > } > > void WebSocketChannel::suspend() >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.h b/Source/WebKit/WebProcess/Network/WebSocketChannel.h >index e4de9c267f4..d8a6aac2112 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketChannel.h >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.h >@@ -49,7 +49,6 @@ public: > void didReceiveMessage(IPC::Connection&, IPC::Decoder&); > > void networkProcessCrashed(); >- void didFail(); > > using RefCounted<WebSocketChannel>::ref; > using RefCounted<WebSocketChannel>::deref; >@@ -74,10 +73,11 @@ private: > void derefThreadableWebSocketChannel() final { deref(); } > > // Message receivers >- void didConnect(); >+ void didConnect(const String&); > void didReceiveText(const String&); > void didReceiveBinaryData(const IPC::DataReference&); > void didClose(unsigned short code, const String&); >+ void didFail(const String&); > > // MessageSender > IPC::Connection* messageSenderConnection() const final; >@@ -87,6 +87,7 @@ private: > > WeakPtr<WebCore::Document> m_document; > WeakPtr<WebCore::WebSocketChannelClient> m_client; >+ String m_subprotocol; > size_t m_bufferedAmount { 0 }; > bool m_isClosing { false }; > bool m_isSuspended { false }; >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in b/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in >index 7ef413baa60..9a1f05cfccb 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in >@@ -21,8 +21,9 @@ > # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > > messages -> WebSocketChannel { >- DidConnect() >+ DidConnect(String subprotocol) > DidClose(unsigned short code, String reason) > DidReceiveText(String message) > DidReceiveBinaryData(IPC::DataReference data) >+ DidFail(String reason) > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199151
:
372750
| 372916