Title: [160352] trunk/Source/WebCore
Revision
160352
Author
g...@gnome.org
Date
2013-12-10 02:07:31 -0800 (Tue, 10 Dec 2013)

Log Message

[Soup] Send original encoded data size to didReceiveBuffer
https://bugs.webkit.org/show_bug.cgi?id=125410

Reviewed by Martin Robinson.

No tests, the only way to test this seems to be through the inspector UI.

* platform/network/ResourceHandle.h:
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal): data member to track stream
position.
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::ResourceHandle::currentStreamPosition): obtains the current stream position by querying
the first seekable input stream we find.
(WebCore::nextMultipartResponsePartCallback): store the position before we start reading a new part.
(WebCore::sendRequestCallback): store the position before we start reading the response body.
(WebCore::readCallback): pass the position delta to didReceiveData.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160351 => 160352)


--- trunk/Source/WebCore/ChangeLog	2013-12-10 07:19:00 UTC (rev 160351)
+++ trunk/Source/WebCore/ChangeLog	2013-12-10 10:07:31 UTC (rev 160352)
@@ -1,3 +1,23 @@
+2013-12-09  Gustavo Noronha Silva  <g...@gnome.org>
+
+        [Soup] Send original encoded data size to didReceiveBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=125410
+
+        Reviewed by Martin Robinson.
+
+        No tests, the only way to test this seems to be through the inspector UI.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleInternal.h:
+        (WebCore::ResourceHandleInternal::ResourceHandleInternal): data member to track stream
+        position.
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::ResourceHandle::currentStreamPosition): obtains the current stream position by querying
+        the first seekable input stream we find.
+        (WebCore::nextMultipartResponsePartCallback): store the position before we start reading a new part.
+        (WebCore::sendRequestCallback): store the position before we start reading the response body.
+        (WebCore::readCallback): pass the position delta to didReceiveData.
+
 2013-12-09  Andreas Kling  <akl...@apple.com>
 
         Clear out font width measurement caches on memory pressure.

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (160351 => 160352)


--- trunk/Source/WebCore/platform/network/ResourceHandle.h	2013-12-10 07:19:00 UTC (rev 160351)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h	2013-12-10 10:07:31 UTC (rev 160352)
@@ -178,6 +178,7 @@
     void sendPendingRequest();
     bool cancelledOrClientless();
     void ensureReadBuffer();
+    size_t currentStreamPosition() const;
     static SoupSession* defaultSession();
     static SoupSession* createTestingSession();
     static SoupSession* createPrivateBrowsingSession();

Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (160351 => 160352)


--- trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2013-12-10 07:19:00 UTC (rev 160351)
+++ trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2013-12-10 10:07:31 UTC (rev 160352)
@@ -110,6 +110,7 @@
             , m_bodySize(0)
             , m_bodyDataSent(0)
             , m_redirectCount(0)
+            , m_previousPosition(0)
 #endif
 #if PLATFORM(MAC)
             , m_startWhenScheduled(false)
@@ -201,6 +202,7 @@
         unsigned long m_bodyDataSent;
         SoupSession* soupSession();
         int m_redirectCount;
+        size_t m_previousPosition;
 #endif
 #if PLATFORM(GTK)
         struct {

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (160351 => 160352)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-10 07:19:00 UTC (rev 160351)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-10 10:07:31 UTC (rev 160352)
@@ -4,7 +4,7 @@
  * Copyright (C) 2008 Xan Lopez <x...@gnome.org>
  * Copyright (C) 2008, 2010 Collabora Ltd.
  * Copyright (C) 2009 Holger Hans Peter Freyther
- * Copyright (C) 2009 Gustavo Noronha Silva <g...@gnome.org>
+ * Copyright (C) 2009, 2013 Gustavo Noronha Silva <g...@gnome.org>
  * Copyright (C) 2009 Christian Dywan <christ...@imendio.com>
  * Copyright (C) 2009, 2010, 2011, 2012 Igalia S.L.
  * Copyright (C) 2009 John Kjellberg <john.kjellb...@power.alstom.com>
@@ -606,6 +606,18 @@
     return true;
 }
 
+size_t ResourceHandle::currentStreamPosition() const
+{
+    GInputStream* baseStream = d->m_inputStream.get();
+    while (!G_IS_SEEKABLE(baseStream) && G_IS_FILTER_INPUT_STREAM(baseStream))
+        baseStream = g_filter_input_stream_get_base_stream(G_FILTER_INPUT_STREAM(baseStream));
+
+    if (!G_IS_SEEKABLE(baseStream))
+        return 0;
+
+    return g_seekable_tell(G_SEEKABLE(baseStream));
+}
+
 static void nextMultipartResponsePartCallback(GObject* /*source*/, GAsyncResult* result, gpointer data)
 {
     RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
@@ -644,6 +656,8 @@
         return;
     }
 
+    d->m_previousPosition = 0;
+
     handle->ensureReadBuffer();
     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());
@@ -1336,12 +1350,15 @@
     // It's mandatory to have sent a response before sending data
     ASSERT(!d->m_response.isNull());
 
-    // FIXME: We should send the encoded data size here and not the decoded size
-    // See https://bugs.webkit.org/show_bug.cgi?id=125410
+    size_t currentPosition = handle->currentStreamPosition();
+    size_t encodedDataLength = currentPosition ? currentPosition - d->m_previousPosition : bytesRead;
+
     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);
+    handle->client()->didReceiveBuffer(handle.get(), SharedBuffer::wrapSoupBuffer(d->m_soupBuffer.release()), encodedDataLength);
 
+    d->m_previousPosition = currentPosition;
+
     // didReceiveBuffer may cancel the load, which may release the last reference.
     if (handle->cancelledOrClientless()) {
         cleanupSoupRequestOperation(handle.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to