Title: [214114] trunk/Source/WebCore
Revision
214114
Author
[email protected]
Date
2017-03-17 13:30:37 -0700 (Fri, 17 Mar 2017)

Log Message

Make SocketStreamHandle virtual functions asynchronous
https://bugs.webkit.org/show_bug.cgi?id=169818

Reviewed by Andy Estes.

No change in behavior.  Instead of returning immediately, call a completion handler.
This is in preparation for making them truly asynchronous.

I still need to be able to synchronously get the number of buffered bytes, but the
buffer itself will soon be in the NetworkProcess with a new subclass of SocketStreamHandle
that messages across IPC.  The number of buffered bytes will still be stored in the WebProcess,
and when it updates, the message from SocketStreamHandleClient::didUpdateBufferedAmount will update it.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/network/SocketStreamHandle.cpp:
(WebCore::SocketStreamHandle::send):
(WebCore::SocketStreamHandle::close):
(WebCore::SocketStreamHandle::sendPendingData): Deleted.
* platform/network/SocketStreamHandle.h:
(WebCore::SocketStreamHandle::bufferedAmount): Deleted.
* platform/network/SocketStreamHandleImpl.cpp: Added.
(WebCore::SocketStreamHandleImpl::platformSend):
(WebCore::SocketStreamHandleImpl::sendPendingData):
(WebCore::SocketStreamHandleImpl::bufferedAmount):
m_buffer was moved from SocketStreamHandle to SocketStreamHandleImpl, so some of the logic must move with it.
I moved as much logic that was shared in the superclass to a new shared location for code shared among the subclass implementations.
* platform/network/cf/SocketStreamHandleImpl.h:
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::SocketStreamHandleImpl::platformSendInternal):
(WebCore::SocketStreamHandleImpl::platformSend): Deleted.
* platform/network/curl/SocketStreamHandleImpl.h:
* platform/network/curl/SocketStreamHandleImplCurl.cpp:
(WebCore::SocketStreamHandleImpl::platformSendInternal):
(WebCore::SocketStreamHandleImpl::platformSend): Deleted.
* platform/network/soup/SocketStreamHandleImpl.h:
* platform/network/soup/SocketStreamHandleImplSoup.cpp:
(WebCore::SocketStreamHandleImpl::platformSendInternal):
(WebCore::SocketStreamHandleImpl::platformSend): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (214113 => 214114)


--- trunk/Source/WebCore/CMakeLists.txt	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-03-17 20:30:37 UTC (rev 214114)
@@ -2423,6 +2423,7 @@
     platform/network/ResourceRequestBase.cpp
     platform/network/ResourceResponseBase.cpp
     platform/network/SocketStreamHandle.cpp
+    platform/network/SocketStreamHandleImpl.cpp
     platform/network/SynchronousLoaderClient.cpp
 
     platform/sql/SQLiteAuthorizer.cpp

Modified: trunk/Source/WebCore/ChangeLog (214113 => 214114)


