Title: [90400] trunk/Source/WebCore
- Revision
- 90400
- Author
- [email protected]
- Date
- 2011-07-05 10:34:43 -0700 (Tue, 05 Jul 2011)
Log Message
2011-07-05 Pratik Solanki <[email protected]>
Reviewed by Dan Bernstein.
Coalesce data array into one NSData before calling didReceiveData
https://bugs.webkit.org/show_bug.cgi?id=63916
<rdar://problem/9715181>
Instead of calling didReceiveData multiple times with smaller chunks of data, we merge the
data buffers into one and call it once.
No new tests because the flag isn't enabled yet.
* platform/network/mac/ResourceHandleMac.mm:
(-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (90399 => 90400)
--- trunk/Source/WebCore/ChangeLog 2011-07-05 16:07:35 UTC (rev 90399)
+++ trunk/Source/WebCore/ChangeLog 2011-07-05 17:34:43 UTC (rev 90400)
@@ -1,3 +1,19 @@
+2011-07-05 Pratik Solanki <[email protected]>
+
+ Reviewed by Dan Bernstein.
+
+ Coalesce data array into one NSData before calling didReceiveData
+ https://bugs.webkit.org/show_bug.cgi?id=63916
+ <rdar://problem/9715181>
+
+ Instead of calling didReceiveData multiple times with smaller chunks of data, we merge the
+ data buffers into one and call it once.
+
+ No new tests because the flag isn't enabled yet.
+
+ * platform/network/mac/ResourceHandleMac.mm:
+ (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]):
+
2011-07-05 Tamas Czene <[email protected]>
Reviewed by Simon Fraser.
Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (90399 => 90400)
--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2011-07-05 16:07:35 UTC (rev 90399)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2011-07-05 17:34:43 UTC (rev 90400)
@@ -811,16 +811,25 @@
if (m_handle->client()->supportsDataArray())
m_handle->client()->didReceiveDataArray(m_handle, reinterpret_cast<CFArrayRef>(dataArray));
else {
- // The call to didReceiveData below could cancel a load, which would result in the delegate
- // (self) being released.
- RetainPtr<WebCoreResourceHandleAsDelegate> protect(self);
- for (NSData *data in dataArray) {
- if (!m_handle)
- break;
+ NSUInteger count = [dataArray count];
+ ASSERT(count);
+ if (count == 1) {
+ NSData *data = "" objectAtIndex:0];
m_handle->client()->didReceiveData(m_handle, static_cast<const char*>([data bytes]), [data length], static_cast<int>([data length]));
+ } else {
+ NSUInteger totalSize = 0;
+ for (NSData *data in dataArray)
+ totalSize += [data length];
+
+ RetainPtr<NSMutableData> mergedData(AdoptNS, [[NSMutableData alloc] initWithCapacity:totalSize]);
+ for (NSData *data in dataArray)
+ [mergedData.get() appendData:data];
+
+ m_handle->client()->didReceiveData(m_handle, static_cast<const char*>([mergedData.get() bytes]), totalSize, static_cast<int>(totalSize));
}
}
- return;
+
+ // The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point.
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes