Diff
Modified: trunk/Source/WebCore/ChangeLog (160309 => 160310)
--- 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)
@@ -1,3 +1,38 @@
+2013-12-08 Martin Robinson <[email protected]>
+
+ [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 <[email protected]> and Csaba Osztrogonác <[email protected]>.
+
+ 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.
+
2013-12-09 Michal Poteralski <[email protected]>
DataCloneError exception is not thrown when postMessage's second parameter is the source
Modified: trunk/Source/WebCore/GNUmakefile.list.am (160309 => 160310)
--- 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)
@@ -5939,6 +5939,7 @@
Source/WebCore/platform/network/SocketStreamHandleBase.cpp \
Source/WebCore/platform/network/SocketStreamHandleBase.h \
Source/WebCore/platform/network/SocketStreamHandleClient.h \
+ Source/WebCore/platform/soup/SharedBufferSoup.cpp \
Source/WebCore/platform/text/enchant/TextCheckerEnchant.h \
Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp \
Source/WebCore/platform/text/BidiContext.cpp \
Modified: trunk/Source/WebCore/PlatformEfl.cmake (160309 => 160310)
--- 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)
@@ -171,6 +171,8 @@
platform/posix/FileSystemPOSIX.cpp
platform/posix/SharedBufferPOSIX.cpp
+ platform/soup/SharedBufferSoup.cpp
+
platform/text/LocaleICU.cpp
platform/text/efl/TextBreakIteratorInternalICUEfl.cpp
Modified: trunk/Source/WebCore/PlatformGTK.cmake (160309 => 160310)
--- 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)
@@ -203,6 +203,8 @@
platform/network/soup/SoupURIUtils.cpp
platform/network/soup/SynchronousLoaderClientSoup.cpp
+ platform/soup/SharedBufferSoup.cpp
+
platform/text/LocaleICU.cpp
platform/text/TextBreakIteratorICU.cpp
platform/text/TextCodecICU.cpp
Modified: trunk/Source/WebCore/PlatformNix.cmake (160309 => 160310)
--- 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)
@@ -79,6 +79,8 @@
platform/gtk/LoggingGtk.cpp
platform/gtk/SharedBufferGtk.cpp
+ platform/soup/SharedBuferSoup.cpp
+
platform/image-decoders/cairo/ImageDecoderCairo.cpp
platform/linux/GamepadDeviceLinux.cpp
Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (160309 => 160310)
--- 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)
@@ -231,7 +231,7 @@
return;
#endif
- char* destination;
+ char* destination = 0;
m_purgeableBuffer = PurgeableBuffer::createUninitialized(m_size, destination);
if (!m_purgeableBuffer)
return;
@@ -454,7 +454,7 @@
#endif
}
-#if !USE(CF)
+#if !USE(CF) && !USE(SOUP)
inline void SharedBuffer::clearPlatformData()
{
Modified: trunk/Source/WebCore/platform/SharedBuffer.h (160309 => 160310)
--- 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)
@@ -37,6 +37,10 @@
#include <wtf/RetainPtr.h>
#endif
+#if USE(SOUP)
+#include "GOwnPtrSoup.h"
+#endif
+
#if PLATFORM(MAC)
OBJC_CLASS NSData;
#endif
@@ -87,6 +91,10 @@
static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef);
#endif
+#if USE(SOUP)
+ static PassRefPtr<SharedBuffer> wrapSoupBuffer(SoupBuffer*);
+#endif
+
// Calling this function will force internal segmented buffers
// to be merged into a flat buffer. Use getSomeData() whenever possible
// for better performance.
@@ -197,6 +205,11 @@
explicit SharedBuffer(CFDataRef);
RetainPtr<CFDataRef> m_cfData;
#endif
+
+#if USE(SOUP)
+ explicit SharedBuffer(SoupBuffer*);
+ GOwnPtr<SoupBuffer> m_soupBuffer;
+#endif
};
PassRefPtr<SharedBuffer> utf8Buffer(const String&);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (160309 => 160310)
--- 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)
@@ -35,6 +35,7 @@
#include "ResourceHandleClient.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
+#include "SharedBuffer.h"
#include <gst/app/gstappsrc.h>
#include <gst/gst.h>
#include <gst/pbutils/missing-plugins.h>
@@ -99,6 +100,7 @@
virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char*, int, int);
+ virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedLength);
virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
virtual void didFail(ResourceHandle*, const ResourceError&);
virtual void wasBlocked(ResourceHandle*);
@@ -1117,9 +1119,20 @@
void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* data, int length, int)
{
- handleDataReceived(data, length);
+ ASSERT_NOT_REACHED();
}
+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;
+ }
+}
+
void ResourceHandleStreamingClient::didFinishLoading(ResourceHandle*, double)
{
handleNotifyFinished();
Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (160309 => 160310)
--- 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)
@@ -106,8 +106,6 @@
#endif
#if USE(SOUP)
, m_cancelled(false)
- , m_readBufferPtr(0)
- , m_readBufferSize(0)
, m_bodySize(0)
, m_bodyDataSent(0)
, m_redirectCount(0)
@@ -196,9 +194,7 @@
GRefPtr<GCancellable> m_cancellable;
GRefPtr<GAsyncResult> m_deferredResult;
GRefPtr<GSource> m_timeoutSource;
- GOwnPtr<char> m_defaultReadBuffer;
- char* m_readBufferPtr;
- size_t m_readBufferSize;
+ GOwnPtr<SoupBuffer> m_soupBuffer;
unsigned long m_bodySize;
unsigned long m_bodyDataSent;
SoupSession* soupSession();
Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.cpp (160309 => 160310)
--- 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)
@@ -42,4 +42,10 @@
soup_message_headers_free(ptr);
}
+template <> void freeOwnedGPtr<SoupBuffer>(SoupBuffer* ptr)
+{
+ if (ptr)
+ soup_buffer_free(ptr);
}
+
+} // namespace WTF
Modified: trunk/Source/WebCore/platform/network/soup/GOwnPtrSoup.h (160309 => 160310)
--- 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)
@@ -20,17 +20,17 @@
#ifndef GOwnPtrSoup_h
#define GOwnPtrSoup_h
+// We need to include libsoup headers here because the way that SoupBuffer
+// is defined is not compatible with forward declaration.
+#include <libsoup/soup.h>
#include <wtf/gobject/GOwnPtr.h>
-typedef struct _SoupURI SoupURI;
-typedef struct _SoupCookie SoupCookie;
-typedef struct SoupMessageHeaders SoupMessageHeaders;
-
namespace WTF {
template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr);
template<> void freeOwnedGPtr<SoupCookie>(SoupCookie* ptr);
template<> void freeOwnedGPtr<SoupMessageHeaders>(SoupMessageHeaders*);
+template<> void freeOwnedGPtr<SoupBuffer>(SoupBuffer*);
}
Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (160309 => 160310)
--- 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)
@@ -82,7 +82,7 @@
}
static bool loadingSynchronousRequest = false;
-static const size_t defaultReadBufferSize = 8192;
+static const size_t gDefaultReadBufferSize = 8192;
class WebCoreSynchronousLoader : public ResourceHandleClient {
WTF_MAKE_NONCOPYABLE(WebCoreSynchronousLoader);
@@ -146,9 +146,20 @@
virtual void didReceiveData(ResourceHandle*, const char* data, int length, int)
{
- m_data.append(data, length);
+ ASSERT_NOT_REACHED();
}
+ 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;
+ }
+ }
+
virtual void didFinishLoading(ResourceHandle*, double)
{
if (g_main_loop_is_running(m_mainLoop.get()))
@@ -301,21 +312,20 @@
{
ResourceHandleInternal* d = getInternal();
+ 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.
size_t bufferSize;
- 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();
+ 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));
- ASSERT(d->m_readBufferPtr);
- ASSERT(d->m_readBufferSize);
+ ASSERT(d->m_soupBuffer);
}
static bool isAuthenticationFailureStatusCode(int httpStatusCode)
@@ -524,7 +534,7 @@
}
if (bytesSkipped > 0) {
- g_input_stream_skip_async(d->m_inputStream.get(), defaultReadBufferSize, G_PRIORITY_DEFAULT,
+ g_input_stream_skip_async(d->m_inputStream.get(), gDefaultReadBufferSize, G_PRIORITY_DEFAULT,
d->m_cancellable.get(), redirectSkipCallback, handle.get());
return;
}
@@ -557,6 +567,7 @@
d->m_inputStream.clear();
d->m_multipartInputStream.clear();
d->m_cancellable.clear();
+ d->m_soupBuffer.clear();
if (d->m_soupMessage) {
g_signal_handlers_disconnect_matched(d->m_soupMessage.get(), G_SIGNAL_MATCH_DATA,
@@ -565,11 +576,6 @@
d->m_soupMessage.clear();
}
- if (d->m_readBufferPtr)
- d->m_readBufferPtr = 0;
- if (!d->m_defaultReadBuffer)
- d->m_readBufferSize = 0;
-
if (d->m_timeoutSource) {
g_source_destroy(d->m_timeoutSource.get());
d->m_timeoutSource.clear();
@@ -639,7 +645,7 @@
}
handle->ensureReadBuffer();
- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length,
G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());
}
@@ -669,12 +675,10 @@
return;
}
- ASSERT(!d->m_readBufferPtr);
-
if (soupMessage) {
if (SOUP_STATUS_IS_REDIRECTION(soupMessage->status_code) && shouldRedirect(handle.get())) {
d->m_inputStream = inputStream;
- g_input_stream_skip_async(d->m_inputStream.get(), defaultReadBufferSize, G_PRIORITY_DEFAULT,
+ g_input_stream_skip_async(d->m_inputStream.get(), gDefaultReadBufferSize, G_PRIORITY_DEFAULT,
d->m_cancellable.get(), redirectSkipCallback, handle.get());
return;
}
@@ -715,7 +719,7 @@
d->m_inputStream = inputStream;
handle->ensureReadBuffer();
- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length,
G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());
}
@@ -1332,16 +1336,20 @@
// It's mandatory to have sent a response before sending data
ASSERT(!d->m_response.isNull());
- handle->client()->didReceiveData(handle.get(), d->m_readBufferPtr, bytesRead, bytesRead);
+ // 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);
- // didReceiveData may cancel the load, which may release the last reference.
+ // didReceiveBuffer may cancel the load, which may release the last reference.
if (handle->cancelledOrClientless()) {
cleanupSoupRequestOperation(handle.get());
return;
}
handle->ensureReadBuffer();
- g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize, G_PRIORITY_DEFAULT,
+ g_input_stream_read_async(d->m_inputStream.get(), const_cast<char*>(d->m_soupBuffer->data), d->m_soupBuffer->length, G_PRIORITY_DEFAULT,
d->m_cancellable.get(), readCallback, handle.get());
}
Added: trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp (0 => 160310)
--- 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)
@@ -0,0 +1,79 @@
+/*
+ * 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
Property changes on: trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebKit/gtk/ChangeLog (160309 => 160310)
--- 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)
@@ -1,3 +1,20 @@
+2013-12-08 Martin Robinson <[email protected]>
+
+ [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 <[email protected]> and Csaba Osztrogonác <[email protected]>.
+
+ 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.
+
2013-12-07 Gustavo Noronha Silva <[email protected]>
Fix API test expectation following 160220.
Modified: trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp (160309 => 160310)
--- 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)
@@ -27,6 +27,7 @@
#include "ResourceHandleInternal.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
+#include "SharedBuffer.h"
#include "webkitdownloadprivate.h"
#include "webkitenumtypes.h"
#include "webkitglobals.h"
@@ -61,18 +62,20 @@
class DownloadClient : public ResourceHandleClient {
WTF_MAKE_NONCOPYABLE(DownloadClient);
- public:
- DownloadClient(WebKitDownload*);
- 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*);
+public:
+ DownloadClient(WebKitDownload*);
- private:
- WebKitDownload* m_download;
+ 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;
};
struct _WebKitDownloadPrivate {
@@ -940,9 +943,20 @@
void DownloadClient::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
{
- webkit_download_received_data(m_download, data, length);
+ ASSERT_NOT_REACHED();
}
+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;
+ }
+}
+
void DownloadClient::didFinishLoading(ResourceHandle*, double)
{
webkit_download_finished_loading(m_download);