--- trunk/Source/WebCore/ChangeLog	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/ChangeLog	2017-03-17 20:30:37 UTC (rev 214114)
@@ -1,3 +1,45 @@
+2017-03-17  Alex Christensen  <[email protected]>
+
+        Make SocketStreamHandle virtual functions asynchronous
+        https://bugs.webkit.org/show_bug.cgi?id=169818
+
+        Reviewed by Andy Estes.
+
+        No change in behavior.  Instead of returning immediately, call a completion handler.
+        This is in preparation for making them truly asynchronous.
+
+        I still need to be able to synchronously get the number of buffered bytes, but the
+        buffer itself will soon be in the NetworkProcess with a new subclass of SocketStreamHandle
+        that messages across IPC.  The number of buffered bytes will still be stored in the WebProcess,
+        and when it updates, the message from SocketStreamHandleClient::didUpdateBufferedAmount will update it.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/network/SocketStreamHandle.cpp:
+        (WebCore::SocketStreamHandle::send):
+        (WebCore::SocketStreamHandle::close):
+        (WebCore::SocketStreamHandle::sendPendingData): Deleted.
+        * platform/network/SocketStreamHandle.h:
+        (WebCore::SocketStreamHandle::bufferedAmount): Deleted.
+        * platform/network/SocketStreamHandleImpl.cpp: Added.
+        (WebCore::SocketStreamHandleImpl::platformSend):
+        (WebCore::SocketStreamHandleImpl::sendPendingData):
+        (WebCore::SocketStreamHandleImpl::bufferedAmount):
+        m_buffer was moved from SocketStreamHandle to SocketStreamHandleImpl, so some of the logic must move with it.
+        I moved as much logic that was shared in the superclass to a new shared location for code shared among the subclass implementations.
+        * platform/network/cf/SocketStreamHandleImpl.h:
+        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+        (WebCore::SocketStreamHandleImpl::platformSendInternal):
+        (WebCore::SocketStreamHandleImpl::platformSend): Deleted.
+        * platform/network/curl/SocketStreamHandleImpl.h:
+        * platform/network/curl/SocketStreamHandleImplCurl.cpp:
+        (WebCore::SocketStreamHandleImpl::platformSendInternal):
+        (WebCore::SocketStreamHandleImpl::platformSend): Deleted.
+        * platform/network/soup/SocketStreamHandleImpl.h:
+        * platform/network/soup/SocketStreamHandleImplSoup.cpp:
+        (WebCore::SocketStreamHandleImpl::platformSendInternal):
+        (WebCore::SocketStreamHandleImpl::platformSend): Deleted.
+
 2017-03-17  Antti Koivisto  <[email protected]>
 
         Add a reload policy where only expired subresources are revalidated

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (214113 => 214114)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-17 20:30:37 UTC (rev 214114)
@@ -2647,6 +2647,7 @@
 		5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; };
 		5C5381B21D87D4B200E2EBE6 /* URLSearchParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5381B01D87D45700E2EBE6 /* URLSearchParams.cpp */; };
 		5C5381B51D87E08700E2EBE6 /* JSURLSearchParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */; };
+		5C668E651E7C6C4000D32B3B /* SocketStreamHandleImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */; };
 		5C688AA11D380BF8000B54FA /* ThreadableWebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */; };
 		5C688AA31D3814BF000B54FA /* SocketProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C688AA21D38126F000B54FA /* SocketProvider.cpp */; };
 		5C6E65421D5CEFB900F7862E /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E653F1D5CEDC900F7862E /* URLParser.cpp */; };
@@ -10338,6 +10339,7 @@
 		5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSearchParams.h; sourceTree = "<group>"; };
 		5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
 		5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSURLSearchParams.h; sourceTree = "<group>"; };
+		5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImpl.cpp; sourceTree = "<group>"; };
 		5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
 		5C688AA21D38126F000B54FA /* SocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketProvider.cpp; sourceTree = "<group>"; };
 		5C6E653F1D5CEDC900F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
@@ -18763,6 +18765,7 @@
 				510D4A30103165EE0049EA54 /* SocketStreamHandle.cpp */,
 				510D4A31103165EE0049EA54 /* SocketStreamHandle.h */,
 				510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */,
+				5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */,
 				E180811016FCF42E00B80D07 /* SynchronousLoaderClient.cpp */,
 				E180811516FCF9CB00B80D07 /* SynchronousLoaderClient.h */,
 			);
@@ -30753,6 +30756,7 @@
 				2D5002F81B56D7810020AAF7 /* DOMPath.cpp in Sources */,
 				A9C6E4EB0D745E2B006442E9 /* DOMPlugin.cpp in Sources */,
 				A9C6E4EF0D745E38006442E9 /* DOMPluginArray.cpp in Sources */,
+				5C668E651E7C6C4000D32B3B /* SocketStreamHandleImpl.cpp in Sources */,
 				BC5A86840C33676000EEA649 /* DOMSelection.cpp in Sources */,
 				C55610F111A704EB00B82D27 /* DOMStringList.cpp in Sources */,
 				188604B30F2E654A000B6443 /* DOMTimer.cpp in Sources */,

