WebCore:
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2007 08:07:59 +0000 (08:07 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2007 08:07:59 +0000 (08:07 +0000)
        Fix for bugzilla bug 13050 and also radar p1 5050645.

        This patch reworks resource loading to avoid having redundant buffers in the icon database and in cached
        images in the WebCore cache.  It also avoids overcopying in top-level image documents and in the icon
        database.

        There is now only one SharedBuffer for a resource and everybody observes that buffer now instead of ever
        making their own.  Even ImageIO uses the SharedBuffer while decoding.

        The page in 13050 dropped from 145mb down to 45mb of memory use with this change for a stunning savings
        of 100mb.

        Reviewed by olliej, mjs

        * WebCore.exp:
        * loader/CachedCSSStyleSheet.cpp:
        (WebCore::CachedCSSStyleSheet::data):
        * loader/CachedCSSStyleSheet.h:
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::data):
        * loader/CachedImage.h:
        * loader/CachedResource.cpp:
        (WebCore::CachedResource::CachedResource):
        (WebCore::CachedResource::~CachedResource):
        * loader/CachedResource.h:
        (WebCore::CachedResource::data):
        * loader/CachedScript.cpp:
        (WebCore::CachedScript::data):
        * loader/CachedScript.h:
        * loader/CachedXSLStyleSheet.cpp:
        (WebCore::CachedXSLStyleSheet::data):
        * loader/CachedXSLStyleSheet.h:
        * loader/DocLoader.cpp:
        (WebCore::DocLoader::checkCacheObjectStatus):
        * loader/ImageDocument.cpp:
        (WebCore::ImageTokenizer::writeRawData):
        (WebCore::ImageTokenizer::finish):
        * loader/icon/IconDataCache.cpp:
        (WebCore::IconDataCache::setImageData):
        (WebCore::IconDataCache::writeToDatabase):
        * loader/icon/IconDataCache.h:
        * loader/icon/IconDatabase.cpp:
        (WebCore::IconDatabase::imageDataForIconURL):
        (WebCore::IconDatabase::iconForPageURL):
        (WebCore::IconDatabase::setIconDataForIconURL):
        (WebCore::IconDatabase::setHaveNoIconForIconURL):
        (WebCore::IconDatabase::imageDataForIconURLQuery):
        * loader/icon/IconDatabase.h:
        * loader/icon/IconLoader.cpp:
        (WebCore::IconLoader::startLoading):
        (WebCore::IconLoader::didReceiveResponse):
        (WebCore::IconLoader::didReceiveData):
        (WebCore::IconLoader::didFail):
        (WebCore::IconLoader::finishLoading):
        (WebCore::IconLoader::clearLoadingState):
        * loader/icon/IconLoader.h:
        * loader/icon/SQLStatement.cpp:
        (WebCore::SQLStatement::getColumnBlobAsVector):
        (WebCore::SQLStatement::isExpired):
        * loader/icon/SQLStatement.h:
        * loader/loader.cpp:
        (WebCore::Loader::didFinishLoading):
        (WebCore::Loader::didReceiveData):
        * page/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge getData:andResponse:forURL:]):
        (-[WebCoreFrameBridge getAllResourceDatas:andResponses:]):
        * platform/SharedBuffer.h:
        (WebCore::SharedBuffer::isEmpty):
        * platform/graphics/BitmapImage.cpp:
        (WebCore::BitmapImage::destroyDecodedData):
        (WebCore::BitmapImage::dataChanged):
        * platform/graphics/BitmapImage.h:
        * platform/graphics/Image.cpp:
        (WebCore::Image::setData):
        * platform/graphics/Image.h:
        (WebCore::Image::dataChanged):
        (WebCore::Image::data):
        * platform/graphics/ImageSource.h:
        * platform/graphics/cg/ImageSourceCG.cpp:
        (WebCore::ImageSource::setData):
        * platform/graphics/cg/PDFDocumentImage.cpp:
        (WebCore::PDFDocumentImage::dataChanged):
        * platform/graphics/cg/PDFDocumentImage.h:
        * platform/graphics/mac/ImageMac.mm:
        (WebCore::Image::loadPlatformResource):
        * platform/graphics/svg/SVGImage.cpp:
        (WebCore::SVGImage::setData):
        * platform/mac/PasteboardMac.mm:
        (WebCore::fileWrapperForImage):

WebKit:

        Fixes to ensure that the resource loader's shared buffer can always be used.

        Reviewed by olliej, mjs

        * Misc/WebIconDatabase.mm:
        (-[WebIconDatabase _convertToWebCoreFormat]):
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::deliverArchivedResources):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20182 268f45cc-cd09-0410-ab3c-d52691b4dbfc

40 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/loader/CachedCSSStyleSheet.cpp
WebCore/loader/CachedCSSStyleSheet.h
WebCore/loader/CachedImage.cpp
WebCore/loader/CachedImage.h
WebCore/loader/CachedResource.cpp
WebCore/loader/CachedResource.h
WebCore/loader/CachedScript.cpp
WebCore/loader/CachedScript.h
WebCore/loader/CachedXSLStyleSheet.cpp
WebCore/loader/CachedXSLStyleSheet.h
WebCore/loader/DocLoader.cpp
WebCore/loader/ImageDocument.cpp
WebCore/loader/icon/IconDataCache.cpp
WebCore/loader/icon/IconDataCache.h
WebCore/loader/icon/IconDatabase.cpp
WebCore/loader/icon/IconDatabase.h
WebCore/loader/icon/IconLoader.cpp
WebCore/loader/icon/IconLoader.h
WebCore/loader/icon/SQLStatement.cpp
WebCore/loader/icon/SQLStatement.h
WebCore/loader/loader.cpp
WebCore/page/mac/WebCoreFrameBridge.mm
WebCore/platform/SharedBuffer.h
WebCore/platform/graphics/BitmapImage.cpp
WebCore/platform/graphics/BitmapImage.h
WebCore/platform/graphics/Image.cpp
WebCore/platform/graphics/Image.h
WebCore/platform/graphics/ImageSource.h
WebCore/platform/graphics/cg/ImageSourceCG.cpp
WebCore/platform/graphics/cg/PDFDocumentImage.cpp
WebCore/platform/graphics/cg/PDFDocumentImage.h
WebCore/platform/graphics/mac/ImageMac.mm
WebCore/platform/graphics/svg/SVGImage.cpp
WebCore/platform/graphics/svg/SVGImage.h
WebCore/platform/mac/PasteboardMac.mm
WebKit/ChangeLog
WebKit/Misc/WebIconDatabase.mm
WebKit/WebCoreSupport/WebFrameLoaderClient.mm

