2008-11-20 Adele Peterson <adele@apple.com>
authoradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Nov 2008 01:54:55 +0000 (01:54 +0000)
committeradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Nov 2008 01:54:55 +0000 (01:54 +0000)
        Reviewed by Darin Adler.

        Fix for <rdar://problem/6111436> Support upload progress events on Windows

        * platform/network/cf/ResourceHandleCFNet.cpp:
        (WebCore::didSendBodyData): Added.
        (WebCore::ResourceHandle::start): Hook up didSendBodyData callback.

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

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

index 8cdca77..f29effa 100644 (file)
@@ -1,3 +1,13 @@
+2008-11-20  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Darin Adler. 
+
+        Fix for <rdar://problem/6111436> Support upload progress events on Windows
+
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::didSendBodyData): Added.
+        (WebCore::ResourceHandle::start): Hook up didSendBodyData callback.
+
 2008-11-20  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Darin Adler.
index fa7947f..6f7b43b 100644 (file)
@@ -109,6 +109,16 @@ void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLen
         handle->client()->didReceiveData(handle, (const char*)bytes, length, originalLength);
 }
 
+#ifdef _CFURLConnectionClientV2Present
+static void didSendBodyData(CFURLConnectionRef conn, CFIndex bytesWritten, CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite, const void *clientInfo)
+{
+    ResourceHandle* handle = (ResourceHandle*)clientInfo;
+    if (!handle || !handle->client())
+        return;
+    handle->client()->didSendData(handle, totalBytesWritten, totalBytesExpectedToWrite);
+}
+#endif
+
 void didFinishLoading(CFURLConnectionRef conn, const void* clientInfo) 
 {
     ResourceHandle* handle = (ResourceHandle*)clientInfo;
@@ -279,11 +289,17 @@ bool ResourceHandle::start(Frame* frame)
 
     RetainPtr<CFURLRequestRef> request(AdoptCF, makeFinalRequest(d->m_request, d->m_shouldContentSniff));
 
-    // CFURLConnection Callback API currently at version 1
-    const int CFURLConnectionClientVersion = 1;
-    CFURLConnectionClient client = {CFURLConnectionClientVersion, this, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge};
-
-    d->m_connection.adoptCF(CFURLConnectionCreate(0, request.get(), &client));
+    CFURLConnectionClient* client;
+#ifdef _CFURLConnectionClientV2Present
+    // CFURLConnection Callback API currently at version 2
+    CFURLConnectionClient_V2 client_V2 = {2, this, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData};
+    client = reinterpret_cast<CFURLConnectionClient*>(&client_V2);
+#else
+    CFURLConnectionClient client_V1 = {1, this, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge};
+    client = &client_V1;
+#endif
+
+    d->m_connection.adoptCF(CFURLConnectionCreate(0, request.get(), client));
 
     CFURLConnectionScheduleWithCurrentMessageQueue(d->m_connection.get());
     CFURLConnectionScheduleDownloadWithRunLoop(d->m_connection.get(), loaderRunLoop(), kCFRunLoopDefaultMode);