Modified: trunk/Source/WebCore/platform/network/SocketStreamHandle.cpp (214113 => 214114)


--- trunk/Source/WebCore/platform/network/SocketStreamHandle.cpp	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/SocketStreamHandle.cpp	2017-03-17 20:30:37 UTC (rev 214114)
@@ -36,8 +36,6 @@
 
 namespace WebCore {
 
-const unsigned bufferSize = 100 * 1024 * 1024;
-
 SocketStreamHandle::SocketStreamHandle(const URL& url, SocketStreamHandleClient& client)
     : m_url(url)
     , m_client(client)
@@ -54,31 +52,7 @@
 {
     if (m_state == Connecting || m_state == Closing)
         return completionHandler(false);
-    if (!m_buffer.isEmpty()) {
-        if (m_buffer.size() + length > bufferSize) {
-            // FIXME: report error to indicate that buffer has no more space.
-            return completionHandler(false);
-        }
-        m_buffer.append(data, length);
-        m_client.didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount());
-        return completionHandler(true);
-    }
-    size_t bytesWritten = 0;
-    if (m_state == Open) {
-        if (auto result = platformSend(data, length))
-            bytesWritten = result.value();
-        else
-            return completionHandler(false);
-    }
-    if (m_buffer.size() + length - bytesWritten > bufferSize) {
-        // FIXME: report error to indicate that buffer has no more space.
-        return completionHandler(false);
-    }
-    if (bytesWritten < length) {
-        m_buffer.append(data + bytesWritten, length - bytesWritten);
-        m_client.didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount());
-    }
-    return completionHandler(true);
+    platformSend(data, length, WTFMove(completionHandler));
 }
 
 void SocketStreamHandle::close()
@@ -86,7 +60,7 @@
     if (m_state == Closed)
         return;
     m_state = Closing;
-    if (!m_buffer.isEmpty())
+    if (bufferedAmount())
         return;
     disconnect();
 }
@@ -99,32 +73,4 @@
     m_state = Closed;
 }
 
-bool SocketStreamHandle::sendPendingData()
-{
-    if (m_state != Open && m_state != Closing)
-        return false;
-    if (m_buffer.isEmpty()) {
-        if (m_state == Open)
-            return false;
-        if (m_state == Closing) {
-            disconnect();
-            return false;
-        }
-    }
-    bool pending;
-    do {
-        auto result = platformSend(m_buffer.firstBlockData(), m_buffer.firstBlockSize());
-        if (!result)
-            return false;
-        size_t bytesWritten = result.value();
-        if (!bytesWritten)
-            return false;
-        pending = bytesWritten != m_buffer.firstBlockSize();
-        ASSERT(m_buffer.size() - bytesWritten <= bufferSize);
-        m_buffer.consume(bytesWritten);
-    } while (!pending && !m_buffer.isEmpty());
-    m_client.didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount());
-    return true;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/SocketStreamHandle.h (214113 => 214114)


--- trunk/Source/WebCore/platform/network/SocketStreamHandle.h	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/SocketStreamHandle.h	2017-03-17 20:30:37 UTC (rev 214114)
@@ -32,7 +32,6 @@
 #pragma once
 
 #include "URL.h"
-#include <wtf/StreamBuffer.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
 namespace WebCore {
@@ -48,18 +47,16 @@
     void send(const char* data, size_t length, Function<void(bool)>);
     void close(); // Disconnect after all data in buffer are sent.
     void disconnect();
-    size_t bufferedAmount() const { return m_buffer.size(); }
+    virtual size_t bufferedAmount() = 0;
 
 protected:
     SocketStreamHandle(const URL&, SocketStreamHandleClient&);
 
-    bool sendPendingData();
-    virtual std::optional<size_t> platformSend(const char* data, size_t length) = 0;
+    virtual void platformSend(const char* data, size_t length, Function<void(bool)>&&) = 0;
     virtual void platformClose() = 0;
 
     URL m_url;
     SocketStreamHandleClient& m_client;
-    StreamBuffer<char, 1024 * 1024> m_buffer;
     SocketStreamState m_state;
 };
 