index e151de4..c5a7495 100644 (file)
@@ -1,3 +1,95 @@
+2007-03-13  David Hyatt  <hyatt@apple.com>
+
+        Fix for bugzilla bug 13050 and also radar p1 5050645.
+
+        This patch reworks resource loading to avoid having redundant buffers in the icon database and in cached
+        images in the WebCore cache.  It also avoids overcopying in top-level image documents and in the icon
+        database.
+
+        There is now only one SharedBuffer for a resource and everybody observes that buffer now instead of ever
+        making their own.  Even ImageIO uses the SharedBuffer while decoding.
+
+        The page in 13050 dropped from 145mb down to 45mb of memory use with this change for a stunning savings
+        of 100mb.
+
+        Reviewed by olliej, mjs
+
+        * WebCore.exp:
+        * loader/CachedCSSStyleSheet.cpp:
+        (WebCore::CachedCSSStyleSheet::data):
+        * loader/CachedCSSStyleSheet.h:
+        * loader/CachedImage.cpp:
+        (WebCore::CachedImage::data):
+        * loader/CachedImage.h:
+        * loader/CachedResource.cpp:
+        (WebCore::CachedResource::CachedResource):
+        (WebCore::CachedResource::~CachedResource):
+        * loader/CachedResource.h:
+        (WebCore::CachedResource::data):
+        * loader/CachedScript.cpp:
+        (WebCore::CachedScript::data):
+        * loader/CachedScript.h:
+        * loader/CachedXSLStyleSheet.cpp:
+        (WebCore::CachedXSLStyleSheet::data):
+        * loader/CachedXSLStyleSheet.h:
+        * loader/DocLoader.cpp:
+        (WebCore::DocLoader::checkCacheObjectStatus):
+        * loader/ImageDocument.cpp:
+        (WebCore::ImageTokenizer::writeRawData):
+        (WebCore::ImageTokenizer::finish):
+        * loader/icon/IconDataCache.cpp:
+        (WebCore::IconDataCache::setImageData):
+        (WebCore::IconDataCache::writeToDatabase):
+        * loader/icon/IconDataCache.h:
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::imageDataForIconURL):
+        (WebCore::IconDatabase::iconForPageURL):
+        (WebCore::IconDatabase::setIconDataForIconURL):
+        (WebCore::IconDatabase::setHaveNoIconForIconURL):
+        (WebCore::IconDatabase::imageDataForIconURLQuery):
+        * loader/icon/IconDatabase.h:
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading):
+        (WebCore::IconLoader::didReceiveResponse):
+        (WebCore::IconLoader::didReceiveData):
+        (WebCore::IconLoader::didFail):
+        (WebCore::IconLoader::finishLoading):
+        (WebCore::IconLoader::clearLoadingState):
+        * loader/icon/IconLoader.h:
+        * loader/icon/SQLStatement.cpp:
+        (WebCore::SQLStatement::getColumnBlobAsVector):
+        (WebCore::SQLStatement::isExpired):
+        * loader/icon/SQLStatement.h:
+        * loader/loader.cpp:
+        (WebCore::Loader::didFinishLoading):
+        (WebCore::Loader::didReceiveData):
+        * page/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge getData:andResponse:forURL:]):
+        (-[WebCoreFrameBridge getAllResourceDatas:andResponses:]):
+        * platform/SharedBuffer.h:
+        (WebCore::SharedBuffer::isEmpty):
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::destroyDecodedData):
+        (WebCore::BitmapImage::dataChanged):
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::setData):
+        * platform/graphics/Image.h:
+        (WebCore::Image::dataChanged):
+        (WebCore::Image::data):
+        * platform/graphics/ImageSource.h:
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageSource::setData):
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        (WebCore::PDFDocumentImage::dataChanged):
+        * platform/graphics/cg/PDFDocumentImage.h:
+        * platform/graphics/mac/ImageMac.mm:
+        (WebCore::Image::loadPlatformResource):
+        * platform/graphics/svg/SVGImage.cpp:
+        (WebCore::SVGImage::setData):
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::fileWrapperForImage):
+
 2007-03-13  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
index 88b6e37..8c7a042 100644 (file)
@@ -219,7 +219,7 @@ __ZN7WebCore12IconDatabase18sharedIconDatabaseEv
 __ZN7WebCore12IconDatabase20retainIconForPageURLERKNS_6StringE
 __ZN7WebCore12IconDatabase20setIconURLForPageURLERKNS_6StringES3_
 __ZN7WebCore12IconDatabase21releaseIconForPageURLERKNS_6StringE
-__ZN7WebCore12IconDatabase21setIconDataForIconURLEPKviRKNS_6StringE
+__ZN7WebCore12IconDatabase21setIconDataForIconURLEN3WTF10PassRefPtrINS_12SharedBufferEEERKNS_6StringE
 __ZN7WebCore12IconDatabase23defaultDatabaseFilenameEv
 __ZN7WebCore12IconDatabase23isIconExpiredForIconURLERKNS_6StringE
 __ZN7WebCore12IconDatabase23setHaveNoIconForIconURLERKNS_6StringE
index 95d5e93..1ded187 100644 (file)
@@ -67,13 +67,17 @@ void CachedCSSStyleSheet::setEncoding(const String& chs)
     m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
 }
 
-void CachedCSSStyleSheet::data(Vector<char>& data, bool allDataReceived)
+void CachedCSSStyleSheet::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
     if (!allDataReceived)
         return;
 
-    setEncodedSize(data.size());
-    m_sheet = m_decoder->decode(data.data(), encodedSize());
+    m_data = data;
+    setEncodedSize(m_data.get() ? m_data->size() : 0);
+    if (!m_data.get())
+        return;
+
+    m_sheet = m_decoder->decode(m_data->data(), encodedSize());
     m_sheet += m_decoder->flush();
     m_loading = false;
     checkNotify();
index 6f69d1f..184df02 100644 (file)
@@ -47,7 +47,7 @@ namespace WebCore {
         virtual void ref(CachedResourceClient*);
  
         virtual void setEncoding(const String&);
-        virtual void data(Vector<char>&, bool allDataReceived);
+        virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
         virtual void error();
 
         virtual bool schedule() const { return true; }
index f36c5d8..3903bfc 100644 (file)
@@ -165,43 +165,10 @@ inline void CachedImage::createImage()
     m_image = new BitmapImage(this);
 }
 
-Vector<char>& CachedImage::bufferData(const char* bytes, int addedSize, Request* request)
+void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
-    createImage();
-
-    Vector<char>& imageBuffer = m_image->dataBuffer();
-
-    if (addedSize > 0) {
-        bool success = false;
-        unsigned oldSize = imageBuffer.size();
-        unsigned newSize = oldSize + addedSize;
-
-        // Check for overflow
-        if (newSize > oldSize) {
-            // Use temporary Vector so we can safely detect if the allocation fails
-            //
-            // The code that was here before, just called resize of the imageBuffer.  Vector<>::resize
-            // will crash if the resize of a non-empty Vector<> fails.
-            Vector<char> tempBuffer(newSize);
-
-            char* tempBufferBytes = tempBuffer.data();
-            if (tempBufferBytes) {
-                memcpy(tempBufferBytes, imageBuffer.data(), oldSize);
-                memcpy(tempBufferBytes + oldSize, bytes, addedSize);
-                tempBuffer.swap(imageBuffer);
-                success = true;
-            }
-        }
-
-        if (!success)
-            error();
-    }
+    m_data = data;
 
-    return imageBuffer;
-}
-
-void CachedImage::data(Vector<char>& data, bool allDataReceived)
-{
     createImage();
 
     bool sizeAvailable = false;
@@ -209,7 +176,7 @@ void CachedImage::data(Vector<char>& data, bool allDataReceived)
     // Have the image update its data from its internal buffer.
     // It will not do anything now, but will delay decoding until 
     // queried for info (like size or specific image frames).
-    sizeAvailable = m_image->setData(allDataReceived);
+    sizeAvailable = m_image->setData(m_data, allDataReceived);
 
     // Go ahead and tell our observers to try to draw if we have either
     // received all the data or the size is known.  Each chunk from the
@@ -226,16 +193,8 @@ void CachedImage::data(Vector<char>& data, bool allDataReceived)
         
         notifyObservers();
 
-        if (m_image) {
-            Vector<char>& imageBuffer = m_image->dataBuffer();
-#if PLATFORM(CG)
-            // ImageIO sources copy the image data.  We will go ahead and count encoded
-            // size twice until this issue is fixed.  See <rdar://problem/5050645>
-            setEncodedSize(imageBuffer.size() * 2);
-#else
-            setEncodedSize(imageBuffer.size());
-#endif
-        }
+        if (m_image)
+            setEncodedSize(m_image->data() ? m_image->data()->size() : 0);
     }
     
     if (allDataReceived) {
index 74249b7..b69f421 100644 (file)
@@ -57,8 +57,7 @@ public:
     virtual void allReferencesRemoved();
     virtual void destroyDecodedData();
 
-    virtual Vector<char>& bufferData(const char* bytes, int addedSize, Request*);
-    virtual void data(Vector<char>&, bool allDataReceived);
+    virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
     virtual void error();
 
     virtual bool schedule() const { return true; }
@@ -83,7 +82,6 @@ private:
     void notifyObservers();
 
     Image* m_image;
-    int m_dataSize;
 
     friend class Cache;
 };
index eb0b190..e16e803 100644 (file)
@@ -46,7 +46,6 @@ CachedResource::CachedResource(const String& URL, Type type, CachePolicy cachePo
     m_inCache = false;
     m_cachePolicy = cachePolicy;
     m_request = 0;
-    m_allData = 0;
     m_expireDateChanged = false;
     m_accessCount = 0;
     m_nextInLRUList = 0;
@@ -66,19 +65,6 @@ CachedResource::~CachedResource()
 #ifndef NDEBUG
     m_deleted = true;
 #endif
-    setAllData(0);
-}
-
-Vector<char>& CachedResource::bufferData(const char* bytes, int addedSize, Request* request)
-{
-    // Add new bytes to the buffer in the Request object.
-    Vector<char>& buffer = request->buffer();
-
-    unsigned oldSize = buffer.size();
-    buffer.resize(oldSize + addedSize);
-    memcpy(buffer.data() + oldSize, bytes, addedSize);
-    
-    return buffer;
 }
 
 void CachedResource::finish()
index 234ee6f..86f0a8d 100644 (file)
@@ -71,8 +71,7 @@ public:
     virtual ~CachedResource();
 
     virtual void setEncoding(const String&) { }
-    virtual Vector<char>& bufferData(const char* bytes, int addedSize, Request*);
-    virtual void data(Vector<char>&, bool allDataReceived) = 0;
+    virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived) = 0;
     virtual void error() = 0;
 
     const String &url() const { return m_url; }
@@ -113,8 +112,7 @@ public:
 
     void setRequest(Request*);
 
-    SharedBuffer* allData() const { return m_allData.get(); }
-    void setAllData(PassRefPtr<SharedBuffer> allData) { m_allData = allData; }
+    SharedBuffer* data() const { return m_data.get(); }
 
     void setResponse(const ResourceResponse& response) { m_response = response; }
     const ResourceResponse& response() const { return m_response; }
