Source/WebCore/ChangeLog

 12013-12-08 Gustavo Noronha Silva <gns@gnome.org>
 2
 3 [Soup] Send original encoded data size to didReceiveBuffer
 4 https://bugs.webkit.org/show_bug.cgi?id=125410
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 No tests, the only way to test this seems to be through the inspector UI.
 9
 10 * platform/network/ResourceHandle.h:
 11 * platform/network/ResourceHandleInternal.h:
 12 (WebCore::ResourceHandleInternal::ResourceHandleInternal): data member to track stream
 13 position.
 14 * platform/network/soup/ResourceHandleSoup.cpp:
 15 (WebCore::ResourceHandle::currentStreamPosition): obtains the current stream position by querying
 16 the first seekable input stream we find.
 17 (WebCore::nextMultipartResponsePartCallback): store the position before we start reading a new part.
 18 (WebCore::sendRequestCallback): store the position before we start reading the response body.
 19 (WebCore::readCallback): pass the position delta to didReceiveData.
 20
1212013-12-07 ChangSeok Oh <changseok.oh@collabora.com>
222
323 Unreviewed. Build fix for gtk port after r160260.

Source/WebCore/platform/network/ResourceHandle.h

@@public:
180180 void sendPendingRequest();
181181 bool cancelledOrClientless();
182182 void ensureReadBuffer();
 183 size_t currentStreamPosition() const;
183184 static SoupSession* defaultSession();
184185 static SoupSession* createTestingSession();
185186 static SoupSession* createPrivateBrowsingSession();

Source/WebCore/platform/network/ResourceHandleInternal.h

@@namespace WebCore {
111111 , m_bodySize(0)
112112 , m_bodyDataSent(0)
113113 , m_redirectCount(0)
 114 , m_previousPosition(0)
114115#endif
115116#if PLATFORM(MAC)
116117 , m_startWhenScheduled(false)

@@namespace WebCore {
203204 unsigned long m_bodyDataSent;
204205 SoupSession* soupSession();
205206 int m_redirectCount;
 207 size_t m_previousPosition;
206208#endif
207209#if PLATFORM(GTK)
208210 struct {

Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

@@static bool handleUnignoredTLSErrors(ResourceHandle* handle)
600600 return true;
601601}
602602
 603size_t ResourceHandle::currentStreamPosition() const
 604{
 605 GInputStream* baseStream = d->m_inputStream.get();
 606 while (!G_IS_SEEKABLE(baseStream))
 607 baseStream = g_filter_input_stream_get_base_stream(G_FILTER_INPUT_STREAM(baseStream));
 608 return g_seekable_tell(G_SEEKABLE(baseStream));
 609}
 610
603611static void nextMultipartResponsePartCallback(GObject* /*source*/, GAsyncResult* result, gpointer data)
604612{
605613 RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);

@@static void nextMultipartResponsePartCallback(GObject* /*source*/, GAsyncResult*
638646 return;
639647 }
640648
 649 d->m_previousPosition = handle->currentStreamPosition();
 650
641651 handle->ensureReadBuffer();
642652 g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
643653 G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());

@@static void sendRequestCallback(GObject*, GAsyncResult* result, gpointer data)
714724
715725 d->m_inputStream = inputStream;
716726
 727 d->m_previousPosition = handle->currentStreamPosition();
 728
717729 handle->ensureReadBuffer();
718730 g_input_stream_read_async(d->m_inputStream.get(), d->m_readBufferPtr, d->m_readBufferSize,
719731 G_PRIORITY_DEFAULT, d->m_cancellable.get(), readCallback, handle.get());

@@static void readCallback(GObject*, GAsyncResult* asyncResult, gpointer data)
13321344 // It's mandatory to have sent a response before sending data
13331345 ASSERT(!d->m_response.isNull());
13341346
1335  handle->client()->didReceiveData(handle.get(), d->m_readBufferPtr, bytesRead, bytesRead);
 1347 size_t currentPosition = handle->currentStreamPosition();
 1348
 1349 handle->client()->didReceiveData(handle.get(), d->m_readBufferPtr, bytesRead, currentPosition - d->m_previousPosition);
 1350
 1351 d->m_previousPosition = currentPosition;
13361352
13371353 // didReceiveData may cancel the load, which may release the last reference.
13381354 if (handle->cancelledOrClientless()) {