Added: trunk/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp (0 => 214114)


--- trunk/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp	2017-03-17 20:30:37 UTC (rev 214114)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * 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 "SocketStreamHandleImpl.h"
+
+#include "SocketStreamHandleClient.h"
+#include <wtf/Function.h>
+
+namespace WebCore {
+
+void SocketStreamHandleImpl::platformSend(const char* data, size_t length, Function<void(bool)>&& completionHandler)
+{
+    if (!m_buffer.isEmpty()) {
+        if (m_buffer.size() + length > maxBufferSize) {
+            // FIXME: report error to indicate that buffer has no more space.
+            return completionHandler(false);
+        }
+        m_buffer.append(data, length);
+        m_client.didUpdateBufferedAmount(*this, bufferedAmount());
+        return completionHandler(true);
+    }
+    size_t bytesWritten = 0;
+    if (m_state == Open) {
+        if (auto result = platformSendInternal(data, length))
+            bytesWritten = result.value();
+        else
+            return completionHandler(false);
+    }
+    if (m_buffer.size() + length - bytesWritten > maxBufferSize) {
+        // FIXME: report error to indicate that buffer has no more space.
+        return completionHandler(false);
+    }
+    if (bytesWritten < length) {
+        m_buffer.append(data + bytesWritten, length - bytesWritten);
+        m_client.didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount());
+    }
+    return completionHandler(true);
+}
+
+bool SocketStreamHandleImpl::sendPendingData()
+{
+    if (m_state != Open && m_state != Closing)
+        return false;
+    if (m_buffer.isEmpty()) {
+        if (m_state == Open)
+            return false;
+        if (m_state == Closing) {
+            disconnect();
+            return false;
+        }
+    }
+    bool pending;
+    do {
+        auto result = platformSendInternal(m_buffer.firstBlockData(), m_buffer.firstBlockSize());
+        if (!result)
+            return false;
+        size_t bytesWritten = result.value();
+        if (!bytesWritten)
+            return false;
+        pending = bytesWritten != m_buffer.firstBlockSize();
+        ASSERT(m_buffer.size() - bytesWritten <= maxBufferSize);
+        m_buffer.consume(bytesWritten);
+    } while (!pending && !m_buffer.isEmpty());
+    m_client.didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount());
+    return true;
+}
+
+size_t SocketStreamHandleImpl::bufferedAmount()
+{
+    return m_buffer.size();
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h (214113 => 214114)


--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h	2017-03-17 20:30:37 UTC (rev 214114)
@@ -34,6 +34,7 @@
 #include "SessionID.h"
 #include "SocketStreamHandle.h"
 #include <wtf/RetainPtr.h>
+#include <wtf/StreamBuffer.h>
 
 typedef struct __CFHTTPMessage* CFHTTPMessageRef;
 
@@ -50,8 +51,11 @@
     virtual ~SocketStreamHandleImpl();
 
 private:
-    std::optional<size_t> platformSend(const char* data, size_t length) final;
+    void platformSend(const char* data, size_t length, Function<void(bool)>&&) final;
     void platformClose() final;
+    size_t bufferedAmount() final;
+    std::optional<size_t> platformSendInternal(const char*, size_t);
+    bool sendPendingData();
 
     WEBCORE_EXPORT SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&, SessionID, const String& credentialPartition);
     void createStreams();
@@ -97,6 +101,9 @@
     RetainPtr<CFURLRef> m_httpsURL; // ws(s): replaced with https:
     SessionID m_sessionID;
     String m_credentialPartition;
+    
+    StreamBuffer<char, 1024 * 1024> m_buffer;
+    static const unsigned maxBufferSize = 100 * 1024 * 1024;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (214113 => 214114)


--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2017-03-17 20:30:37 UTC (rev 214114)
@@ -653,7 +653,7 @@
     ASSERT(!m_pacRunLoopSource);
 }
 