@@ -145,7 +143,7 @@ protected:
     Request* m_request;
 
     ResourceResponse m_response;
-    RefPtr<SharedBuffer> m_allData;
+    RefPtr<SharedBuffer> m_data;
 
     Type m_type;
     Status m_status;
index 89637fc..7367a8d 100644 (file)
@@ -70,13 +70,16 @@ void CachedScript::setEncoding(const String& chs)
         m_encoding = encoding;
 }
 
-void CachedScript::data(Vector<char>& data, bool allDataReceived)
+void CachedScript::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
-    if (!allDataReceived)
+    if (!allDataReceived || !data.get())
         return;
 
-    setEncodedSize(data.size());
-    m_script = m_encoding.decode(data.data(), encodedSize());
+    m_data = data;
+    setEncodedSize(m_data.get() ? m_data->size() : 0);
+    if (!m_data.get())
+        return;
+    m_script = m_encoding.decode(m_data->data(), encodedSize());
     m_loading = false;
     checkNotify();
 }
index f8b7f7f..56a4a39 100644 (file)
@@ -45,7 +45,7 @@ namespace WebCore {
         virtual void ref(CachedResourceClient*);
 
         virtual void setEncoding(const String&);
-        virtual void data(Vector<char>&, bool allDataReceived);
+        virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
         virtual void error();
 
         virtual bool schedule() const { return false; }
index f12806b..90d66ce 100644 (file)
@@ -66,13 +66,16 @@ void CachedXSLStyleSheet::setEncoding(const String& chs)
     m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
 }
 
-void CachedXSLStyleSheet::data(Vector<char>& data, bool allDataReceived)
+void CachedXSLStyleSheet::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
-    if (!allDataReceived)
+    if (!allDataReceived || !data.get())
         return;
 
-    setEncodedSize(data.size());
-    m_sheet = String(m_decoder->decode(data.data(), encodedSize()));
+    m_data = data;     
+    setEncodedSize(m_data.get() ? m_data->size() : 0);
+    if (!m_data.get())
+        return;
+    m_sheet = String(m_decoder->decode(m_data->data(), encodedSize()));
     m_sheet += m_decoder->flush();
     m_loading = false;
     checkNotify();
index 6bfc1ae..d4ba168 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
         virtual void ref(CachedResourceClient*);
         
         virtual void setEncoding(const String&);
-        virtual void data(Vector<char>&, bool allDataReceived);
+        virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
         virtual void error();
         
         virtual bool schedule() const { return true; }
index 72d53e4..3a3cf85 100644 (file)
@@ -202,7 +202,7 @@ void DocLoader::checkCacheObjectStatus(CachedResource* resource)
     
     ResourceRequest request(resource->url());
     const ResourceResponse& response = resource->response();
-    SharedBuffer* data = resource->allData();
+    SharedBuffer* data = resource->data();
     
     // FIXME: If the WebKit client changes or cancels the request, WebCore does not respect this and continues the load.
     m_frame->loader()->loadedResourceFromMemoryCache(request, response, data ? data->size() : 0);
index 3c59d1e..4af1eac 100644 (file)
@@ -96,7 +96,7 @@ bool ImageTokenizer::writeRawData(const char* data, int len)
         createDocumentStructure();
 
     CachedImage* cachedImage = m_imageElement->cachedImage();
-    cachedImage->data(cachedImage->bufferData(data, len, 0), false);
+    cachedImage->data(m_doc->frame()->loader()->documentLoader()->mainResourceData(), false);
 
     return false;
 }
@@ -112,11 +112,9 @@ void ImageTokenizer::finish()
 {
     if (!m_parserStopped && m_imageElement) {
         CachedImage* cachedImage = m_imageElement->cachedImage();
-        Vector<char>& buffer = cachedImage->bufferData(0, 0, 0);
-        cachedImage->data(buffer, true);
+        cachedImage->data(m_doc->frame()->loader()->documentLoader()->mainResourceData(), true);
         cachedImage->finish();
 
-        cachedImage->setAllData(m_doc->frame()->loader()->documentLoader()->mainResourceData());
         cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response());
         
         // FIXME: Need code to set the title for platforms other than Mac OS X.
index 715261c..4416114 100644 (file)
@@ -60,24 +60,16 @@ Image* IconDataCache::getImage(const IntSize& size)
     return 0;
 }
 
