From 2bde8e466a4451c7319e3a072d118917957d6554 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 May 2011 19:08:45 +0100 Subject: Merge WebKit at r82507: Initial merge by git Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e --- Source/WebCore/loader/mac/ResourceLoaderMac.mm | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Source/WebCore/loader/mac') diff --git a/Source/WebCore/loader/mac/ResourceLoaderMac.mm b/Source/WebCore/loader/mac/ResourceLoaderMac.mm index 3835517..b42f8e0 100644 --- a/Source/WebCore/loader/mac/ResourceLoaderMac.mm +++ b/Source/WebCore/loader/mac/ResourceLoaderMac.mm @@ -35,6 +35,10 @@ #include "FrameLoaderClient.h" #include "ResourceHandle.h" +#if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) +#include "InspectorInstrumentation.h" +#endif + namespace WebCore { NSCachedURLResponse* ResourceLoader::willCacheResponse(ResourceHandle*, NSCachedURLResponse* response) @@ -44,6 +48,44 @@ NSCachedURLResponse* ResourceLoader::willCacheResponse(ResourceHandle*, NSCached return frameLoader()->client()->willCacheResponse(documentLoader(), identifier(), response); } +#if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) + +void ResourceLoader::didReceiveDataArray(CFArrayRef dataArray) +{ + // Protect this in this delegate method since the additional processing can do + // anything including possibly derefing this; one example of this is Radar 3266216. + RefPtr protector(this); + + if (!m_shouldBufferData) + return; + + if (!m_resourceData) + m_resourceData = SharedBuffer::create(); + + CFIndex arrayCount = CFArrayGetCount(dataArray); + for (CFIndex i = 0; i < arrayCount; ++i) { + CFDataRef data = static_cast(CFArrayGetValueAtIndex(dataArray, i)); + int dataLen = static_cast(CFDataGetLength(data)); + + m_resourceData->append(data); + + // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing. + // However, with today's computers and networking speeds, this won't happen in practice. + // Could be an issue with a giant local file. + if (m_sendResourceLoadCallbacks && m_frame) + frameLoader()->notifier()->didReceiveData(this, reinterpret_cast(CFDataGetBytePtr(data)), dataLen, dataLen); + } +} + +void ResourceLoader::didReceiveDataArray(ResourceHandle*, CFArrayRef dataArray) +{ + InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier()); + didReceiveDataArray(dataArray); + InspectorInstrumentation::didReceiveResourceData(cookie); +} + +#endif + } #endif // !USE(CFNETWORK) -- cgit v1.1