Update ResourceHandleCF to use the didReceiveBuffer() callback
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 22:06:39 +0000 (22:06 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 22:06:39 +0000 (22:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124256

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-11-13
Reviewed by Alexey Proskuryakov.

Use didReceiveBuffer() instead of didReceiveData() to pass data back to
the ResourceHandleClient. This unify the update code with the NSURLConnection loader.

* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::didReceiveData):
(WebCore::ResourceHandle::handleDataArray):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159235 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

index 3a3c6de..fea2f7a 100644 (file)
@@ -1,3 +1,17 @@
+2013-11-13  Benjamin Poulain  <bpoulain@apple.com>
+
+        Update ResourceHandleCF to use the didReceiveBuffer() callback
+        https://bugs.webkit.org/show_bug.cgi?id=124256
+
+        Reviewed by Alexey Proskuryakov.
+
+        Use didReceiveBuffer() instead of didReceiveData() to pass data back to
+        the ResourceHandleClient. This unify the update code with the NSURLConnection loader.
+
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::didReceiveData):
+        (WebCore::ResourceHandle::handleDataArray):
+
 2013-11-13  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Split Inspector.json into individual domain json files
index 2e44a9e..fb84d81 100644 (file)
@@ -214,17 +214,17 @@ static void didReceiveDataArray(CFURLConnectionRef conn, CFArrayRef dataArray, c
 
 static void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo)
 {
+    ResourceHandle* handle = static_cast<ResourceHandle*>(const_cast<void*>(clientInfo));
+
 #if LOG_DISABLED
     UNUSED_PARAM(conn);
-#endif
-    ResourceHandle* handle = static_cast<ResourceHandle*>(const_cast<void*>(clientInfo));
-    const UInt8* bytes = CFDataGetBytePtr(data);
+#else
     CFIndex length = CFDataGetLength(data);
-
     LOG(Network, "CFNet - didReceiveData(conn=%p, handle=%p, bytes=%ld) (%s)", conn, handle, length, handle->firstRequest().url().string().utf8().data());
+#endif
 
-    if (handle->client())
-        handle->client()->didReceiveData(handle, (const char*)bytes, length, originalLength);
+    if (ResourceHandleClient* client = handle->client())
+        client->didReceiveBuffer(handle, SharedBuffer::wrapCFData(data), originalLength);
 }
 
 static void didSendBodyData(CFURLConnectionRef, CFIndex, CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite, const void *clientInfo)
@@ -784,8 +784,7 @@ void ResourceHandle::handleDataArray(CFArrayRef dataArray)
     ASSERT(count);
     if (count == 1) {
         CFDataRef data = static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, 0));
-        CFIndex length = CFDataGetLength(data);
-        client()->didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(data)), length, static_cast<int>(length));
+        client()->didReceiveBuffer(this, SharedBuffer::wrapCFData(data), -1);
         return;
     }
 
@@ -800,7 +799,7 @@ void ResourceHandle::handleDataArray(CFArrayRef dataArray)
         CFDataAppendBytes(mergedData.get(), CFDataGetBytePtr(data), CFDataGetLength(data));
     }
 
-    client()->didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(mergedData.get())), totalSize, static_cast<int>(totalSize));
+    client()->didReceiveBuffer(this, SharedBuffer::wrapCFData(mergedData.get()), -1);
 }
 #endif