-void IconDataCache::setImageData(unsigned char* data, int size)
+void IconDataCache::setImageData(PassRefPtr<SharedBuffer> data)
 {
-    if (!data)
-        ASSERT(!size);
-
     // It's okay to delete the raw image data here. Any existing clients using this icon will be
     // managing an image that was created with a copy of this raw image data.
     if (m_image)
         delete m_image;
     m_image = new BitmapImage();
 
-    // Copy the provided data into the buffer of the new Image object
-    Vector<char>& dataBuffer = m_image->dataBuffer();
-    dataBuffer.resize(size);
-    memcpy(dataBuffer.data(), data, size);
-    
-    // Tell the Image object that all of its data has been set
-    if (!m_image->setData(true)) {
+    // Copy the provided data into the buffer of the new Image object.
+    if (!m_image->setData(data, true)) {
         LOG(IconDatabase, "Manual image data for iconURL '%s' FAILED - it was probably invalid image data", m_iconURL.ascii().data());
         delete m_image;
         m_image = 0;
@@ -119,8 +111,8 @@ void IconDataCache::writeToDatabase(SQLDatabase& db)
     
     // If we *have* image data, bind it to this statement - Otherwise the DB will get "null" for the blob data, 
     // signifying that this icon doesn't have any data    
-    if (m_image && !m_image->dataBuffer().isEmpty())
-        if (updateAttempt.bindBlob(2, m_image->dataBuffer().data(), m_image->dataBuffer().size()) != SQLResultOk) {
+    if (m_image && !m_image->data()->isEmpty())
+        if (updateAttempt.bindBlob(2, m_image->data()->data(), m_image->data()->size()) != SQLResultOk) {
             LOG_ERROR("Failed to bind icon data to SQL statement to update icon data for url %s", m_iconURL.ascii().data());
             return;
         }
@@ -146,8 +138,8 @@ void IconDataCache::writeToDatabase(SQLDatabase& db)
         
     // Then, if we *have* data, we bind it.  Otherwise the DB will get "null" for the blob data, 
     // signifying that this icon doesn't have any data
-    if (m_image && !m_image->dataBuffer().isEmpty())
-        insertStatement.bindBlob(3, m_image->dataBuffer().data(), m_image->dataBuffer().size());
+    if (m_image && !m_image->data()->isEmpty())
+        insertStatement.bindBlob(3, m_image->data()->data(), m_image->data()->size());
     
     // Finally we step and make sure the step was successful
     if (insertStatement.step() != SQLResultDone)
index 39490a0..f5801f9 100644 (file)
@@ -32,6 +32,7 @@ namespace WebCore {
 
 class Image;
 class IntSize;
+class SharedBuffer;
 class SQLDatabase;
 
 enum ImageDataStatus {
@@ -49,7 +50,7 @@ public:
     Image* getImage(const IntSize&);    
     String getIconURL() { return m_iconURL; }
 
-    void setImageData(unsigned char* data, int size);
+    void setImageData(PassRefPtr<SharedBuffer> data);
     
     void loadImageFromResource(const char*);
     
index 1e24d0d..7bee2b1 100644 (file)
@@ -320,12 +320,12 @@ void IconDatabase::createDatabaseTables(SQLDatabase& db)
     }
 }    
 
-void IconDatabase::imageDataForIconURL(const String& iconURL, Vector<unsigned char>& result)
+void IconDatabase::imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result)
 {      
     // If private browsing is enabled, we'll check there first as the most up-to-date data for an icon will be there
     if (m_privateBrowsingEnabled) {    
         imageDataForIconURLQuery(m_privateBrowsingDB, iconURL, result);
-        if (!result.isEmpty())
+        if (!result->isEmpty())
             return;
     } 
     
@@ -370,9 +370,9 @@ Image* IconDatabase::iconForPageURL(const String& pageURL, const IntSize& size,
     // If it's a new IconDataCache object that doesn't have its imageData set yet,
     // we'll read in that image data now
     if (icon->imageDataStatus() == ImageDataStatusUnknown) {
-        Vector<unsigned char> data;
-        imageDataForIconURL(iconURL, data);
-        icon->setImageData(data.data(), data.size());
+        RefPtr<SharedBuffer> data = new SharedBuffer();
+        imageDataForIconURL(iconURL, data.get());
+        icon->setImageData(data.get());
     }
         
     return icon->getImage(size);
@@ -640,22 +640,16 @@ IconDataCache* IconDatabase::getOrCreateIconDataCache(const String& iconURL)
     return icon;
 }
 
-void IconDatabase::setIconDataForIconURL(const void* data, int size, const String& iconURL)
+void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String& iconURL)
 {
-    ASSERT(size > -1);
     if (!isOpen() || iconURL.isEmpty())
         return;
 
-    if (size)
-        ASSERT(data);
-    else
-        data = 0;
-    
     // Get the IconDataCache for this IconURL (note, IconDataCacheForIconURL will create it if necessary)
     IconDataCache* icon = getOrCreateIconDataCache(iconURL);
     
     // Set the data in the IconDataCache
-    icon->setImageData((unsigned char*)data, size);
+    icon->setImageData(data);
     
     // Update the timestamp in the IconDataCache to NOW
     icon->setTimestamp((int)currentTime());
@@ -666,7 +660,7 @@ void IconDatabase::setIconDataForIconURL(const void* data, int size, const Strin
 
 void IconDatabase::setHaveNoIconForIconURL(const String& iconURL)
 {   
-    setIconDataForIconURL(0, 0, iconURL);
+    setIconDataForIconURL(0, iconURL);
 }
 
 bool IconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL)
@@ -955,16 +949,18 @@ bool IconDatabase::pageURLTableIsEmptyQuery(SQLDatabase& db)
     return !SQLStatement(db, "SELECT iconID FROM PageURL LIMIT 1;").returnsAtLeastOneResult();
 }
 
-void IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, Vector<unsigned char>& imageData)
+void IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> imageData)
 {
     readySQLStatement(m_imageDataForIconURLStatement, db, "SELECT Icon.data FROM Icon WHERE Icon.url = (?);");
     m_imageDataForIconURLStatement->bindText16(1, iconURL, false);
     
     int result = m_imageDataForIconURLStatement->step();
-    imageData.clear();
-    if (result == SQLResultRow)
-        m_imageDataForIconURLStatement->getColumnBlobAsVector(0, imageData);
-    else if (result != SQLResultDone)
+    imageData->clear();
+    if (result == SQLResultRow) {
+        Vector<char> data;
+        m_imageDataForIconURLStatement->getColumnBlobAsVector(0, data);
+        imageData->append(data.data(), data.size());
+    } else if (result != SQLResultDone)
         LOG_ERROR("imageDataForIconURLQuery failed");
 
     m_imageDataForIconURLStatement->reset();
index 4d86c0b..1855b0c 100644 (file)
@@ -38,6 +38,7 @@ namespace WebCore {
 class Image;
 class IntSize;
 class IconDataCache;
+class SharedBuffer;
 class SQLTransaction;
 
 class IconDatabase : Noncopyable {
@@ -67,7 +68,7 @@ public:
 
     bool isIconExpiredForIconURL(const String&);
     
-    void setIconDataForIconURL(const void* data, int size, const String&);
+    void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&);
     void setHaveNoIconForIconURL(const String&);
     
     // Returns true if the set actually took place, false if the mapping already existed
@@ -121,7 +122,7 @@ private:
     void createDatabaseTables(SQLDatabase&);
     
     // Returns the image data for the given IconURL, checking both databases if necessary
-    void imageDataForIconURL(const String& iconURL, Vector<unsigned char>&);
+    void imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result);
     
     // Retains an iconURL, bringing it back from the brink if it was pending deletion
     void retainIconURL(const String& iconURL);
@@ -161,7 +162,7 @@ private:
     SQLStatement* m_addIconForIconURLStatement;
     
     // Query - Returns the image data from the given database for the given IconURL
-    void imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, Vector<unsigned char>& result);
+    void imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> result);
     SQLStatement* m_imageDataForIconURLStatement;
 
     void deleteAllPreparedStatements(bool withSync);
