Changeset 90400 in webkit


Ignore:
Timestamp:
Jul 5, 2011 10:34:43 AM (13 years ago)
Author:
psolanki@apple.com
Message:

2011-07-05 Pratik Solanki <psolanki@apple.com>

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:]):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90399 r90400  
     12011-07-05  Pratik Solanki  <psolanki@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Coalesce data array into one NSData before calling didReceiveData
     6        https://bugs.webkit.org/show_bug.cgi?id=63916
     7        <rdar://problem/9715181>
     8
     9        Instead of calling didReceiveData multiple times with smaller chunks of data, we merge the
     10        data buffers into one and call it once.
     11
     12        No new tests because the flag isn't enabled yet.
     13
     14        * platform/network/mac/ResourceHandleMac.mm:
     15        (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]):
     16
    1172011-07-05  Tamas Czene  <Czene.Tamas@stud.u-szeged.hu>
    218
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r88123 r90400  
    812812        m_handle->client()->didReceiveDataArray(m_handle, reinterpret_cast<CFArrayRef>(dataArray));
    813813    else {
    814         // The call to didReceiveData below could cancel a load, which would result in the delegate
    815         // (self) being released.
    816         RetainPtr<WebCoreResourceHandleAsDelegate> protect(self);
    817         for (NSData *data in dataArray) {
    818             if (!m_handle)
    819                 break;
     814        NSUInteger count = [dataArray count];
     815        ASSERT(count);
     816        if (count == 1) {
     817            NSData *data = [dataArray objectAtIndex:0];
    820818            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));
    821829        }
    822830    }
    823     return;
     831
     832    // The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point.
    824833}
    825834#endif
Note: See TracChangeset for help on using the changeset viewer.