Changeset 20182 in webkit
- Timestamp:
- Mar 14, 2007, 1:07:59 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r20181 r20182 1 2007-03-13 David Hyatt <hyatt@apple.com> 2 3 Fix for bugzilla bug 13050 and also radar p1 5050645. 4 5 This patch reworks resource loading to avoid having redundant buffers in the icon database and in cached 6 images in the WebCore cache. It also avoids overcopying in top-level image documents and in the icon 7 database. 8 9 There is now only one SharedBuffer for a resource and everybody observes that buffer now instead of ever 10 making their own. Even ImageIO uses the SharedBuffer while decoding. 11 12 The page in 13050 dropped from 145mb down to 45mb of memory use with this change for a stunning savings 13 of 100mb. 14 15 Reviewed by olliej, mjs 16 17 * WebCore.exp: 18 * loader/CachedCSSStyleSheet.cpp: 19 (WebCore::CachedCSSStyleSheet::data): 20 * loader/CachedCSSStyleSheet.h: 21 * loader/CachedImage.cpp: 22 (WebCore::CachedImage::data): 23 * loader/CachedImage.h: 24 * loader/CachedResource.cpp: 25 (WebCore::CachedResource::CachedResource): 26 (WebCore::CachedResource::~CachedResource): 27 * loader/CachedResource.h: 28 (WebCore::CachedResource::data): 29 * loader/CachedScript.cpp: 30 (WebCore::CachedScript::data): 31 * loader/CachedScript.h: 32 * loader/CachedXSLStyleSheet.cpp: 33 (WebCore::CachedXSLStyleSheet::data): 34 * loader/CachedXSLStyleSheet.h: 35 * loader/DocLoader.cpp: 36 (WebCore::DocLoader::checkCacheObjectStatus): 37 * loader/ImageDocument.cpp: 38 (WebCore::ImageTokenizer::writeRawData): 39 (WebCore::ImageTokenizer::finish): 40 * loader/icon/IconDataCache.cpp: 41 (WebCore::IconDataCache::setImageData): 42 (WebCore::IconDataCache::writeToDatabase): 43 * loader/icon/IconDataCache.h: 44 * loader/icon/IconDatabase.cpp: 45 (WebCore::IconDatabase::imageDataForIconURL): 46 (WebCore::IconDatabase::iconForPageURL): 47 (WebCore::IconDatabase::setIconDataForIconURL): 48 (WebCore::IconDatabase::setHaveNoIconForIconURL): 49 (WebCore::IconDatabase::imageDataForIconURLQuery): 50 * loader/icon/IconDatabase.h: 51 * loader/icon/IconLoader.cpp: 52 (WebCore::IconLoader::startLoading): 53 (WebCore::IconLoader::didReceiveResponse): 54 (WebCore::IconLoader::didReceiveData): 55 (WebCore::IconLoader::didFail): 56 (WebCore::IconLoader::finishLoading): 57 (WebCore::IconLoader::clearLoadingState): 58 * loader/icon/IconLoader.h: 59 * loader/icon/SQLStatement.cpp: 60 (WebCore::SQLStatement::getColumnBlobAsVector): 61 (WebCore::SQLStatement::isExpired): 62 * loader/icon/SQLStatement.h: 63 * loader/loader.cpp: 64 (WebCore::Loader::didFinishLoading): 65 (WebCore::Loader::didReceiveData): 66 * page/mac/WebCoreFrameBridge.mm: 67 (-[WebCoreFrameBridge getData:andResponse:forURL:]): 68 (-[WebCoreFrameBridge getAllResourceDatas:andResponses:]): 69 * platform/SharedBuffer.h: 70 (WebCore::SharedBuffer::isEmpty): 71 * platform/graphics/BitmapImage.cpp: 72 (WebCore::BitmapImage::destroyDecodedData): 73 (WebCore::BitmapImage::dataChanged): 74 * platform/graphics/BitmapImage.h: 75 * platform/graphics/Image.cpp: 76 (WebCore::Image::setData): 77 * platform/graphics/Image.h: 78 (WebCore::Image::dataChanged): 79 (WebCore::Image::data): 80 * platform/graphics/ImageSource.h: 81 * platform/graphics/cg/ImageSourceCG.cpp: 82 (WebCore::ImageSource::setData): 83 * platform/graphics/cg/PDFDocumentImage.cpp: 84 (WebCore::PDFDocumentImage::dataChanged): 85 * platform/graphics/cg/PDFDocumentImage.h: 86 * platform/graphics/mac/ImageMac.mm: 87 (WebCore::Image::loadPlatformResource): 88 * platform/graphics/svg/SVGImage.cpp: 89 (WebCore::SVGImage::setData): 90 * platform/mac/PasteboardMac.mm: 91 (WebCore::fileWrapperForImage): 92 1 93 2007-03-13 Justin Garcia <justin.garcia@apple.com> 2 94 -
trunk/WebCore/WebCore.exp
r20173 r20182 220 220 __ZN7WebCore12IconDatabase20setIconURLForPageURLERKNS_6StringES3_ 221 221 __ZN7WebCore12IconDatabase21releaseIconForPageURLERKNS_6StringE 222 __ZN7WebCore12IconDatabase21setIconDataForIconURLE PKviRKNS_6StringE222 __ZN7WebCore12IconDatabase21setIconDataForIconURLEN3WTF10PassRefPtrINS_12SharedBufferEEERKNS_6StringE 223 223 __ZN7WebCore12IconDatabase23defaultDatabaseFilenameEv 224 224 __ZN7WebCore12IconDatabase23isIconExpiredForIconURLERKNS_6StringE -
trunk/WebCore/loader/CachedCSSStyleSheet.cpp
r20009 r20182 68 68 } 69 69 70 void CachedCSSStyleSheet::data( Vector<char>&data, bool allDataReceived)70 void CachedCSSStyleSheet::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) 71 71 { 72 72 if (!allDataReceived) 73 73 return; 74 74 75 setEncodedSize(data.size()); 76 m_sheet = m_decoder->decode(data.data(), encodedSize()); 75 m_data = data; 76 setEncodedSize(m_data.get() ? m_data->size() : 0); 77 if (!m_data.get()) 78 return; 79 80 m_sheet = m_decoder->decode(m_data->data(), encodedSize()); 77 81 m_sheet += m_decoder->flush(); 78 82 m_loading = false; -
trunk/WebCore/loader/CachedCSSStyleSheet.h
r19977 r20182 48 48 49 49 virtual void setEncoding(const String&); 50 virtual void data( Vector<char>&, bool allDataReceived);50 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived); 51 51 virtual void error(); 52 52 -
trunk/WebCore/loader/CachedImage.cpp
r20165 r20182 166 166 } 167 167 168 Vector<char>& CachedImage::bufferData(const char* bytes, int addedSize, Request* request) 169 { 170 createImage(); 171 172 Vector<char>& imageBuffer = m_image->dataBuffer(); 173 174 if (addedSize > 0) { 175 bool success = false; 176 unsigned oldSize = imageBuffer.size(); 177 unsigned newSize = oldSize + addedSize; 178 179 // Check for overflow 180 if (newSize > oldSize) { 181 // Use temporary Vector so we can safely detect if the allocation fails 182 // 183 // The code that was here before, just called resize of the imageBuffer. Vector<>::resize 184 // will crash if the resize of a non-empty Vector<> fails. 185 Vector<char> tempBuffer(newSize); 186 187 char* tempBufferBytes = tempBuffer.data(); 188 if (tempBufferBytes) { 189 memcpy(tempBufferBytes, imageBuffer.data(), oldSize); 190 memcpy(tempBufferBytes + oldSize, bytes, addedSize); 191 tempBuffer.swap(imageBuffer); 192 success = true; 193 } 194 } 195 196 if (!success) 197 error(); 198 } 199 200 return imageBuffer; 201 } 202 203 void CachedImage::data(Vector<char>& data, bool allDataReceived) 204 { 168 void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) 169 { 170 m_data = data; 171 205 172 createImage(); 206 173 … … 210 177 // It will not do anything now, but will delay decoding until 211 178 // queried for info (like size or specific image frames). 212 sizeAvailable = m_image->setData( allDataReceived);179 sizeAvailable = m_image->setData(m_data, allDataReceived); 213 180 214 181 // Go ahead and tell our observers to try to draw if we have either … … 227 194 notifyObservers(); 228 195 229 if (m_image) { 230 Vector<char>& imageBuffer = m_image->dataBuffer(); 231 #if PLATFORM(CG) 232 // ImageIO sources copy the image data. We will go ahead and count encoded 233 // size twice until this issue is fixed. See <rdar://problem/5050645> 234 setEncodedSize(imageBuffer.size() * 2); 235 #else 236 setEncodedSize(imageBuffer.size()); 237 #endif 238 } 196 if (m_image) 197 setEncodedSize(m_image->data() ? m_image->data()->size() : 0); 239 198 } 240 199 -
trunk/WebCore/loader/CachedImage.h
r20009 r20182 58 58 virtual void destroyDecodedData(); 59 59 60 virtual Vector<char>& bufferData(const char* bytes, int addedSize, Request*); 61 virtual void data(Vector<char>&, bool allDataReceived); 60 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived); 62 61 virtual void error(); 63 62 … … 84 83 85 84 Image* m_image; 86 int m_dataSize;87 85 88 86 friend class Cache; -
trunk/WebCore/loader/CachedResource.cpp
r20163 r20182 47 47 m_cachePolicy = cachePolicy; 48 48 m_request = 0; 49 m_allData = 0;50 49 m_expireDateChanged = false; 51 50 m_accessCount = 0; … … 67 66 m_deleted = true; 68 67 #endif 69 setAllData(0);70 }71 72 Vector<char>& CachedResource::bufferData(const char* bytes, int addedSize, Request* request)73 {74 // Add new bytes to the buffer in the Request object.75 Vector<char>& buffer = request->buffer();76 77 unsigned oldSize = buffer.size();78 buffer.resize(oldSize + addedSize);79 memcpy(buffer.data() + oldSize, bytes, addedSize);80 81 return buffer;82 68 } 83 69 -
trunk/WebCore/loader/CachedResource.h
r20009 r20182 72 72 73 73 virtual void setEncoding(const String&) { } 74 virtual Vector<char>& bufferData(const char* bytes, int addedSize, Request*); 75 virtual void data(Vector<char>&, bool allDataReceived) = 0; 74 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived) = 0; 76 75 virtual void error() = 0; 77 76 … … 114 113 void setRequest(Request*); 115 114 116 SharedBuffer* allData() const { return m_allData.get(); } 117 void setAllData(PassRefPtr<SharedBuffer> allData) { m_allData = allData; } 115 SharedBuffer* data() const { return m_data.get(); } 118 116 119 117 void setResponse(const ResourceResponse& response) { m_response = response; } … … 146 144 147 145 ResourceResponse m_response; 148 RefPtr<SharedBuffer> m_ allData;146 RefPtr<SharedBuffer> m_data; 149 147 150 148 Type m_type; -
trunk/WebCore/loader/CachedScript.cpp
r20009 r20182 71 71 } 72 72 73 void CachedScript::data( Vector<char>&data, bool allDataReceived)73 void CachedScript::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) 74 74 { 75 if (!allDataReceived )75 if (!allDataReceived || !data.get()) 76 76 return; 77 77 78 setEncodedSize(data.size()); 79 m_script = m_encoding.decode(data.data(), encodedSize()); 78 m_data = data; 79 setEncodedSize(m_data.get() ? m_data->size() : 0); 80 if (!m_data.get()) 81 return; 82 m_script = m_encoding.decode(m_data->data(), encodedSize()); 80 83 m_loading = false; 81 84 checkNotify(); -
trunk/WebCore/loader/CachedScript.h
r19952 r20182 46 46 47 47 virtual void setEncoding(const String&); 48 virtual void data( Vector<char>&, bool allDataReceived);48 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived); 49 49 virtual void error(); 50 50 -
trunk/WebCore/loader/CachedXSLStyleSheet.cpp
r20009 r20182 67 67 } 68 68 69 void CachedXSLStyleSheet::data( Vector<char>&data, bool allDataReceived)69 void CachedXSLStyleSheet::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) 70 70 { 71 if (!allDataReceived )71 if (!allDataReceived || !data.get()) 72 72 return; 73 73 74 setEncodedSize(data.size()); 75 m_sheet = String(m_decoder->decode(data.data(), encodedSize())); 74 m_data = data; 75 setEncodedSize(m_data.get() ? m_data->size() : 0); 76 if (!m_data.get()) 77 return; 78 m_sheet = String(m_decoder->decode(m_data->data(), encodedSize())); 76 79 m_sheet += m_decoder->flush(); 77 80 m_loading = false; -
trunk/WebCore/loader/CachedXSLStyleSheet.h
r19855 r20182 47 47 48 48 virtual void setEncoding(const String&); 49 virtual void data( Vector<char>&, bool allDataReceived);49 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived); 50 50 virtual void error(); 51 51 -
trunk/WebCore/loader/DocLoader.cpp
r19977 r20182 203 203 ResourceRequest request(resource->url()); 204 204 const ResourceResponse& response = resource->response(); 205 SharedBuffer* data = resource-> allData();205 SharedBuffer* data = resource->data(); 206 206 207 207 // FIXME: If the WebKit client changes or cancels the request, WebCore does not respect this and continues the load. -
trunk/WebCore/loader/ImageDocument.cpp
r19737 r20182 97 97 98 98 CachedImage* cachedImage = m_imageElement->cachedImage(); 99 cachedImage->data( cachedImage->bufferData(data, len, 0), false);99 cachedImage->data(m_doc->frame()->loader()->documentLoader()->mainResourceData(), false); 100 100 101 101 return false; … … 113 113 if (!m_parserStopped && m_imageElement) { 114 114 CachedImage* cachedImage = m_imageElement->cachedImage(); 115 Vector<char>& buffer = cachedImage->bufferData(0, 0, 0); 116 cachedImage->data(buffer, true); 115 cachedImage->data(m_doc->frame()->loader()->documentLoader()->mainResourceData(), true); 117 116 cachedImage->finish(); 118 117 119 cachedImage->setAllData(m_doc->frame()->loader()->documentLoader()->mainResourceData());120 118 cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response()); 121 119 -
trunk/WebCore/loader/icon/IconDataCache.cpp
r18446 r20182 61 61 } 62 62 63 void IconDataCache::setImageData( unsigned char* data, int size)63 void IconDataCache::setImageData(PassRefPtr<SharedBuffer> data) 64 64 { 65 if (!data)66 ASSERT(!size);67 68 65 // It's okay to delete the raw image data here. Any existing clients using this icon will be 69 66 // managing an image that was created with a copy of this raw image data. … … 72 69 m_image = new BitmapImage(); 73 70 74 // Copy the provided data into the buffer of the new Image object 75 Vector<char>& dataBuffer = m_image->dataBuffer(); 76 dataBuffer.resize(size); 77 memcpy(dataBuffer.data(), data, size); 78 79 // Tell the Image object that all of its data has been set 80 if (!m_image->setData(true)) { 71 // Copy the provided data into the buffer of the new Image object. 72 if (!m_image->setData(data, true)) { 81 73 LOG(IconDatabase, "Manual image data for iconURL '%s' FAILED - it was probably invalid image data", m_iconURL.ascii().data()); 82 74 delete m_image; … … 120 112 // If we *have* image data, bind it to this statement - Otherwise the DB will get "null" for the blob data, 121 113 // signifying that this icon doesn't have any data 122 if (m_image && !m_image->data Buffer().isEmpty())123 if (updateAttempt.bindBlob(2, m_image->data Buffer().data(), m_image->dataBuffer().size()) != SQLResultOk) {114 if (m_image && !m_image->data()->isEmpty()) 115 if (updateAttempt.bindBlob(2, m_image->data()->data(), m_image->data()->size()) != SQLResultOk) { 124 116 LOG_ERROR("Failed to bind icon data to SQL statement to update icon data for url %s", m_iconURL.ascii().data()); 125 117 return; … … 147 139 // Then, if we *have* data, we bind it. Otherwise the DB will get "null" for the blob data, 148 140 // signifying that this icon doesn't have any data 149 if (m_image && !m_image->data Buffer().isEmpty())150 insertStatement.bindBlob(3, m_image->data Buffer().data(), m_image->dataBuffer().size());141 if (m_image && !m_image->data()->isEmpty()) 142 insertStatement.bindBlob(3, m_image->data()->data(), m_image->data()->size()); 151 143 152 144 // Finally we step and make sure the step was successful -
trunk/WebCore/loader/icon/IconDataCache.h
r18874 r20182 33 33 class Image; 34 34 class IntSize; 35 class SharedBuffer; 35 36 class SQLDatabase; 36 37 … … 50 51 String getIconURL() { return m_iconURL; } 51 52 52 void setImageData( unsigned char* data, int size);53 void setImageData(PassRefPtr<SharedBuffer> data); 53 54 54 55 void loadImageFromResource(const char*); -
trunk/WebCore/loader/icon/IconDatabase.cpp
r17704 r20182 321 321 } 322 322 323 void IconDatabase::imageDataForIconURL(const String& iconURL, Vector<unsigned char>&result)323 void IconDatabase::imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result) 324 324 { 325 325 // If private browsing is enabled, we'll check there first as the most up-to-date data for an icon will be there 326 326 if (m_privateBrowsingEnabled) { 327 327 imageDataForIconURLQuery(m_privateBrowsingDB, iconURL, result); 328 if (!result .isEmpty())328 if (!result->isEmpty()) 329 329 return; 330 330 } … … 371 371 // we'll read in that image data now 372 372 if (icon->imageDataStatus() == ImageDataStatusUnknown) { 373 Vector<unsigned char> data;374 imageDataForIconURL(iconURL, data );375 icon->setImageData(data. data(), data.size());373 RefPtr<SharedBuffer> data = new SharedBuffer(); 374 imageDataForIconURL(iconURL, data.get()); 375 icon->setImageData(data.get()); 376 376 } 377 377 … … 641 641 } 642 642 643 void IconDatabase::setIconDataForIconURL(const void* data, int size, const String& iconURL) 644 { 645 ASSERT(size > -1); 643 void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String& iconURL) 644 { 646 645 if (!isOpen() || iconURL.isEmpty()) 647 646 return; 648 647 649 if (size)650 ASSERT(data);651 else652 data = 0;653 654 648 // Get the IconDataCache for this IconURL (note, IconDataCacheForIconURL will create it if necessary) 655 649 IconDataCache* icon = getOrCreateIconDataCache(iconURL); 656 650 657 651 // Set the data in the IconDataCache 658 icon->setImageData( (unsigned char*)data, size);652 icon->setImageData(data); 659 653 660 654 // Update the timestamp in the IconDataCache to NOW … … 667 661 void IconDatabase::setHaveNoIconForIconURL(const String& iconURL) 668 662 { 669 setIconDataForIconURL(0, 0,iconURL);663 setIconDataForIconURL(0, iconURL); 670 664 } 671 665 … … 956 950 } 957 951 958 void IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, Vector<unsigned char>&imageData)952 void IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> imageData) 959 953 { 960 954 readySQLStatement(m_imageDataForIconURLStatement, db, "SELECT Icon.data FROM Icon WHERE Icon.url = (?);"); … … 962 956 963 957 int result = m_imageDataForIconURLStatement->step(); 964 imageData.clear(); 965 if (result == SQLResultRow) 966 m_imageDataForIconURLStatement->getColumnBlobAsVector(0, imageData); 967 else if (result != SQLResultDone) 958 imageData->clear(); 959 if (result == SQLResultRow) { 960 Vector<char> data; 961 m_imageDataForIconURLStatement->getColumnBlobAsVector(0, data); 962 imageData->append(data.data(), data.size()); 963 } else if (result != SQLResultDone) 968 964 LOG_ERROR("imageDataForIconURLQuery failed"); 969 965 -
trunk/WebCore/loader/icon/IconDatabase.h
r18874 r20182 39 39 class IntSize; 40 40 class IconDataCache; 41 class SharedBuffer; 41 42 class SQLTransaction; 42 43 … … 68 69 bool isIconExpiredForIconURL(const String&); 69 70 70 void setIconDataForIconURL( const void* data, int size, const String&);71 void setIconDataForIconURL(PassRefPtr<SharedBuffer> data, const String&); 71 72 void setHaveNoIconForIconURL(const String&); 72 73 … … 122 123 123 124 // Returns the image data for the given IconURL, checking both databases if necessary 124 void imageDataForIconURL(const String& iconURL, Vector<unsigned char>&);125 void imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result); 125 126 126 127 // Retains an iconURL, bringing it back from the brink if it was pending deletion … … 162 163 163 164 // Query - Returns the image data from the given database for the given IconURL 164 void imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, Vector<unsigned char>&result);165 void imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> result); 165 166 SQLStatement* m_imageDataForIconURLStatement; 166 167 -
trunk/WebCore/loader/icon/IconLoader.cpp
r18047 r20182 42 42 namespace WebCore { 43 43 44 const size_t defaultBufferSize = 4096; // bigger than most icons45 46 44 IconLoader::IconLoader(Frame* frame) 47 45 : m_frame(frame) … … 75 73 // SubresourceLoader::create returns. 76 74 m_loadIsInProgress = true; 77 m_buffer.reserveCapacity(defaultBufferSize);78 75 79 76 RefPtr<SubresourceLoader> loader = SubresourceLoader::create(m_frame, this, m_frame->loader()->iconURL()); … … 100 97 if (status && (status < 200 || status > 299)) { 101 98 KURL iconURL = resourceLoader->handle()->url(); 99 finishLoading(iconURL); 102 100 m_resourceLoader = 0; 103 finishLoading(iconURL);104 101 } 105 102 } … … 107 104 void IconLoader::didReceiveData(SubresourceLoader*, const char* data, int size) 108 105 { 109 ASSERT(data || size == 0);110 ASSERT(size >= 0);111 m_buffer.append(data, size);112 106 } 113 107 … … 115 109 { 116 110 ASSERT(m_loadIsInProgress); 117 m_buffer.clear();118 111 finishLoading(resourceLoader->handle()->url()); 119 112 } … … 131 124 void IconLoader::finishLoading(const KURL& iconURL) 132 125 { 133 IconDatabase::sharedIconDatabase()->setIconDataForIconURL(m_ buffer.data(), m_buffer.size(), iconURL.url());126 IconDatabase::sharedIconDatabase()->setIconDataForIconURL(m_resourceLoader->resourceData(), iconURL.url()); 134 127 m_frame->loader()->commitIconURLToIconDatabase(iconURL); 135 128 m_frame->loader()->client()->dispatchDidReceiveIcon(); … … 140 133 { 141 134 m_resourceLoader = 0; 142 m_buffer.clear();143 135 m_loadIsInProgress = false; 144 136 } -
trunk/WebCore/loader/icon/IconLoader.h
r18874 r20182 31 31 #include <memory> 32 32 #include <wtf/Noncopyable.h> 33 #include <wtf/Vector.h>34 33 35 34 namespace WebCore { … … 59 58 60 59 RefPtr<SubresourceLoader> m_resourceLoader; 61 Vector<char> m_buffer;62 60 bool m_loadIsInProgress; 63 61 }; // class IconLoader -
trunk/WebCore/loader/icon/SQLStatement.cpp
r16595 r20182 231 231 } 232 232 233 void SQLStatement::getColumnBlobAsVector(int col, Vector< unsignedchar>& result)233 void SQLStatement::getColumnBlobAsVector(int col, Vector<char>& result) 234 234 { 235 235 if (!m_statement && prepareAndStep() != SQLITE_ROW) { -
trunk/WebCore/loader/icon/SQLStatement.h
r18874 r20182 80 80 int64_t getColumnInt64(int col); 81 81 const void* getColumnBlob(int col, int& size); 82 void getColumnBlobAsVector(int col, Vector< unsignedchar>&);82 void getColumnBlobAsVector(int col, Vector<char>&); 83 83 84 84 bool returnTextResults(int col, Vector<String>&); -
trunk/WebCore/loader/loader.cpp
r20178 r20182 105 105 106 106 docLoader->setLoadInProgress(true); 107 object->data(req->buffer(), true); 108 object->setAllData(loader->resourceData()); 107 object->data(loader->resourceData(), true); 109 108 docLoader->setLoadInProgress(false); 110 109 object->finish(); … … 168 167 169 168 CachedResource* object = request->cachedResource(); 170 Vector<char>& buffer = object->bufferData(data, size, request);171 169 172 170 // Set the data. 173 171 if (request->isMultipart()) 174 172 // The loader delivers the data in a multipart section all at once, send eof. 175 object->data( buffer, true);173 object->data(loader->resourceData(), true); 176 174 else if (request->isIncremental()) 177 object->data( buffer, false);175 object->data(loader->resourceData(), false); 178 176 } 179 177 -
trunk/WebCore/page/mac/WebCoreFrameBridge.mm
r20180 r20182 1409 1409 return NO; 1410 1410 1411 SharedBuffer* buffer = resource-> allData();1411 SharedBuffer* buffer = resource->data(); 1412 1412 if (buffer) 1413 1413 *data = [buffer->createNSData() autorelease]; … … 1436 1436 HashMap<String, CachedResource*>::const_iterator end = allResources.end(); 1437 1437 for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) { 1438 SharedBuffer* buffer = it->second-> allData();1438 SharedBuffer* buffer = it->second->data(); 1439 1439 NSData *data; 1440 1440 -
trunk/WebCore/platform/SharedBuffer.h
r19764 r20182 55 55 unsigned size() const; 56 56 57 bool isEmpty() const { return size() == 0; } 58 57 59 void append(const char*, int); 58 60 void clear(); -
trunk/WebCore/platform/graphics/BitmapImage.cpp
r20169 r20182 95 95 // while animating that it seems to never clear. 96 96 m_source.clear(); 97 setData(true);97 dataChanged(true); 98 98 } 99 99 } … … 138 138 } 139 139 140 bool BitmapImage:: setNativeData(NativeBytePtr data,bool allDataReceived)140 bool BitmapImage::dataChanged(bool allDataReceived) 141 141 { 142 142 destroyDecodedData(true); 143 143 144 144 // Feed all the data we've seen so far to the image decoder. 145 m_source.setData( data, allDataReceived);145 m_source.setData(m_data.get(), allDataReceived); 146 146 147 147 // Image properties will not be available until the first frame of the file -
trunk/WebCore/platform/graphics/BitmapImage.h
r20009 r20182 95 95 virtual IntSize size() const; 96 96 97 virtual bool setNativeData(NativeBytePtr,bool allDataReceived);97 virtual bool dataChanged(bool allDataReceived); 98 98 99 99 // It may look unusual that there is no start animation call as public API. This is because -
trunk/WebCore/platform/graphics/Image.cpp
r20009 r20182 60 60 } 61 61 62 bool Image::setData( bool allDataReceived)62 bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived) 63 63 { 64 int length = m_data.size(); 64 m_data = data; 65 if (!m_data.get()) 66 return true; 67 68 int length = m_data->size(); 65 69 if (!length) 66 70 return true; … … 76 80 #endif 77 81 78 #if PLATFORM(CG) 79 // Avoid the extra copy of bytes by just handing the byte array directly to a CFDataRef. 80 CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data.data()), length, kCFAllocatorNull); 81 bool result = setNativeData(data, allDataReceived); 82 CFRelease(data); 83 #else 84 bool result = setNativeData(&m_data, allDataReceived); 85 #endif 86 87 return result; 82 return dataChanged(allDataReceived); 88 83 } 89 84 -
trunk/WebCore/platform/graphics/Image.h
r20044 r20182 31 31 #include "GraphicsTypes.h" 32 32 #include "ImageSource.h" 33 #include <wtf/RefPtr.h> 34 #include <wtf/PassRefPtr.h> 35 #include "SharedBuffer.h" 33 36 34 37 #if PLATFORM(MAC) … … 61 64 class IntRect; 62 65 class IntSize; 66 class SharedBuffer; 63 67 class String; 64 68 … … 82 86 int height() const; 83 87 84 virtual bool setData(bool allDataReceived);85 virtual bool setNativeData(NativeBytePtr,bool allDataReceived) { return false; }88 bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived); 89 virtual bool dataChanged(bool allDataReceived) { return false; } 86 90 87 91 // FIXME: PDF/SVG will be underreporting decoded sizes and will be unable to prune because these functions are not … … 90 94 virtual unsigned decodedSize() const { return 0; } 91 95 92 Vector<char>& dataBuffer() { return m_data; }96 SharedBuffer* data() { return m_data.get(); } 93 97 94 98 // It may look unusual that there is no start animation call as public API. This is because … … 146 150 147 151 protected: 148 Vector<char> m_data; // The encoded raw data for the image.152 RefPtr<SharedBuffer> m_data; // The encoded raw data for the image. 149 153 ImageObserver* m_imageObserver; 150 154 }; -
trunk/WebCore/platform/graphics/ImageSource.h
r20070 r20182 44 44 45 45 class IntSize; 46 class SharedBuffer; 46 47 47 48 #if PLATFORM(CG) 48 49 typedef CGImageSourceRef NativeImageSourcePtr; 49 50 typedef CGImageRef NativeImagePtr; 50 typedef CFDataRef NativeBytePtr;51 51 #elif PLATFORM(QT) 52 52 class ImageDecoderQt; 53 53 typedef ImageDecoderQt* NativeImageSourcePtr; 54 typedef const Vector<char>* NativeBytePtr;55 54 typedef QPixmap* NativeImagePtr; 56 55 #else 57 56 class ImageDecoder; 58 57 typedef ImageDecoder* NativeImageSourcePtr; 59 typedef const Vector<char>* NativeBytePtr;60 58 typedef cairo_surface_t* NativeImagePtr; 61 59 #endif … … 73 71 bool initialized() const; 74 72 75 void setData( NativeBytePtr, bool allDataReceived);73 void setData(SharedBuffer* data, bool allDataReceived); 76 74 77 75 bool isSizeAvailable(); -
trunk/WebCore/platform/graphics/cg/ImageSourceCG.cpp
r20070 r20182 26 26 #include "config.h" 27 27 #include "ImageSource.h" 28 #include "SharedBuffer.h" 28 29 29 30 #if PLATFORM(CG) … … 72 73 } 73 74 74 void ImageSource::setData( NativeBytePtrdata, bool allDataReceived)75 void ImageSource::setData(SharedBuffer* data, bool allDataReceived) 75 76 { 76 77 if (!m_decoder) 77 78 m_decoder = CGImageSourceCreateIncremental(NULL); 78 CGImageSourceUpdateData(m_decoder, data, allDataReceived); 79 80 CFDataRef cfData = (CFDataRef)data->createNSData(); 81 CGImageSourceUpdateData(m_decoder, cfData, allDataReceived); 82 CFRelease(cfData); 79 83 } 80 84 -
trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
r18904 r20182 54 54 } 55 55 56 bool PDFDocumentImage:: setNativeData(NativeBytePtr data,bool allDataReceived)56 bool PDFDocumentImage::dataChanged(bool allDataReceived) 57 57 { 58 if (allDataReceived && !m_document && data) { 58 if (allDataReceived && !m_document) { 59 CFDataRef data = (CFDataRef)m_data->createNSData(); 59 60 CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data); 61 CFRelease(data); 60 62 m_document = CGPDFDocumentCreateWithProvider(dataProvider); 61 63 CGDataProviderRelease(dataProvider); -
trunk/WebCore/platform/graphics/cg/PDFDocumentImage.h
r18904 r20182 42 42 ~PDFDocumentImage(); 43 43 44 virtual bool setNativeData(NativeBytePtr,bool allDataReceived);44 virtual bool dataChanged(bool allDataReceived); 45 45 46 46 virtual IntSize size() const; -
trunk/WebCore/platform/graphics/mac/ImageMac.mm
r18446 r20182 65 65 if (namedImageData) { 66 66 Image* image = new BitmapImage; 67 image->set NativeData((CFDataRef)namedImageData, true);67 image->setData(SharedBuffer::wrapNSData(namedImageData), true); 68 68 return image; 69 69 } -
trunk/WebCore/platform/graphics/svg/SVGImage.cpp
r20009 r20182 119 119 } 120 120 121 bool SVGImage:: setData(bool allDataReceived)121 bool SVGImage::dataChanged(bool allDataReceived) 122 122 { 123 int length = dataBuffer().size();123 int length = m_data->size(); 124 124 if (!length) // if this was an empty image 125 125 return true; … … 147 147 m_frame->loader()->setResponseMIMEType("image/svg+xml"); 148 148 m_frame->loader()->begin("placeholder.svg"); // create the empty document 149 m_frame->loader()->write( dataBuffer().data(), dataBuffer().size());149 m_frame->loader()->write(m_data->data(), m_data->size()); 150 150 m_frame->loader()->end(); 151 151 } -
trunk/WebCore/platform/graphics/svg/SVGImage.h
r20009 r20182 48 48 virtual IntSize size() const; 49 49 50 virtual bool setData(bool allDataReceived);51 50 virtual bool dataChanged(bool allDataReceived); 51 52 52 virtual NativeImagePtr frameAtIndex(size_t) { return 0; } 53 53 -
trunk/WebCore/platform/mac/PasteboardMac.mm
r20130 r20182 248 248 static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *URL) 249 249 { 250 SharedBuffer* coreData = resource-> allData();250 SharedBuffer* coreData = resource->data(); 251 251 NSData *data = [[[NSData alloc] initWithBytes:coreData->platformData() 252 252 length:coreData->platformDataSize()] autorelease]; -
trunk/WebKit/ChangeLog
r20180 r20182 1 2007-03-14 David Hyatt <hyatt@apple.com> 2 3 Fixes to ensure that the resource loader's shared buffer can always be used. 4 5 Reviewed by olliej, mjs 6 7 * Misc/WebIconDatabase.mm: 8 (-[WebIconDatabase _convertToWebCoreFormat]): 9 * WebCoreSupport/WebFrameLoaderClient.mm: 10 (WebFrameLoaderClient::deliverArchivedResources): 11 1 12 2007-03-13 Oliver Hunt <oliver@apple.com> 2 13 -
trunk/WebKit/Misc/WebIconDatabase.mm
r19921 r20182 530 530 iconData = iconDataFromPathForIconURL(databaseDirectory, url); 531 531 if (iconData) 532 IconDatabase::sharedIconDatabase()->setIconDataForIconURL( [iconData bytes], [iconData length], url);532 IconDatabase::sharedIconDatabase()->setIconDataForIconURL(SharedBuffer::wrapNSData(iconData), url); 533 533 else { 534 534 // This really *shouldn't* happen, so it'd be good to track down why it might happen in a debug build -
trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm
r20173 r20182 950 950 NSData *data = [[resource data] retain]; 951 951 loader->didReceiveResponse([resource _response]); 952 loader->addData((const char*)[data bytes], [data length], true); 952 953 loader->didReceiveData((const char*)[data bytes], [data length], [data length], true); 953 954 [data release];
Note:
See TracChangeset
for help on using the changeset viewer.