index ff39588..33bbc1c 100644 (file)
@@ -41,8 +41,6 @@ using namespace std;
 
 namespace WebCore {
 
-const size_t defaultBufferSize = 4096; // bigger than most icons
-
 IconLoader::IconLoader(Frame* frame)
     : m_frame(frame)
     , m_loadIsInProgress(false)
@@ -74,7 +72,6 @@ void IconLoader::startLoading()
     // Set flag so we can detect the case where the load completes before
     // SubresourceLoader::create returns.
     m_loadIsInProgress = true;
-    m_buffer.reserveCapacity(defaultBufferSize);
 
     RefPtr<SubresourceLoader> loader = SubresourceLoader::create(m_frame, this, m_frame->loader()->iconURL());
     if (!loader)
@@ -99,22 +96,18 @@ void IconLoader::didReceiveResponse(SubresourceLoader* resourceLoader, const Res
     int status = response.httpStatusCode();
     if (status && (status < 200 || status > 299)) {
         KURL iconURL = resourceLoader->handle()->url();
-        m_resourceLoader = 0;
         finishLoading(iconURL);
+        m_resourceLoader = 0;
     }
 }
 
 void IconLoader::didReceiveData(SubresourceLoader*, const char* data, int size)
 {
-    ASSERT(data || size == 0);
-    ASSERT(size >= 0);
-    m_buffer.append(data, size);
 }
 
 void IconLoader::didFail(SubresourceLoader* resourceLoader, const ResourceError&)
 {
     ASSERT(m_loadIsInProgress);
-    m_buffer.clear();
     finishLoading(resourceLoader->handle()->url());
 }
 
@@ -130,7 +123,7 @@ void IconLoader::didFinishLoading(SubresourceLoader* resourceLoader)
 
 void IconLoader::finishLoading(const KURL& iconURL)
 {
-    IconDatabase::sharedIconDatabase()->setIconDataForIconURL(m_buffer.data(), m_buffer.size(), iconURL.url());
+    IconDatabase::sharedIconDatabase()->setIconDataForIconURL(m_resourceLoader->resourceData(), iconURL.url());
     m_frame->loader()->commitIconURLToIconDatabase(iconURL);
     m_frame->loader()->client()->dispatchDidReceiveIcon();
     clearLoadingState();
@@ -139,7 +132,6 @@ void IconLoader::finishLoading(const KURL& iconURL)
 void IconLoader::clearLoadingState()
 {
     m_resourceLoader = 0;
-    m_buffer.clear();
     m_loadIsInProgress = false;
 }
 
index 4076469..d63e3ca 100644 (file)
@@ -30,7 +30,6 @@
 #include "SubresourceLoaderClient.h"
 #include <memory>
 #include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
 
 namespace WebCore {
 
@@ -58,7 +57,6 @@ private:
     Frame* m_frame;
 
     RefPtr<SubresourceLoader> m_resourceLoader;
-    Vector<char> m_buffer;
     bool m_loadIsInProgress;
 }; // class IconLoader
 
index 1406acb..c97230c 100644 (file)
@@ -230,7 +230,7 @@ int64_t SQLStatement::getColumnInt64(int col)
     return sqlite3_column_int64(m_statement, col);
 }
     
-void SQLStatement::getColumnBlobAsVector(int col, Vector<unsigned char>& result)
+void SQLStatement::getColumnBlobAsVector(int col, Vector<char>& result)
 {
     if (!m_statement && prepareAndStep() != SQLITE_ROW) {
         result.clear();
@@ -373,9 +373,9 @@ bool SQLStatement::returnDoubleResults(int col, Vector<double>& v)
     return result;
 }
 
-bool SQLStatement::isExpired()\r
-{\r
-    return m_statement ? sqlite3_expired(m_statement) : true;\r
-}\r
+bool SQLStatement::isExpired()
+{
+    return m_statement ? sqlite3_expired(m_statement) : true;
+}
 
 } // namespace WebCore
index 3a75f61..06cdda2 100644 (file)
@@ -79,7 +79,7 @@ public:
     int getColumnInt(int col);
     int64_t getColumnInt64(int col);
     const void* getColumnBlob(int col, int& size);
-    void getColumnBlobAsVector(int col, Vector<unsigned char>&);
+    void getColumnBlobAsVector(int col, Vector<char>&);
 
     bool returnTextResults(int col, Vector<String>&);
     bool returnTextResults16(int col, Vector<String>&);
index 80fa352..7bf9adb 100644 (file)
@@ -104,8 +104,7 @@ void Loader::didFinishLoading(SubresourceLoader* loader)
     DocLoader* docLoader = req->docLoader();
 
     docLoader->setLoadInProgress(true);
-    object->data(req->buffer(), true);
-    object->setAllData(loader->resourceData());
+    object->data(loader->resourceData(), true);
     docLoader->setLoadInProgress(false);
     object->finish();
 
@@ -167,14 +166,13 @@ void Loader::didReceiveData(SubresourceLoader* loader, const char* data, int siz
         return;
 
     CachedResource* object = request->cachedResource();    
-    Vector<char>& buffer = object->bufferData(data, size, request);
 
     // Set the data.
     if (request->isMultipart())
         // The loader delivers the data in a multipart section all at once, send eof.
-        object->data(buffer, true);
+        object->data(loader->resourceData(), true);
     else if (request->isIncremental())
-        object->data(buffer, false);
+        object->data(loader->resourceData(), false);
 }
 
 int Loader::numRequests(DocLoader* dl) const
index 05cdaee..6e76d69 100644 (file)
@@ -1408,7 +1408,7 @@ static NSCharacterSet *_getPostSmartSet(void)
     if (!resource)
         return NO;
 
-    SharedBuffer* buffer = resource->allData();
+    SharedBuffer* buffer = resource->data();
     if (buffer)
         *data = [buffer->createNSData() autorelease];
     else
@@ -1435,7 +1435,7 @@ static NSCharacterSet *_getPostSmartSet(void)
 
     HashMap<String, CachedResource*>::const_iterator end = allResources.end();
     for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
-        SharedBuffer* buffer = it->second->allData();
+        SharedBuffer* buffer = it->second->data();
         NSData *data;
         
         if (buffer)
index 23e9333..50ce48e 100644 (file)
@@ -54,6 +54,8 @@ public:
     const char* data() const;
     unsigned size() const;
 
+    bool isEmpty() const { return size() == 0; }
+
     void append(const char*, int);
     void clear();
     const char* platformData() const;
index 269fdb4..9176da5 100644 (file)
@@ -94,7 +94,7 @@ void BitmapImage::destroyDecodedData(bool incremental)
             // Reset the image source, since Image I/O has an underlying cache that it uses
             // while animating that it seems to never clear.
             m_source.clear();
-            setData(true);
+            dataChanged(true);
         }
     }
 }
