Changeset 90834 in webkit
- Timestamp:
- Jul 12, 2011 11:47:18 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90833 r90834 1 2011-07-12 Pratik Solanki <psolanki@apple.com> 2 3 Implement didReceiveDataArray callback for CFNetwork based loader 4 https://bugs.webkit.org/show_bug.cgi?id=64130 5 6 Reviewed by David Kilzer. 7 8 Factor out the didReceiveDataArray code from ResourceHandleMac.mm into 9 a new method ResourceHandle::handleDataArray(). Implement the callback 10 in the CFNetwork loader code and call handleDataArray() to process 11 incoming data. 12 13 No new tests because the flag is not enabled for any bots. 14 15 * platform/network/ResourceHandle.h: 16 * platform/network/cf/ResourceHandleCFNet.cpp: 17 (WebCore::didReceiveDataArray): 18 (WebCore::ResourceHandle::createCFURLConnection): 19 (WebCore::ResourceHandle::handleDataArray): 20 * platform/network/mac/ResourceHandleMac.mm: 21 (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]): 22 1 23 2011-07-12 Emil A Eklund <eae@chromium.org> 2 24 -
trunk/Source/WebCore/platform/network/ResourceHandle.h
r88398 r90834 212 212 #endif 213 213 214 #if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) 215 void handleDataArray(CFArrayRef dataArray); 216 #endif 217 214 218 protected: 215 219 ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff); -
trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
r88123 r90834 26 26 #include "config.h" 27 27 28 #if USE(CFNETWORK)29 30 28 #include "ResourceHandleInternal.h" 31 29 … … 47 45 #include "SharedBuffer.h" 48 46 #include <CFNetwork/CFNetwork.h> 49 #include <WebKitSystemInterface/WebKitSystemInterface.h>50 #include <process.h> // for _beginthread()51 47 #include <sys/stat.h> 52 48 #include <sys/types.h> … … 54 50 #include <wtf/Threading.h> 55 51 #include <wtf/text/CString.h> 52 53 #if PLATFORM(MAC) && USE(CFNETWORK) 54 #include "WebCoreSystemInterface.h" 55 #include "WebCoreURLResponse.h" 56 #include <CFNetwork/CFURLConnectionPriv.h> 57 #endif 58 59 #if PLATFORM(WIN) 60 #include <WebKitSystemInterface/WebKitSystemInterface.h> 61 #include <process.h> 56 62 57 63 // FIXME: Remove this declaration once it's in WebKitSupportLibrary. … … 63 69 CFDictionaryRef properties); 64 70 } 71 #endif 65 72 66 73 namespace WebCore { 74 75 #if USE(CFNETWORK) 67 76 68 77 class WebCoreSynchronousLoaderClient : public ResourceHandleClient { … … 205 214 handle->client()->didReceiveResponse(handle, cfResponse); 206 215 } 216 217 #if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) 218 static void didReceiveDataArray(CFURLConnectionRef conn, CFArrayRef dataArray, const void* clientInfo) 219 { 220 #if LOG_DISABLED 221 UNUSED_PARAM(conn); 222 #endif 223 ResourceHandle* handle = static_cast<ResourceHandle*>(const_cast<void*>(clientInfo)); 224 if (!handle->client()) 225 return; 226 227 LOG(Network, "CFNet - didReceiveDataArray(conn=%p, handle=%p, arrayLength=%ld) (%s)", conn, handle, CFArrayGetCount(dataArray), handle->firstRequest().url().string().utf8().data()); 228 229 handle->handleDataArray(dataArray); 230 } 231 #endif 207 232 208 233 static void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo) … … 421 446 RetainPtr<CFURLRequestRef> request(AdoptCF, makeFinalRequest(firstRequest(), shouldContentSniff)); 422 447 448 #if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) 449 CFURLConnectionClient_V6 client = { 6, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0, 0, 0, didReceiveDataArray}; 450 #else 423 451 CFURLConnectionClient_V3 client = { 3, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0}; 452 #endif 424 453 RetainPtr<CFDictionaryRef> connectionProperties(AdoptCF, createConnectionProperties(shouldUseCredentialStorage)); 425 454 … … 839 868 } 840 869 870 #endif // USE(CFNETWORK) 871 872 #if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) 873 void ResourceHandle::handleDataArray(CFArrayRef dataArray) 874 { 875 ASSERT(client()); 876 if (client()->supportsDataArray()) { 877 client()->didReceiveDataArray(this, dataArray); 878 return; 879 } 880 881 CFIndex count = CFArrayGetCount(dataArray); 882 ASSERT(count); 883 if (count == 1) { 884 CFDataRef data = static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, 0)); 885 CFIndex length = CFDataGetLength(data); 886 client()->didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(data)), length, static_cast<int>(length)); 887 return; 888 } 889 890 CFIndex totalSize = 0; 891 CFIndex index; 892 for (index = 0; index < count; index++) 893 totalSize += CFDataGetLength(static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, index))); 894 895 RetainPtr<CFMutableDataRef> mergedData(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, totalSize)); 896 for (index = 0; index < count; index++) { 897 CFDataRef data = static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, index)); 898 CFDataAppendBytes(mergedData.get(), CFDataGetBytePtr(data), CFDataGetLength(data)); 899 } 900 901 client()->didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(mergedData.get())), totalSize, static_cast<int>(totalSize)); 902 } 903 #endif 904 841 905 } // namespace WebCore 842 906 843 #endif // USE(CFNETWORK) -
trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm
r90400 r90834 809 809 return; 810 810 811 if (m_handle->client()->supportsDataArray()) 812 m_handle->client()->didReceiveDataArray(m_handle, reinterpret_cast<CFArrayRef>(dataArray)); 813 else { 814 NSUInteger count = [dataArray count]; 815 ASSERT(count); 816 if (count == 1) { 817 NSData *data = [dataArray objectAtIndex:0]; 818 m_handle->client()->didReceiveData(m_handle, static_cast<const char*>([data bytes]), [data length], static_cast<int>([data length])); 819 } else { 820 NSUInteger totalSize = 0; 821 for (NSData *data in dataArray) 822 totalSize += [data length]; 823 824 RetainPtr<NSMutableData> mergedData(AdoptNS, [[NSMutableData alloc] initWithCapacity:totalSize]); 825 for (NSData *data in dataArray) 826 [mergedData.get() appendData:data]; 827 828 m_handle->client()->didReceiveData(m_handle, static_cast<const char*>([mergedData.get() bytes]), totalSize, static_cast<int>(totalSize)); 829 } 830 } 831 811 m_handle->handleDataArray(reinterpret_cast<CFArrayRef>(dataArray)); 832 812 // The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point. 833 813 }
Note: See TracChangeset
for help on using the changeset viewer.