<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160310] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160310">160310</a></dd>
<dt>Author</dt> <dd>mrobinson@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-09 06:10:18 -0800 (Mon, 09 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WK2][Soup] Use didReceiveBuffer instead of didReceiveData
https://bugs.webkit.org/show_bug.cgi?id=118598
Reviewed by Gustavo Noronha Silva.
Original patch by Kwang Yul Seo <skyul@company100.net> and Csaba Osztrogonác <ossy@webkit.org>.
Switch from using didReceiveData to didReceiveBuffer for the Soup backend and
let SharedBuffer wrap a SoupBuffer. This is necessary because the NetworkProcess
only supports getting data via SharedBuffer.
Source/WebCore:
* GNUmakefile.list.am: Add the new SharedBufferSoup.cpp file to the list.
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformNix.cmake:
* platform/SharedBuffer.cpp: We no longer used the no-op version of the platformFoo methods.
* platform/SharedBuffer.h: Ditto.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: Use didReceiveBuffer instead of didReceiveData.
* platform/network/ResourceHandleInternal.h: Have only a m_soupBuffer member instead of three to manage the buffer.
* platform/network/soup/GOwnPtrSoup.cpp: Add support for SoupBuffer.
* platform/network/soup/GOwnPtrSoup.h: Ditto.
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::WebCoreSynchronousLoader::didReceiveData): ASSERT_NOT_REACHED here, since it should never be
called now.
(WebCore::WebCoreSynchronousLoader::didReceiveBuffer): Handle this call properly.
(WebCore::ResourceHandle::ensureReadBuffer): Now we package up our buffer into a SoupBuffer.
(WebCore::redirectSkipCallback): Use the new m_soupBuffer member.
(WebCore::cleanupSoupRequestOperation): Ditto.
(WebCore::nextMultipartResponsePartCallback): Ditto.
(WebCore::sendRequestCallback): Ditto.
(WebCore::readCallback):
* platform/soup/SharedBufferSoup.cpp: Added.
Source/WebKit/gtk:
* webkit/webkitdownload.cpp:
(DownloadClient::didReceiveData): Replace with ASSERT_NOT_REACHED.
(DownloadClient::didReceiveBuffer): Use this to process incoming data.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCorePlatformEflcmake">trunk/Source/WebCore/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformNixcmake">trunk/Source/WebCore/PlatformNix.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformSharedBuffercpp">trunk/Source/WebCore/platform/SharedBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformSharedBufferh">trunk/Source/WebCore/platform/SharedBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceHandleInternalh">trunk/Source/WebCore/platform/network/ResourceHandleInternal.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupGOwnPtrSoupcpp">trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupGOwnPtrSouph">trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupResourceHandleSoupcpp">trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp</a></li>
<li><a href="#trunkSourceWebKitgtkChangeLog">trunk/Source/WebKit/gtk/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitgtkwebkitwebkitdownloadcpp">trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/platform/soup/</li>
<li><a href="#trunkSourceWebCoreplatformsoupSharedBufferSoupcpp">trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/ChangeLog        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2013-12-08 Martin Robinson <mrobinson@igalia.com>
+
+ [WK2][Soup] Use didReceiveBuffer instead of didReceiveData
+ https://bugs.webkit.org/show_bug.cgi?id=118598
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Original patch by Kwang Yul Seo <skyul@company100.net> and Csaba Osztrogonác <ossy@webkit.org>.
+
+ Switch from using didReceiveData to didReceiveBuffer for the Soup backend and
+ let SharedBuffer wrap a SoupBuffer. This is necessary because the NetworkProcess
+ only supports getting data via SharedBuffer.
+
+ * GNUmakefile.list.am: Add the new SharedBufferSoup.cpp file to the list.
+ * PlatformEfl.cmake:
+ * PlatformGTK.cmake:
+ * PlatformNix.cmake:
+ * platform/SharedBuffer.cpp: We no longer used the no-op version of the platformFoo methods.
+ * platform/SharedBuffer.h: Ditto.
+ * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: Use didReceiveBuffer instead of didReceiveData.
+ * platform/network/ResourceHandleInternal.h: Have only a m_soupBuffer member instead of three to manage the buffer.
+ * platform/network/soup/GOwnPtrSoup.cpp: Add support for SoupBuffer.
+ * platform/network/soup/GOwnPtrSoup.h: Ditto.
+ * platform/network/soup/ResourceHandleSoup.cpp:
+ (WebCore::WebCoreSynchronousLoader::didReceiveData): ASSERT_NOT_REACHED here, since it should never be
+ called now.
+ (WebCore::WebCoreSynchronousLoader::didReceiveBuffer): Handle this call properly.
+ (WebCore::ResourceHandle::ensureReadBuffer): Now we package up our buffer into a SoupBuffer.
+ (WebCore::redirectSkipCallback): Use the new m_soupBuffer member.
+ (WebCore::cleanupSoupRequestOperation): Ditto.
+ (WebCore::nextMultipartResponsePartCallback): Ditto.
+ (WebCore::sendRequestCallback): Ditto.
+ (WebCore::readCallback):
+ * platform/soup/SharedBufferSoup.cpp: Added.
+
</ins><span class="cx"> 2013-12-09 Michal Poteralski <m.poteralski@samsung.com>
</span><span class="cx">
</span><span class="cx"> DataCloneError exception is not thrown when postMessage's second parameter is the source
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -5939,6 +5939,7 @@
</span><span class="cx">         Source/WebCore/platform/network/SocketStreamHandleBase.cpp \
</span><span class="cx">         Source/WebCore/platform/network/SocketStreamHandleBase.h \
</span><span class="cx">         Source/WebCore/platform/network/SocketStreamHandleClient.h \
</span><ins>+        Source/WebCore/platform/soup/SharedBufferSoup.cpp \
</ins><span class="cx">         Source/WebCore/platform/text/enchant/TextCheckerEnchant.h \
</span><span class="cx">         Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp \
</span><span class="cx">         Source/WebCore/platform/text/BidiContext.cpp \
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformEfl.cmake (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformEfl.cmake        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/PlatformEfl.cmake        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -171,6 +171,8 @@
</span><span class="cx"> platform/posix/FileSystemPOSIX.cpp
</span><span class="cx"> platform/posix/SharedBufferPOSIX.cpp
</span><span class="cx">
</span><ins>+ platform/soup/SharedBufferSoup.cpp
+
</ins><span class="cx"> platform/text/LocaleICU.cpp
</span><span class="cx">
</span><span class="cx"> platform/text/efl/TextBreakIteratorInternalICUEfl.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -203,6 +203,8 @@
</span><span class="cx"> platform/network/soup/SoupURIUtils.cpp
</span><span class="cx"> platform/network/soup/SynchronousLoaderClientSoup.cpp
</span><span class="cx">
</span><ins>+ platform/soup/SharedBufferSoup.cpp
+
</ins><span class="cx"> platform/text/LocaleICU.cpp
</span><span class="cx"> platform/text/TextBreakIteratorICU.cpp
</span><span class="cx"> platform/text/TextCodecICU.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformNixcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformNix.cmake (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformNix.cmake        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/PlatformNix.cmake        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -79,6 +79,8 @@
</span><span class="cx"> platform/gtk/LoggingGtk.cpp
</span><span class="cx"> platform/gtk/SharedBufferGtk.cpp
</span><span class="cx">
</span><ins>+ platform/soup/SharedBuferSoup.cpp
+
</ins><span class="cx"> platform/image-decoders/cairo/ImageDecoderCairo.cpp
</span><span class="cx">
</span><span class="cx"> platform/linux/GamepadDeviceLinux.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSharedBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SharedBuffer.cpp        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx"> return;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- char* destination;
</del><ins>+ char* destination = 0;
</ins><span class="cx"> m_purgeableBuffer = PurgeableBuffer::createUninitialized(m_size, destination);
</span><span class="cx"> if (!m_purgeableBuffer)
</span><span class="cx"> return;
</span><span class="lines">@@ -454,7 +454,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if !USE(CF)
</del><ins>+#if !USE(CF) && !USE(SOUP)
</ins><span class="cx">
</span><span class="cx"> inline void SharedBuffer::clearPlatformData()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSharedBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SharedBuffer.h (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SharedBuffer.h        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/SharedBuffer.h        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -37,6 +37,10 @@
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(SOUP)
+#include "GOwnPtrSoup.h"
+#endif
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> OBJC_CLASS NSData;
</span><span class="cx"> #endif
</span><span class="lines">@@ -87,6 +91,10 @@
</span><span class="cx"> static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef);
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(SOUP)
+ static PassRefPtr<SharedBuffer> wrapSoupBuffer(SoupBuffer*);
+#endif
+
</ins><span class="cx"> // Calling this function will force internal segmented buffers
</span><span class="cx"> // to be merged into a flat buffer. Use getSomeData() whenever possible
</span><span class="cx"> // for better performance.
</span><span class="lines">@@ -197,6 +205,11 @@
</span><span class="cx"> explicit SharedBuffer(CFDataRef);
</span><span class="cx"> RetainPtr<CFDataRef> m_cfData;
</span><span class="cx"> #endif
</span><ins>+
+#if USE(SOUP)
+ explicit SharedBuffer(SoupBuffer*);
+ GOwnPtr<SoupBuffer> m_soupBuffer;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> PassRefPtr<SharedBuffer> utf8Buffer(const String&);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "ResourceHandleClient.h"
</span><span class="cx"> #include "ResourceRequest.h"
</span><span class="cx"> #include "ResourceResponse.h"
</span><ins>+#include "SharedBuffer.h"
</ins><span class="cx"> #include <gst/app/gstappsrc.h>
</span><span class="cx"> #include <gst/gst.h>
</span><span class="cx"> #include <gst/pbutils/missing-plugins.h>
</span><span class="lines">@@ -99,6 +100,7 @@
</span><span class="cx"> virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&);
</span><span class="cx"> virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
</span><span class="cx"> virtual void didReceiveData(ResourceHandle*, const char*, int, int);
</span><ins>+ virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedLength);
</ins><span class="cx"> virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
</span><span class="cx"> virtual void didFail(ResourceHandle*, const ResourceError&);
</span><span class="cx"> virtual void wasBlocked(ResourceHandle*);
</span><span class="lines">@@ -1117,9 +1119,20 @@
</span><span class="cx">
</span><span class="cx"> void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* data, int length, int)
</span><span class="cx"> {
</span><del>- handleDataReceived(data, length);
</del><ins>+ ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void ResourceHandleStreamingClient::didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int /* encodedLength */)
+{
+ // This pattern is suggested by SharedBuffer.h.
+ const char* segment;
+ unsigned position = 0;
+ while (unsigned length = buffer->getSomeData(segment, position)) {
+ handleDataReceived(segment, length);
+ position += length;
+ }
+}
+
</ins><span class="cx"> void ResourceHandleStreamingClient::didFinishLoading(ResourceHandle*, double)
</span><span class="cx"> {
</span><span class="cx"> handleNotifyFinished();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceHandleInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceHandleInternal.h        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/network/ResourceHandleInternal.h        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -106,8 +106,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(SOUP)
</span><span class="cx"> , m_cancelled(false)
</span><del>- , m_readBufferPtr(0)
- , m_readBufferSize(0)
</del><span class="cx"> , m_bodySize(0)
</span><span class="cx"> , m_bodyDataSent(0)
</span><span class="cx"> , m_redirectCount(0)
</span><span class="lines">@@ -196,9 +194,7 @@
</span><span class="cx"> GRefPtr<GCancellable> m_cancellable;
</span><span class="cx"> GRefPtr<GAsyncResult> m_deferredResult;
</span><span class="cx"> GRefPtr<GSource> m_timeoutSource;
</span><del>- GOwnPtr<char> m_defaultReadBuffer;
- char* m_readBufferPtr;
- size_t m_readBufferSize;
</del><ins>+ GOwnPtr<SoupBuffer> m_soupBuffer;
</ins><span class="cx"> unsigned long m_bodySize;
</span><span class="cx"> unsigned long m_bodyDataSent;
</span><span class="cx"> SoupSession* soupSession();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupGOwnPtrSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -42,4 +42,10 @@
</span><span class="cx"> soup_message_headers_free(ptr);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+template <> void freeOwnedGPtr<SoupBuffer>(SoupBuffer* ptr)
+{
+ if (ptr)
+ soup_buffer_free(ptr);
</ins><span class="cx"> }
</span><ins>+
+} // namespace WTF
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupGOwnPtrSouph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -20,17 +20,17 @@
</span><span class="cx"> #ifndef GOwnPtrSoup_h
</span><span class="cx"> #define GOwnPtrSoup_h
</span><span class="cx">
</span><ins>+// We need to include libsoup headers here because the way that SoupBuffer
+// is defined is not compatible with forward declaration.
+#include <libsoup/soup.h>
</ins><span class="cx"> #include <wtf/gobject/GOwnPtr.h>
</span><span class="cx">
</span><del>-typedef struct _SoupURI SoupURI;
-typedef struct _SoupCookie SoupCookie;
-typedef struct SoupMessageHeaders SoupMessageHeaders;
-
</del><span class="cx"> namespace WTF {
</span><span class="cx">
</span><span class="cx"> template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr);
</span><span class="cx"> template<> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr);
</span><span class="cx"> template<> void freeOwnedGPtr<SoupMessageHeaders>(SoupMessageHeaders*);
</span><ins>+template<> void freeOwnedGPtr<SoupBuffer>(SoupBuffer*);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupResourceHandleSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool loadingSynchronousRequest = false;
</span><del>-static const size_t defaultReadBufferSize = 8192;
</del><ins>+static const size_t gDefaultReadBufferSize = 8192;
</ins><span class="cx">
</span><span class="cx"> class WebCoreSynchronousLoader : public ResourceHandleClient {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(WebCoreSynchronousLoader);
</span><span class="lines">@@ -146,9 +146,20 @@
</span><span class="cx">
</span><span class="cx"> virtual void didReceiveData(ResourceHandle*, const char* data, int length, int)
</span><span class="cx"> {
</span><del>- m_data.append(data, length);
</del><ins>+ ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int /* encodedLength */)
+ {
+ // This pattern is suggested by SharedBuffer.h.
+ const char* segment;
+ unsigned position = 0;
+ while (unsigned length = buffer->getSomeData(segment, position)) {
+ m_data.append(segment, length);
+ position += length;
+ }
+ }
+
</ins><span class="cx"> virtual void didFinishLoading(ResourceHandle*, double)
</span><span class="cx"> {
</span><span class="cx"> if (g_main_loop_is_running(m_mainLoop.get()))
</span><span class="lines">@@ -301,21 +312,20 @@
</span><span class="cx"> {
</span><span class="cx"> ResourceHandleInternal* d = getInternal();
</span><span class="cx">
</span><ins>+ if (d->m_soupBuffer)
+ return;
+
+ // Non-NetworkProcess clients are able to give a buffer to the ResourceHandle to avoid expensive copies. If
+ // we do get a buffer from the client, we want the client to free it, so we create the soup buffer with
+ // SOUP_MEMORY_TEMPORARY.
</ins><span class="cx"> size_t bufferSize;
</span><del>- char* bufferPtr = client()->getOrCreateReadBuffer(defaultReadBufferSize, bufferSize);
- if (bufferPtr) {
- d->m_defaultReadBuffer.clear();
- d->m_readBufferPtr = bufferPtr;
- d->m_readBufferSize = bufferSize;
- } else if (!d->m_defaultReadBuffer) {
- d->m_defaultReadBuffer.set(static_cast<char*>(g_malloc(defaultReadBufferSize)));
- d->m_readBufferPtr = d->m_defaultReadBuffer.get();
- d->m_readBufferSize = defaultReadBufferSize;
- } else
- d->m_readBufferPtr = d->m_defaultReadBuffer.get();
</del><ins>+ char* bufferFromClient = client()->getOrCreateReadBuffer(gDefaultReadBufferSize, bufferSize);
+ if (bufferFromClient)
+ d->m_soupBuffer.set(soup_buffer_new(SOUP_MEMORY_TEMPORARY, bufferFromClient, bufferSize));
+ else
+ d->m_soupBuffer.set(soup_buffer_new(SOUP_MEMORY_TAKE, static_cast<char*>(g_malloc(gDefaultReadBufferSize)), gDefaultReadBufferSize));
</ins><span class="cx">
</span><del>- ASSERT(d->m_readBufferPtr);
- ASSERT(d->m_readBufferSize);
</del><ins>+ ASSERT(d->m_soupBuffer);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isAuthenticationFailureStatusCode(int httpStatusCode)
</span><span class="lines">@@ -524,7 +534,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (bytesSkipped > 0) {
</span><del>- g_input_stream_skip_async(d->m_inputStream.get(), defaultReadBufferSize, G_PRIORITY_DEFAULT,
</del><ins>+ g_input_stream_skip_async(d->m_inputStream.get(), gDefaultReadBufferSize, G_PRIORITY_DEFAULT,
</ins><span class="cx"> d->m_cancellable.get(), redirectSkipCallback, handle.get());
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -557,6 +567,7 @@
</span><span class="cx"> d->m_inputStream.clear();
</span><span class="cx"> d->m_multipartInputStream.clear();
</span><span class="cx"> d->m_cancellable.clear();
</span><ins>+ d->m_soupBuffer.clear();
</ins><span class="cx">
</span><span class="cx"> if (d->m_soupMessage) {
</span><span class="cx"> g_signal_handlers_disconnect_matched(d->m_soupMessage.get(), G_SIGNAL_MATCH_DATA,
</span><span class="lines">@@ -565,11 +576,6 @@
</span><span class="cx"> d->m_soupMessage.clear();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (d->m_readBufferPtr)
- d->m_readBufferPtr = 0;
- if (!d->m_defaultReadBuffer)
- d->m_readBufferSize = 0;
-
</del><span class="cx"> if (d->m_timeoutSource) {
</span><span class="cx"> g_source_destroy(d->m_timeoutSource.get());
</span><span class="cx"> d->m_timeoutSource.clear();
</span><span class="lines">@@ -639,7 +645,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> handle->ensureReadBuffer();
</span><del>- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
</del><ins>+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length,
</ins><span class="cx"> G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -669,12 +675,10 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- ASSERT(!d->m_readBufferPtr);
-
</del><span class="cx"> if (soupMessage) {
</span><span class="cx"> if (SOUP_STATUS_IS_REDIRECTION(soupMessage->status_code) && shouldRedirect(handle.get())) {
</span><span class="cx"> d->m_inputStream = inputStream;
</span><del>- g_input_stream_skip_async(d->m_inputStream.get(), defaultReadBufferSize, G_PRIORITY_DEFAULT,
</del><ins>+ g_input_stream_skip_async(d->m_inputStream.get(), gDefaultReadBufferSize, G_PRIORITY_DEFAULT,
</ins><span class="cx"> d->m_cancellable.get(), redirectSkipCallback, handle.get());
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -715,7 +719,7 @@
</span><span class="cx"> d->m_inputStream = inputStream;
</span><span class="cx">
</span><span class="cx"> handle->ensureReadBuffer();
</span><del>- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
</del><ins>+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length,
</ins><span class="cx"> G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1332,16 +1336,20 @@
</span><span class="cx"> // It's mandatory to have sent a response before sending data
</span><span class="cx"> ASSERT(!d->m_response.isNull());
</span><span class="cx">
</span><del>- handle->client()->didReceiveData(handle.get(), d->m_readBufferPtr, bytesRead, bytesRead);
</del><ins>+ // FIXME: We should send the encoded data size here and not the decoded size
+ // See https://bugs.webkit.org/show_bug.cgi?id=125410
+ ASSERT(d->m_soupBuffer);
+ d->m_soupBuffer->length = bytesRead; // The buffer might be larger than the number of bytes read. SharedBuffer looks at the length property.
+ handle->client()->didReceiveBuffer(handle.get(), SharedBuffer::wrapSoupBuffer(d->m_soupBuffer.release()), bytesRead);
</ins><span class="cx">
</span><del>- // didReceiveData may cancel the load, which may release the last reference.
</del><ins>+ // didReceiveBuffer may cancel the load, which may release the last reference.
</ins><span class="cx"> if (handle->cancelledOrClientless()) {
</span><span class="cx"> cleanupSoupRequestOperation(handle.get());
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> handle->ensureReadBuffer();
</span><del>- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize, G_PRIORITY_DEFAULT,
</del><ins>+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length, G_PRIORITY_DEFAULT,
</ins><span class="cx"> d->m_cancellable.get(), readCallback, handle.get());
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformsoupSharedBufferSoupcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp (0 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+/*
+ * Copyright (C) 2013 Company 100 Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "SharedBuffer.h"
+
+#include "PurgeableBuffer.h"
+#include <libsoup/soup.h>
+
+namespace WebCore {
+
+SharedBuffer::SharedBuffer(SoupBuffer* soupBuffer)
+ : m_size(0)
+{
+ ASSERT(soupBuffer);
+ m_soupBuffer.set(soupBuffer);
+}
+
+PassRefPtr<SharedBuffer> SharedBuffer::wrapSoupBuffer(SoupBuffer* soupBuffer)
+{
+ return adoptRef(new SharedBuffer(soupBuffer));
+}
+
+void SharedBuffer::clearPlatformData()
+{
+ m_soupBuffer.clear();
+}
+
+void SharedBuffer::tryReplaceContentsWithPlatformBuffer(SharedBuffer* newContents)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void SharedBuffer::maybeTransferPlatformData()
+{
+ if (!m_soupBuffer)
+ return;
+
+ ASSERT(!m_size);
+
+ // Hang on to the m_soupBuffer pointer in a local pointer as append() will re-enter maybeTransferPlatformData()
+ // and we need to make sure to early return when it does.
+ GOwnPtr<SoupBuffer> soupBuffer;
+ soupBuffer.swap(m_soupBuffer);
+
+ append(soupBuffer->data, soupBuffer->length);
+}
+
+bool SharedBuffer::hasPlatformData() const
+{
+ return m_soupBuffer;
+}
+
+const char* SharedBuffer::platformData() const
+{
+ return m_soupBuffer->data;
+}
+
+unsigned SharedBuffer::platformDataSize() const
+{
+ return m_soupBuffer->length;
+}
+
+} // namespace WebCore
</ins><span class="cx">Property changes on: trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/ChangeLog (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/ChangeLog        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebKit/gtk/ChangeLog        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2013-12-08 Martin Robinson <mrobinson@igalia.com>
+
+ [WK2][Soup] Use didReceiveBuffer instead of didReceiveData
+ https://bugs.webkit.org/show_bug.cgi?id=118598
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Original patch by Kwang Yul Seo <skyul@company100.net> and Csaba Osztrogonác <ossy@webkit.org>.
+
+ Switch from using didReceiveData to didReceiveBuffer for the Soup backend and
+ let SharedBuffer wrap a SoupBuffer. This is necessary because the NetworkProcess
+ only supports getting data via SharedBuffer.
+
+ * webkit/webkitdownload.cpp:
+ (DownloadClient::didReceiveData): Replace with ASSERT_NOT_REACHED.
+ (DownloadClient::didReceiveBuffer): Use this to process incoming data.
+
</ins><span class="cx"> 2013-12-07 Gustavo Noronha Silva <gns@gnome.org>
</span><span class="cx">
</span><span class="cx"> Fix API test expectation following 160220.
</span></span></pre></div>
<a id="trunkSourceWebKitgtkwebkitwebkitdownloadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp (160309 => 160310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp        2013-12-09 12:42:54 UTC (rev 160309)
+++ trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp        2013-12-09 14:10:18 UTC (rev 160310)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include "ResourceHandleInternal.h"
</span><span class="cx"> #include "ResourceRequest.h"
</span><span class="cx"> #include "ResourceResponse.h"
</span><ins>+#include "SharedBuffer.h"
</ins><span class="cx"> #include "webkitdownloadprivate.h"
</span><span class="cx"> #include "webkitenumtypes.h"
</span><span class="cx"> #include "webkitglobals.h"
</span><span class="lines">@@ -61,18 +62,20 @@
</span><span class="cx">
</span><span class="cx"> class DownloadClient : public ResourceHandleClient {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(DownloadClient);
</span><del>- public:
- DownloadClient(WebKitDownload*);
</del><span class="cx">
</span><del>- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
- virtual void didReceiveData(ResourceHandle*, const char*, int, int);
- virtual void didFinishLoading(ResourceHandle*, double);
- virtual void didFail(ResourceHandle*, const ResourceError&);
- virtual void wasBlocked(ResourceHandle*);
- virtual void cannotShowURL(ResourceHandle*);
</del><ins>+public:
+ DownloadClient(WebKitDownload*);
</ins><span class="cx">
</span><del>- private:
- WebKitDownload* m_download;
</del><ins>+ virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
+ virtual void didReceiveData(ResourceHandle*, const char*, int, int);
+ virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int encodedLength);
+ virtual void didFinishLoading(ResourceHandle*, double);
+ virtual void didFail(ResourceHandle*, const ResourceError&);
+ virtual void wasBlocked(ResourceHandle*);
+ virtual void cannotShowURL(ResourceHandle*);
+
+private:
+ WebKitDownload* m_download;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct _WebKitDownloadPrivate {
</span><span class="lines">@@ -940,9 +943,20 @@
</span><span class="cx">
</span><span class="cx"> void DownloadClient::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
</span><span class="cx"> {
</span><del>- webkit_download_received_data(m_download, data, length);
</del><ins>+ ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void DownloadClient::didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer> buffer, int encodedLength)
+{
+ // This pattern is suggested by SharedBuffer.h.
+ const char* segment;
+ unsigned position = 0;
+ while (unsigned length = buffer->getSomeData(segment, position)) {
+ webkit_download_received_data(m_download, segment, length);
+ position += length;
+ }
+}
+
</ins><span class="cx"> void DownloadClient::didFinishLoading(ResourceHandle*, double)
</span><span class="cx"> {
</span><span class="cx"> webkit_download_finished_loading(m_download);
</span></span></pre>
</div>
</div>
</body>
</html>