@@ -137,12 +137,12 @@ IntSize BitmapImage::size() const
     return m_size;
 }
 
-bool BitmapImage::setNativeData(NativeBytePtr data, bool allDataReceived)
+bool BitmapImage::dataChanged(bool allDataReceived)
 {
     destroyDecodedData(true);
     
     // Feed all the data we've seen so far to the image decoder.
-    m_source.setData(data, allDataReceived);
+    m_source.setData(m_data.get(), allDataReceived);
     
     // Image properties will not be available until the first frame of the file
     // reaches kCGImageStatusIncomplete.
index 45852f4..6894336 100644 (file)
@@ -94,7 +94,7 @@ public:
     
     virtual IntSize size() const;
 
-    virtual bool setNativeData(NativeBytePtr, bool allDataReceived);
+    virtual bool dataChanged(bool allDataReceived);
 
     // It may look unusual that there is no start animation call as public API.  This is because
     // we start and stop animating lazily.  Animation begins whenever someone draws the image.  It will
index 9cfafdc..80fff2d 100644 (file)
@@ -59,9 +59,13 @@ bool Image::isNull() const
     return size().isEmpty();
 }
 
-bool Image::setData(bool allDataReceived)
+bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
-    int length = m_data.size();
+    m_data = data;
+    if (!m_data.get())
+        return true;
+
+    int length = m_data->size();
     if (!length)
         return true;
 
@@ -75,16 +79,7 @@ bool Image::setData(bool allDataReceived)
     }
 #endif
     
-#if PLATFORM(CG)
-    // Avoid the extra copy of bytes by just handing the byte array directly to a CFDataRef.
-    CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data.data()), length, kCFAllocatorNull);
-    bool result = setNativeData(data, allDataReceived);
-    CFRelease(data);
-#else
-    bool result = setNativeData(&m_data, allDataReceived);
-#endif
-
-    return result;
+    return dataChanged(allDataReceived);
 }
 
 IntRect Image::rect() const
index 994a585..330d55f 100644 (file)
@@ -30,6 +30,9 @@
 #include "Color.h"
 #include "GraphicsTypes.h"
 #include "ImageSource.h"
+#include <wtf/RefPtr.h>
+#include <wtf/PassRefPtr.h>
+#include "SharedBuffer.h"
 
 #if PLATFORM(MAC)
 #ifdef __OBJC__
@@ -60,6 +63,7 @@ class FloatSize;
 class GraphicsContext;
 class IntRect;
 class IntSize;
+class SharedBuffer;
 class String;
 
 // This class gets notified when an image creates or destroys decoded frames and when it advances animation frames.
@@ -81,15 +85,15 @@ public:
     int width() const;
     int height() const;
 
-    virtual bool setData(bool allDataReceived);
-    virtual bool setNativeData(NativeBytePtr, bool allDataReceived) { return false; }
+    bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
+    virtual bool dataChanged(bool allDataReceived) { return false; }
     
     // FIXME: PDF/SVG will be underreporting decoded sizes and will be unable to prune because these functions are not
     // implemented yet for those image types.
     virtual void destroyDecodedData(bool incremental = false) {};
     virtual unsigned decodedSize() const { return 0; }
 
-    Vector<char>& dataBuffer() { return m_data; }
+    SharedBuffer* data() { return m_data.get(); }
 
     // It may look unusual that there is no start animation call as public API.  This is because
     // we start and stop animating lazily.  Animation begins whenever someone draws the image.  It will
@@ -145,7 +149,7 @@ private:
 #endif
     
 protected:
-    Vector<char> m_data; // The encoded raw data for the image. 
+    RefPtr<SharedBuffer> m_data; // The encoded raw data for the image. 
     ImageObserver* m_imageObserver;
 };
 
index 25edf1f..de11054 100644 (file)
@@ -43,20 +43,18 @@ typedef struct _cairo_surface cairo_surface_t;
 namespace WebCore {
 
 class IntSize;
+class SharedBuffer;
 
 #if PLATFORM(CG)
 typedef CGImageSourceRef NativeImageSourcePtr;
 typedef CGImageRef NativeImagePtr;
-typedef CFDataRef NativeBytePtr;
 #elif PLATFORM(QT)
 class ImageDecoderQt;
 typedef ImageDecoderQt* NativeImageSourcePtr;
-typedef const Vector<char>* NativeBytePtr;
 typedef QPixmap* NativeImagePtr;
 #else
 class ImageDecoder;
 typedef ImageDecoder* NativeImageSourcePtr;
-typedef const Vector<char>* NativeBytePtr;
 typedef cairo_surface_t* NativeImagePtr;
 #endif
 
@@ -72,7 +70,7 @@ public:
 
     bool initialized() const;
     
-    void setData(NativeBytePtr, bool allDataReceived);
+    void setData(SharedBuffer* data, bool allDataReceived);
 
     bool isSizeAvailable();
     IntSize size() const;
index 88f1ff0..59fc8d4 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "ImageSource.h"
+#include "SharedBuffer.h"
 
 #if PLATFORM(CG)
 
@@ -71,11 +72,14 @@ bool ImageSource::initialized() const
     return m_decoder;
 }
 
