Diff
Modified: trunk/Source/WebCore/ChangeLog (170929 => 170930)
--- trunk/Source/WebCore/ChangeLog 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/ChangeLog 2014-07-09 21:19:47 UTC (rev 170930)
@@ -1,5 +1,30 @@
2014-07-09 Pratik Solanki <psola...@apple.com>
+ Add SharedBuffer::wrapCFDataArray() and use it
+ https://bugs.webkit.org/show_bug.cgi?id=134733
+
+ Reviewed by Antti Koivisto.
+
+ No new tests. Should be covered by existing tests.
+
+ * platform/SharedBuffer.h:
+ * platform/cf/SharedBufferCF.cpp:
+ (WebCore::SharedBuffer::wrapCFDataArray):
+ (WebCore::SharedBuffer::SharedBuffer):
+ * platform/network/ResourceHandle.h:
+ * platform/network/cf/ResourceHandleCFNet.cpp:
+ (WebCore::ResourceHandle::handleDataArray): Deleted.
+ * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
+ (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveDataArray):
+ * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp:
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveDataArray):
+ * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+ (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]):
+ * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveDataArray:]):
+
+2014-07-09 Pratik Solanki <psola...@apple.com>
+
Move resource buffering from SynchronousNetworkLoaderClient to NetworkResourceLoader
https://bugs.webkit.org/show_bug.cgi?id=134732
Modified: trunk/Source/WebCore/platform/SharedBuffer.h (170929 => 170930)
--- trunk/Source/WebCore/platform/SharedBuffer.h 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/SharedBuffer.h 2014-07-09 21:19:47 UTC (rev 170930)
@@ -118,6 +118,7 @@
unsigned platformDataSize() const;
#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+ static PassRefPtr<SharedBuffer> wrapCFDataArray(CFArrayRef);
void append(CFDataRef);
#endif
@@ -196,6 +197,7 @@
bool m_shouldUsePurgeableMemory;
mutable OwnPtr<PurgeableBuffer> m_purgeableBuffer;
#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+ explicit SharedBuffer(CFArrayRef);
mutable Vector<RetainPtr<CFDataRef>> m_dataArray;
unsigned copySomeDataFromDataArray(const char*& someData, unsigned position) const;
const char *singleDataArrayBuffer() const;
Modified: trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp (170929 => 170930)
--- trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp 2014-07-09 21:19:47 UTC (rev 170930)
@@ -29,6 +29,7 @@
#include "SharedBuffer.h"
#include "PurgeableBuffer.h"
+#include <wtf/cf/TypeCasts.h>
#if ENABLE(DISK_IMAGE_CACHE)
#include "DiskImageCacheIOS.h"
@@ -112,6 +113,27 @@
}
#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+PassRefPtr<SharedBuffer> SharedBuffer::wrapCFDataArray(CFArrayRef cfDataArray)
+{
+ return adoptRef(new SharedBuffer(cfDataArray));
+}
+
+SharedBuffer::SharedBuffer(CFArrayRef cfDataArray)
+ : m_size(0)
+ , m_shouldUsePurgeableMemory(true)
+#if ENABLE(DISK_IMAGE_CACHE)
+ , m_isMemoryMapped(false)
+ , m_diskImageCacheId(DiskImageCache::invalidDiskCacheId)
+ , m_notifyMemoryMappedCallback(nullptr)
+ , m_notifyMemoryMappedCallbackData(nullptr)
+#endif
+ , m_cfData(nullptr)
+{
+ CFIndex dataArrayCount = CFArrayGetCount(cfDataArray);
+ for (CFIndex index = 0; index < dataArrayCount; ++index)
+ append(checked_cf_cast<CFDataRef>(CFArrayGetValueAtIndex(cfDataArray, index)));
+}
+
void SharedBuffer::append(CFDataRef data)
{
ASSERT(data);
Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (170929 => 170930)
--- trunk/Source/WebCore/platform/network/ResourceHandle.h 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h 2014-07-09 21:19:47 UTC (rev 170930)
@@ -258,10 +258,6 @@
static CFMutableDictionaryRef createSSLPropertiesFromNSURLRequest(const ResourceRequest&);
#endif
-#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
- void handleDataArray(CFArrayRef dataArray);
-#endif
-
typedef PassRefPtr<ResourceHandle> (*BuiltinConstructor)(const ResourceRequest& request, ResourceHandleClient* client);
static void registerBuiltinConstructor(const AtomicString& protocol, BuiltinConstructor);
Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (170929 => 170930)
--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp 2014-07-09 21:19:47 UTC (rev 170930)
@@ -624,29 +624,4 @@
}
#endif // USE(CFNETWORK)
-#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
-void ResourceHandle::handleDataArray(CFArrayRef dataArray)
-{
- ASSERT(client());
- if (client()->supportsDataArray()) {
- client()->didReceiveDataArray(this, dataArray);
- return;
- }
-
- CFIndex count = CFArrayGetCount(dataArray);
- ASSERT(count);
- if (count == 1) {
- CFDataRef data = "" 0));
- client()->didReceiveBuffer(this, SharedBuffer::wrapCFData(data), -1);
- return;
- }
-
- RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create();
- for (CFIndex index = 0; index < count; index++)
- sharedBuffer->append(static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, index)));
-
- client()->didReceiveBuffer(this, sharedBuffer, -1);
-}
-#endif
-
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp (170929 => 170930)
--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp 2014-07-09 21:19:47 UTC (rev 170930)
@@ -282,7 +282,7 @@
if (protector->hasHandle()) {
LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didSendBodyData(handle=%p) (%s)", m_handle, m_handle->firstRequest().url().string().utf8().data());
- m_handle->handleDataArray(dataArray);
+ m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(dataArray), -1);
}
CFRelease(dataArray);
});
Modified: trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp (170929 => 170930)
--- trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp 2014-07-09 21:19:47 UTC (rev 170930)
@@ -275,7 +275,8 @@
return;
#endif
- m_handle->handleDataArray(dataArray);
+ if (ResourceHandleClient* client = m_handle->client())
+ client->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(dataArray), -1);
}
#endif // USE(NETWORK_CFDATA_ARRAY_CALLBACK)
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm (170929 => 170930)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2014-07-09 21:19:47 UTC (rev 170930)
@@ -197,7 +197,7 @@
return;
#endif
- m_handle->handleDataArray(reinterpret_cast<CFArrayRef>(dataArray));
+ m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(reinterpret_cast<CFArrayRef>(dataArray)), -1);
// The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point.
}
#endif
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm (170929 => 170930)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2014-07-09 21:16:17 UTC (rev 170929)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2014-07-09 21:19:47 UTC (rev 170930)
@@ -239,7 +239,7 @@
if (!m_handle || !m_handle->client())
return;
- m_handle->handleDataArray(reinterpret_cast<CFArrayRef>(dataArray));
+ m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(reinterpret_cast<CFArrayRef>(dataArray)), -1);
// The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point.
});
}