-std::optional<size_t> SocketStreamHandleImpl::platformSend(const char* data, size_t length)
+std::optional<size_t> SocketStreamHandleImpl::platformSendInternal(const char* data, size_t length)
 {
     if (!CFWriteStreamCanAcceptBytes(m_writeStream.get()))
         return std::nullopt;

Modified: trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h (214113 => 214114)


--- trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImpl.h	2017-03-17 20:30:37 UTC (rev 214114)
@@ -42,6 +42,7 @@
 #include <wtf/Deque.h>
 #include <wtf/Lock.h>
 #include <wtf/RefCounted.h>
+#include <wtf/StreamBuffer.h>
 #include <wtf/Threading.h>
 
 namespace WebCore {
@@ -57,8 +58,11 @@
 private:
     SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&);
 
-    std::optional<size_t> platformSend(const char* data, size_t length) final;
+    void platformSend(const char* data, size_t length, Function<void(bool)>&&) final;
     void platformClose() final;
+    size_t bufferedAmount() final;
+    std::optional<size_t> platformSendInternal(const char*, size_t);
+    bool sendPendingData();
 
     bool readData(CURL*);
     bool sendData(CURL*);
@@ -94,6 +98,9 @@
     Lock m_mutexReceive;
     Deque<SocketData> m_sendData;
     Deque<SocketData> m_receiveData;
+
+    StreamBuffer<char, 1024 * 1024> m_buffer;
+    static const unsigned maxBufferSize = 100 * 1024 * 1024;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp (214113 => 214114)


--- trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/curl/SocketStreamHandleImplCurl.cpp	2017-03-17 20:30:37 UTC (rev 214114)
@@ -66,7 +66,7 @@
     ASSERT(!m_workerThread);
 }
 
-std::optional<size_t> SocketStreamHandleImpl::platformSend(const char* data, size_t length)
+std::optional<size_t> SocketStreamHandleImpl::platformSendInternal(const char* data, size_t length)
 {
     LOG(Network, "SocketStreamHandle %p platformSend", this);
 

Modified: trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h (214113 => 214114)


--- trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImpl.h	2017-03-17 20:30:37 UTC (rev 214114)
@@ -38,6 +38,7 @@
 
 #include "SessionID.h"
 #include <wtf/RefCounted.h>
+#include <wtf/StreamBuffer.h>
 #include <wtf/glib/GRefPtr.h>
 
 namespace WebCore {
@@ -55,8 +56,11 @@
 private:
     SocketStreamHandleImpl(const URL&, SocketStreamHandleClient&);
 
-    std::optional<size_t> platformSend(const char* data, size_t length) final;
+    void platformSend(const char* data, size_t length, Function<void(bool)>&&) final;
     void platformClose() final;
+    size_t bufferedAmount() final;
+    std::optional<size_t> platformSendInternal(const char*, size_t);
+    bool sendPendingData();
 
     void beginWaitingForSocketWritability();
     void stopWaitingForSocketWritability();
@@ -76,6 +80,9 @@
     GRefPtr<GSource> m_writeReadySource;
     GRefPtr<GCancellable> m_cancellable;
     std::unique_ptr<char[]> m_readBuffer;
+
+    StreamBuffer<char, 1024 * 1024> m_buffer;
+    static const unsigned maxBufferSize = 100 * 1024 * 1024;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp (214113 => 214114)


--- trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp	2017-03-17 19:52:49 UTC (rev 214113)
+++ trunk/Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp	2017-03-17 20:30:37 UTC (rev 214114)
@@ -190,7 +190,7 @@
     sendPendingData();
 }
 
-std::optional<size_t> SocketStreamHandleImpl::platformSend(const char* data, size_t length)
+std::optional<size_t> SocketStreamHandleImpl::platformSendInternal(const char* data, size_t length)
 {
     LOG(Network, "SocketStreamHandle %p platformSend", this);
     if (!m_outputStream || !data)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to