-void ImageSource::setData(NativeBytePtr data, bool allDataReceived)
+void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
 {
     if (!m_decoder)
         m_decoder = CGImageSourceCreateIncremental(NULL);
-    CGImageSourceUpdateData(m_decoder, data, allDataReceived);
+        
+    CFDataRef cfData = (CFDataRef)data->createNSData();
+    CGImageSourceUpdateData(m_decoder, cfData, allDataReceived);
+    CFRelease(cfData);
 }
 
 bool ImageSource::isSizeAvailable()
index 7e9f896..f3c12aa 100644 (file)
@@ -53,10 +53,12 @@ IntSize PDFDocumentImage::size() const
     return IntSize((int)m_mediaBox.size().width(), (int)m_mediaBox.size().height());
 }
 
-bool PDFDocumentImage::setNativeData(NativeBytePtr data, bool allDataReceived)
+bool PDFDocumentImage::dataChanged(bool allDataReceived)
 {
-    if (allDataReceived && !m_document && data) {
+    if (allDataReceived && !m_document) {
+        CFDataRef data = (CFDataRef)m_data->createNSData();
         CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data);
+        CFRelease(data);
         m_document = CGPDFDocumentCreateWithProvider(dataProvider);
         CGDataProviderRelease(dataProvider);
         setCurrentPage(0);
index 5bec1bf..caddc05 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
         PDFDocumentImage();
         ~PDFDocumentImage();
         
-        virtual bool setNativeData(NativeBytePtr, bool allDataReceived);
+        virtual bool dataChanged(bool allDataReceived);
 
         virtual IntSize size() const;
 
index 378c3c1..eb39d35 100644 (file)
@@ -64,7 +64,7 @@ Image* Image::loadPlatformResource(const char *name)
     NSData *namedImageData = [NSData dataWithContentsOfFile:imagePath];
     if (namedImageData) {
         Image* image = new BitmapImage;
-        image->setNativeData((CFDataRef)namedImageData, true);
+        image->setData(SharedBuffer::wrapNSData(namedImageData), true);
         return image;
     }
     return 0;
index 5dca240..8dc404a 100644 (file)
@@ -118,9 +118,9 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame()
 #endif
 }
 
-bool SVGImage::setData(bool allDataReceived)
+bool SVGImage::dataChanged(bool allDataReceived)
 {
-    int length = dataBuffer().size();
+    int length = m_data->size();
     if (!length) // if this was an empty image
         return true;
     
@@ -146,7 +146,7 @@ bool SVGImage::setData(bool allDataReceived)
         m_frame->loader()->commitProvisionalLoad(0);
         m_frame->loader()->setResponseMIMEType("image/svg+xml");
         m_frame->loader()->begin("placeholder.svg"); // create the empty document
-        m_frame->loader()->write(dataBuffer().data(), dataBuffer().size());
+        m_frame->loader()->write(m_data->data(), m_data->size());
         m_frame->loader()->end();
     }
     return m_frameView;
index c390492..270bda9 100644 (file)
@@ -47,8 +47,8 @@ namespace WebCore {
         
         virtual IntSize size() const;
         
-        virtual bool setData(bool allDataReceived);
-        
+        virtual bool dataChanged(bool allDataReceived);
+
         virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
         
 private:
index ed4eda9..b32de03 100644 (file)
@@ -247,7 +247,7 @@ void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame,
 
 static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *URL)
 {
-    SharedBuffer* coreData = resource->allData();
+    SharedBuffer* coreData = resource->data();
     NSData *data = [[[NSData alloc] initWithBytes:coreData->platformData() 
         length:coreData->platformDataSize()] autorelease];
     NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
index ec76a0f..d9d9083 100644 (file)
@@ -1,3 +1,14 @@
+2007-03-14  David Hyatt  <hyatt@apple.com>
+
+        Fixes to ensure that the resource loader's shared buffer can always be used.
+
+        Reviewed by olliej, mjs
+
+        * Misc/WebIconDatabase.mm:
+        (-[WebIconDatabase _convertToWebCoreFormat]):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::deliverArchivedResources):
+
 2007-03-13  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Brady.
index dd203b4..d40d5ef 100644 (file)
@@ -529,7 +529,7 @@ static NSData* iconDataFromPathForIconURL(NSString *databasePath, NSString *icon
     while ((url = [enumerator nextObject]) != nil) {
         iconData = iconDataFromPathForIconURL(databaseDirectory, url);
         if (iconData)
-            IconDatabase::sharedIconDatabase()->setIconDataForIconURL([iconData bytes], [iconData length], url);
+            IconDatabase::sharedIconDatabase()->setIconDataForIconURL(SharedBuffer::wrapNSData(iconData), url);
         else {
             // This really *shouldn't* happen, so it'd be good to track down why it might happen in a debug build
             // however, we do know how to handle it gracefully in release
index 12e8eab..2475742 100644 (file)
@@ -949,6 +949,7 @@ void WebFrameLoaderClient::deliverArchivedResources(Timer<WebFrameLoaderClient>*
         WebResource *resource = it->second.get();
         NSData *data = [[resource data] retain];
         loader->didReceiveResponse([resource _response]);
+        loader->addData((const char*)[data bytes], [data length], true);
         loader->didReceiveData((const char*)[data bytes], [data length], [data length], true);
         [data release];
         loader->didFinishLoading();