Diff
Modified: trunk/Source/WebCore/ChangeLog (214072 => 214073)
--- trunk/Source/WebCore/ChangeLog 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/ChangeLog 2017-03-16 22:15:58 UTC (rev 214073)
@@ -1,3 +1,24 @@
+2017-03-16 Alex Christensen <achristen...@webkit.org>
+
+ Don't use an optional for didReceiveSocketStreamData's length
+ https://bugs.webkit.org/show_bug.cgi?id=169699
+
+ Reviewed by Brady Eidson.
+
+ Rather than sending a message with an optional length, send a message with a length
+ and send a different message if the receiving of bytes failed.
+
+ No new tests (no behavior change).
+
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::didReceiveSocketStreamData):
+ * Modules/websockets/WebSocketChannel.h:
+ * platform/network/SocketStreamHandleClient.h:
+ * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+ (WebCore::SocketStreamHandleImpl::readStreamCallback):
+ * platform/network/soup/SocketStreamHandleImplSoup.cpp:
+ (WebCore::SocketStreamHandleImpl::readBytes):
+
2017-03-16 Zalan Bujtas <za...@apple.com>
Simple line layout: Extend webkit-hyphenate-limit-lines to cover subsequent words.
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (214072 => 214073)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-03-16 22:15:58 UTC (rev 214073)
@@ -307,18 +307,15 @@
deref();
}
-void WebSocketChannel::didReceiveSocketStreamData(SocketStreamHandle& handle, const char* data, std::optional<size_t> len)
+void WebSocketChannel::didReceiveSocketStreamData(SocketStreamHandle& handle, const char* data, size_t length)
{
- if (len)
- LOG(Network, "WebSocketChannel %p didReceiveSocketStreamData() Received %zu bytes", this, len.value());
- else
- LOG(Network, "WebSocketChannel %p didReceiveSocketStreamData() Received no bytes", this);
+ LOG(Network, "WebSocketChannel %p didReceiveSocketStreamData() Received %zu bytes", this, length);
Ref<WebSocketChannel> protectedThis(*this); // The client can close the channel, potentially removing the last reference.
ASSERT(&handle == m_handle);
if (!m_document) {
return;
}
- if (!len || !len.value()) {
+ if (!length) {
handle.disconnect();
return;
}
@@ -329,7 +326,7 @@
}
if (m_shouldDiscardReceivedData)
return;
- if (!appendToBuffer(data, len.value())) {
+ if (!appendToBuffer(data, length)) {
m_shouldDiscardReceivedData = true;
fail("Ran out of memory while receiving WebSocket data.");
return;
@@ -340,6 +337,11 @@
}
}
+void WebSocketChannel::didFailToReceiveSocketStreamData(SocketStreamHandle& handle)
+{
+ handle.disconnect();
+}
+
void WebSocketChannel::didUpdateBufferedAmount(SocketStreamHandle&, size_t bufferedAmount)
{
if (m_client)
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h (214072 => 214073)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h 2017-03-16 22:15:58 UTC (rev 214073)
@@ -82,7 +82,8 @@
// SocketStreamHandleClient functions.
void didOpenSocketStream(SocketStreamHandle&) final;
void didCloseSocketStream(SocketStreamHandle&) final;
- void didReceiveSocketStreamData(SocketStreamHandle&, const char*, std::optional<size_t>) final;
+ void didReceiveSocketStreamData(SocketStreamHandle&, const char*, size_t) final;
+ void didFailToReceiveSocketStreamData(SocketStreamHandle&) final;
void didUpdateBufferedAmount(SocketStreamHandle&, size_t bufferedAmount) final;
void didFailSocketStream(SocketStreamHandle&, const SocketStreamError&) final;
Modified: trunk/Source/WebCore/platform/network/SocketStreamHandleClient.h (214072 => 214073)
--- trunk/Source/WebCore/platform/network/SocketStreamHandleClient.h 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/platform/network/SocketStreamHandleClient.h 2017-03-16 22:15:58 UTC (rev 214073)
@@ -44,7 +44,8 @@
virtual void didOpenSocketStream(SocketStreamHandle&) = 0;
virtual void didCloseSocketStream(SocketStreamHandle&) = 0;
- virtual void didReceiveSocketStreamData(SocketStreamHandle&, const char* data, std::optional<size_t> length) = 0;
+ virtual void didReceiveSocketStreamData(SocketStreamHandle&, const char* data, size_t length) = 0;
+ virtual void didFailToReceiveSocketStreamData(SocketStreamHandle&) = 0;
virtual void didUpdateBufferedAmount(SocketStreamHandle&, size_t bufferedAmount) = 0;
virtual void didFailSocketStream(SocketStreamHandle&, const SocketStreamError&) = 0;
};
Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (214072 => 214073)
--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-03-16 22:15:58 UTC (rev 214073)
@@ -537,11 +537,10 @@
if (!length)
return;
- std::optional<size_t> optionalLength;
- if (length != -1)
- optionalLength = length;
-
- m_client.didReceiveSocketStreamData(*this, reinterpret_cast<const char*>(ptr), optionalLength);
+ if (length == -1)
+ m_client.didFailToReceiveSocketStreamData(*this);
+ else
+ m_client.didReceiveSocketStreamData(*this, reinterpret_cast<const char*>(ptr), length);
return;
}
Modified: trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp (214072 => 214073)
--- trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp 2017-03-16 22:14:30 UTC (rev 214072)
+++ trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp 2017-03-16 22:15:58 UTC (rev 214073)
@@ -145,11 +145,12 @@
}
// The client can close the handle, potentially removing the last reference.
- RefPtr<SocketStreamHandle> protectedThis(this);
- std::optional<size_t> optionalLength;
- if (bytesRead != -1)
- optionalLength = static_cast<size_t>(bytesRead);
- m_client.didReceiveSocketStreamData(*this, m_readBuffer.get(), optionalLength);
+ Ref<SocketStreamHandle> protectedThis(*this);
+ if (bytesRead == -1)
+ m_client.didFailToReceiveSocketStreamData();
+ else
+ m_client.didReceiveSocketStreamData(*this, m_readBuffer.get(), static_cast<size_t>(bytesRead));
+
if (m_inputStream) {
g_input_stream_read_async(m_inputStream.get(), m_readBuffer.get(), READ_BUFFER_SIZE, G_PRIORITY_DEFAULT, m_cancellable.get(),
reinterpret_cast<GAsyncReadyCallback>(readReadyCallback), protectedThis.leakRef());