WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2007 19:33:24 +0000 (19:33 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2007 19:33:24 +0000 (19:33 +0000)
        Reviewed by Maciej.

        Add a shared buffer class which is backed by either a vector or an NSData object. This object can also
        be held in a custom NSData subclass. Use this in the loader wherever NSData was used.

        * WebCore.exp:
        * WebCore.xcodeproj/project.pbxproj:
        * loader/CachedResource.h:
        (WebCore::CachedResource::allData):
        * loader/DocumentLoader.h:
        * loader/FrameLoader.h:
        * loader/ResourceLoader.h:
        * loader/SubresourceLoaderClient.h:
        (WebCore::SubresourceLoaderClient::didFail):
        * loader/loader.cpp:
        (WebCore::Loader::didFinishLoading):
        * loader/loader.h:
        * loader/mac/DocumentLoaderMac.mm:
        (WebCore::DocumentLoader::setMainResourceData):
        (WebCore::DocumentLoader::mainResourceData):
        (WebCore::DocumentLoader::setupForReplaceByMIMEType):
        * loader/mac/FrameLoaderMac.mm:
        (WebCore::FrameLoader::mainResourceData):
        * loader/mac/ImageDocumentMac.mm:
        (WebCore::finishImageLoad):
        * loader/mac/LoaderFunctionsMac.mm:
        (WebCore::CheckCacheObjectStatus):
        (WebCore::CachedResource::setAllData):
        * loader/mac/NetscapePlugInStreamLoaderMac.mm:
        (WebCore::NetscapePlugInStreamLoader::didFinishLoading):
        * loader/mac/ResourceLoaderMac.mm:
        (WebCore::ResourceLoader::addData):
        (WebCore::ResourceLoader::resourceData):
        (WebCore::ResourceLoader::clearResourceData):
        (WebCore::ResourceLoader::didReceiveData):
        (WebCore::ResourceLoader::willStopBufferingData):
        * loader/mac/SubresourceLoaderMac.mm:
        (WebCore::SubresourceLoader::didReceiveResponse):
        (WebCore::SubresourceLoader::didFinishLoading):
        * page/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge getData:andResponse:forURL:]):
        (-[WebCoreFrameBridge getAllResourceDatas:andResponses:]):
        * platform/KURL.h:
        * platform/SharedBuffer.cpp: Added.
        (WebCore::SharedBuffer::SharedBuffer):
        (WebCore::SharedBuffer::size):
        (WebCore::SharedBuffer::data):
        (WebCore::SharedBuffer::append):
        (WebCore::SharedBuffer::clear):
        (WebCore::SharedBuffer::clearPlatformData):
        (WebCore::SharedBuffer::maybeTransferPlatformData):
        (WebCore::SharedBuffer::hasPlatformData):
        (WebCore::SharedBuffer::platformData):
        * platform/SharedBuffer.h: Added.
        * platform/mac/SharedBufferMac.mm: Added.
        (-[SharedBufferData dealloc]):
        (-[SharedBufferData finalize]):
        (-[SharedBufferData initWithSharedBuffer:WebCore::]):
        (-[SharedBufferData length]):
        (-[SharedBufferData bytes]):
        (WebCore::SharedBuffer::wrapNSData):
        (WebCore::SharedBuffer::SharedBuffer):
        (WebCore::SharedBuffer::createNSData):
        (WebCore::SharedBuffer::hasPlatformData):
        (WebCore::SharedBuffer::platformData):
        (WebCore::SharedBuffer::platformDataSize):
        (WebCore::SharedBuffer::maybeTransferPlatformData):
        (WebCore::SharedBuffer::clearPlatformData):
        * platform/network/ResourceHandle.h:
        * platform/network/ResourceHandleClient.h:
        * platform/network/mac/ResourceHandleMac.mm:
        (WebCore::ResourceHandle::bufferedData):

WebKit:

        Reviewed by Maciej.

        The data returned is now a SharedBuffer so wrap it in an NSData object.

        * WebView/WebDataSource.mm:
        (-[WebDataSource data]):

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

27 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/CachedResource.h
WebCore/loader/DocumentLoader.h
WebCore/loader/FrameLoader.h
WebCore/loader/ResourceLoader.h
WebCore/loader/SubresourceLoaderClient.h
WebCore/loader/loader.cpp
WebCore/loader/loader.h
WebCore/loader/mac/DocumentLoaderMac.mm
WebCore/loader/mac/FrameLoaderMac.mm
WebCore/loader/mac/ImageDocumentMac.mm
WebCore/loader/mac/LoaderFunctionsMac.mm
WebCore/loader/mac/NetscapePlugInStreamLoaderMac.mm
WebCore/loader/mac/ResourceLoaderMac.mm
WebCore/loader/mac/SubresourceLoaderMac.mm
WebCore/page/mac/WebCoreFrameBridge.mm
WebCore/platform/KURL.h
WebCore/platform/SharedBuffer.cpp [new file with mode: 0644]
WebCore/platform/SharedBuffer.h [new file with mode: 0644]
WebCore/platform/mac/SharedBufferMac.mm [new file with mode: 0644]
WebCore/platform/network/ResourceHandle.h
WebCore/platform/network/ResourceHandleClient.h
WebCore/platform/network/mac/ResourceHandleMac.mm
WebKit/ChangeLog
WebKit/WebView/WebDataSource.mm

index 2ef24b1459048d1118fedd9667d59526d2241d3e..319a09543b80e4c8a106683923ed13f414f9bd7e 100644 (file)
@@ -1,3 +1,78 @@
+2007-01-05  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        Add a shared buffer class which is backed by either a vector or an NSData object. This object can also
+        be held in a custom NSData subclass. Use this in the loader wherever NSData was used.
+        
+        * WebCore.exp:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/CachedResource.h:
+        (WebCore::CachedResource::allData):
+        * loader/DocumentLoader.h:
+        * loader/FrameLoader.h:
+        * loader/ResourceLoader.h:
+        * loader/SubresourceLoaderClient.h:
+        (WebCore::SubresourceLoaderClient::didFail):
+        * loader/loader.cpp:
+        (WebCore::Loader::didFinishLoading):
+        * loader/loader.h:
+        * loader/mac/DocumentLoaderMac.mm:
+        (WebCore::DocumentLoader::setMainResourceData):
+        (WebCore::DocumentLoader::mainResourceData):
+        (WebCore::DocumentLoader::setupForReplaceByMIMEType):
+        * loader/mac/FrameLoaderMac.mm:
+        (WebCore::FrameLoader::mainResourceData):
+        * loader/mac/ImageDocumentMac.mm:
+        (WebCore::finishImageLoad):
+        * loader/mac/LoaderFunctionsMac.mm:
+        (WebCore::CheckCacheObjectStatus):
+        (WebCore::CachedResource::setAllData):
+        * loader/mac/NetscapePlugInStreamLoaderMac.mm:
+        (WebCore::NetscapePlugInStreamLoader::didFinishLoading):
+        * loader/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::addData):
+        (WebCore::ResourceLoader::resourceData):
+        (WebCore::ResourceLoader::clearResourceData):
+        (WebCore::ResourceLoader::didReceiveData):
+        (WebCore::ResourceLoader::willStopBufferingData):
+        * loader/mac/SubresourceLoaderMac.mm:
+        (WebCore::SubresourceLoader::didReceiveResponse):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        * page/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge getData:andResponse:forURL:]):
+        (-[WebCoreFrameBridge getAllResourceDatas:andResponses:]):
+        * platform/KURL.h:
+        * platform/SharedBuffer.cpp: Added.
+        (WebCore::SharedBuffer::SharedBuffer):
+        (WebCore::SharedBuffer::size):
+        (WebCore::SharedBuffer::data):
+        (WebCore::SharedBuffer::append):
+        (WebCore::SharedBuffer::clear):
+        (WebCore::SharedBuffer::clearPlatformData):
+        (WebCore::SharedBuffer::maybeTransferPlatformData):
+        (WebCore::SharedBuffer::hasPlatformData):
+        (WebCore::SharedBuffer::platformData):
+        * platform/SharedBuffer.h: Added.
+        * platform/mac/SharedBufferMac.mm: Added.
+        (-[SharedBufferData dealloc]):
+        (-[SharedBufferData finalize]):
+        (-[SharedBufferData initWithSharedBuffer:WebCore::]):
+        (-[SharedBufferData length]):
+        (-[SharedBufferData bytes]):
+        (WebCore::SharedBuffer::wrapNSData):
+        (WebCore::SharedBuffer::SharedBuffer):
+        (WebCore::SharedBuffer::createNSData):
+        (WebCore::SharedBuffer::hasPlatformData):
+        (WebCore::SharedBuffer::platformData):
+        (WebCore::SharedBuffer::platformDataSize):
+        (WebCore::SharedBuffer::maybeTransferPlatformData):
+        (WebCore::SharedBuffer::clearPlatformData):
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleClient.h:
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::bufferedData):
+
 2007-01-05  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Adam.
index 06ba62373f6b6fff2abefefa7f40d50f1d629f04..cb59b5abb15899384a1cfd9dbca6b8de5bb61ad9 100644 (file)
@@ -217,6 +217,7 @@ __ZN7WebCore12IconDatabase25setPrivateBrowsingEnabledEb
 __ZN7WebCore12IconDatabase4openERKNS_6StringE
 __ZN7WebCore12IconDatabase5closeEv
 __ZN7WebCore12IconDatabase7isEmptyEv
+__ZN7WebCore12SharedBuffer12createNSDataEv
 __ZN7WebCore13HitTestResultC1ERKS0_
 __ZN7WebCore13HitTestResultD1Ev
 __ZN7WebCore13KeyboardEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowERKNS_6StringEjbbbbb
index fd965bcd0172a428e4cd16d2cb7f676b834da136..bc26990bff3df4a22162b36b0fd458aa0854b741 100644 (file)
@@ -87,6 +87,9 @@
                1A4A2DF00A1B852A00C807F8 /* JSHTMLAnchorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A2DEC0A1B852A00C807F8 /* JSHTMLAnchorElement.h */; };
                1A4A2DF10A1B852A00C807F8 /* JSHTMLAppletElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A2DED0A1B852A00C807F8 /* JSHTMLAppletElement.cpp */; };
                1A4A2DF20A1B852A00C807F8 /* JSHTMLAppletElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A2DEE0A1B852A00C807F8 /* JSHTMLAppletElement.h */; };
+               1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */; };
+               1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               1A4A95520B4EDCFF002D8C3C /* SharedBufferMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A95510B4EDCFF002D8C3C /* SharedBufferMac.mm */; };
                1A6938010A11100A00C127FE /* TextDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6937FF0A11100A00C127FE /* TextDocument.cpp */; };
                1A6938020A11100A00C127FE /* TextDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6938000A11100A00C127FE /* TextDocument.h */; };
                1A750D5C0A90DEE1000FF215 /* JSTreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A750D5A0A90DEE1000FF215 /* JSTreeWalker.cpp */; };
                1A4A2DEC0A1B852A00C807F8 /* JSHTMLAnchorElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLAnchorElement.h; sourceTree = "<group>"; };
                1A4A2DED0A1B852A00C807F8 /* JSHTMLAppletElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAppletElement.cpp; sourceTree = "<group>"; };
                1A4A2DEE0A1B852A00C807F8 /* JSHTMLAppletElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLAppletElement.h; sourceTree = "<group>"; };
+               1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBuffer.cpp; sourceTree = "<group>"; };
+               1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SharedBuffer.h; sourceTree = "<group>"; };
+               1A4A95510B4EDCFF002D8C3C /* SharedBufferMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SharedBufferMac.mm; sourceTree = "<group>"; };
                1A6937FF0A11100A00C127FE /* TextDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TextDocument.cpp; sourceTree = "<group>"; };
                1A6938000A11100A00C127FE /* TextDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TextDocument.h; sourceTree = "<group>"; };
                1A750D3C0A90DE35000FF215 /* TreeWalker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TreeWalker.idl; sourceTree = "<group>"; };
                                BCAA90C20A7EBA60008B1229 /* ScrollBar.cpp */,
                                9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
                                AB71709F0B31193B0017123E /* SearchPopupMenuMac.mm */,
+                               1A4A95510B4EDCFF002D8C3C /* SharedBufferMac.mm */,
                                93309E9F099EB78C0056E581 /* SharedTimerMac.cpp */,
                                4B3043C80AE0371D00A82647 /* SoundMac.mm */,
                                84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */,
                                BCFB2F3F097A24B500BA703D /* SegmentedString.cpp */,
                                BCFB2F40097A24B500BA703D /* SegmentedString.h */,
                                BCFB2E830979FD4F00BA703D /* Shared.h */,
+                               1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */,
+                               1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */,
                                93309EA0099EB78C0056E581 /* SharedTimer.h */,
                                4B3043C60AE0370300A82647 /* Sound.h */,
                                F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */,
                                B25AE5600B49D6630074C726 /* RadialGradientAttributes.h in Headers */,
                                A82422700B4A16C50084722B /* SVGAnimateMotionElement.h in Headers */,
                                062287840B4DB322000C34DF /* FocusDirection.h in Headers */,
+                               1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A88DD4890B4629B000C02990 /* PathTraversalState.cpp in Sources */,
                                A8241D8C0B48D31E0084722B /* SVGTimer.cpp in Sources */,
                                A82422710B4A16C50084722B /* SVGAnimateMotionElement.cpp in Sources */,
+                               1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */,
+                               1A4A95520B4EDCFF002D8C3C /* SharedBufferMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index aa820dd5b9e19013a68b69df0981dad03776c3c5..f4288e6a5df2b8b1b47e2cd3717930f24e358612 100644 (file)
@@ -30,8 +30,8 @@
 
 #include "CachePolicy.h"
 #include "PlatformString.h"
-#include "ResourceHandleClient.h" // defines PlatformData
 #include "ResourceResponse.h"
+#include "SharedBuffer.h"
 #include <wtf/HashSet.h>
 #include <wtf/Vector.h>
 #include <time.h>
@@ -121,8 +121,8 @@ public:
 
     void setRequest(Request*);
 
-    PlatformData allData() const { return m_allData; }
-    void setAllData(PlatformData);
+    SharedBuffer* allData() const { return m_allData.get(); }
+    void setAllData(PassRefPtr<SharedBuffer>);
 
     void setResponse(const ResourceResponse& response) { m_response = response; }
     const ResourceResponse& response() const { return m_response; }
@@ -156,7 +156,7 @@ protected:
 #endif
 
     ResourceResponse m_response;
-    PlatformData m_allData;
+    RefPtr<SharedBuffer> m_allData;
 
     Type m_type;
     Status m_status;
index c4e88188ec08d75357f3b31365f2ef253966959c..64f13cbb1b7e033f19e740995bdfc15e86e76e90 100644 (file)
@@ -55,6 +55,7 @@ namespace WebCore {
     class HistoryItem;
     class KURL;
     class PageCache;
+    class SharedBuffer;
 
     typedef Vector<ResourceResponse> ResponseVector;
 
@@ -69,7 +70,7 @@ namespace WebCore {
 
         FrameLoader* frameLoader() const;
 #if PLATFORM(MAC)
-        NSData *mainResourceData() const;
+        PassRefPtr<SharedBuffer> mainResourceData() const;
 #endif
 
         const ResourceRequest& originalRequest() const;
@@ -137,7 +138,7 @@ namespace WebCore {
         
     private:
 #if PLATFORM(MAC)
-        void setMainResourceData(NSData *);
+        void setMainResourceData(PassRefPtr<SharedBuffer>);
 #endif
         void setupForReplace();
         void commitIfReady();
@@ -151,7 +152,7 @@ namespace WebCore {
         Frame* m_frame;
 
 #if PLATFORM(MAC)
-        RetainPtr<NSData> m_mainResourceData;
+        RefPtr<SharedBuffer> m_mainResourceData;
 #endif
 
         // A reference to actual request used to create the data source.
index fae3041709d9f50451072f27afcba2f7c9401c7e..7e798c19863163ab887deffe92fcf2588d64f7de 100644 (file)
@@ -48,12 +48,10 @@ typedef struct objc_object* id;
 
 #ifdef __OBJC__
 
-@class NSData;
 @class NSURLAuthenticationChallenge;
 
 #else
 
-class NSData;
 class NSURLAuthenticationChallenge;
 
 #endif // __OBJC__
@@ -87,6 +85,7 @@ namespace WebCore {
     class ResourceLoader;
     class ResourceRequest;
     class ResourceResponse;
+    class SharedBuffer;
     class SubresourceLoader;
     class TextResourceDecoder;
     class Widget;
@@ -196,7 +195,7 @@ namespace WebCore {
         void addSubresourceLoader(ResourceLoader*);
         void removeSubresourceLoader(ResourceLoader*);
 #if PLATFORM(MAC)
-        NSData *mainResourceData() const;
+        PassRefPtr<SharedBuffer> mainResourceData() const;
 #endif
         void releaseMainResourceLoader();
 
index 35ce448d2c1dc9fc09f4f1baee10a4e9730986a1..ab9440837ec3ee3118407b8626834642bb9ac96a 100644 (file)
@@ -36,7 +36,7 @@
 #include "Shared.h"
 #include "KURL.h"
 
-#include <wtf/RefPtr.h>
+#include <wtf/Forward.h>
 
 #if PLATFORM(MAC)
 
@@ -48,7 +48,6 @@
 @class NSURLAuthenticationChallenge;
 #else
 class NSCachedURLResponse;
-class NSData;
 class NSMutableData;
 class NSURLAuthenticationChallenge;
 class NSURLCredential;
@@ -61,6 +60,7 @@ namespace WebCore {
     class Frame;
     class FrameLoader;
     class ResourceHandle;
+    class SharedBuffer;
     
     class ResourceLoader : public Shared<ResourceLoader>, protected ResourceHandleClient {
     public:
@@ -87,7 +87,7 @@ namespace WebCore {
         const ResourceResponse& response() const;
 
         virtual void addData(const char*, int, bool allAtOnce);
-        virtual NSData *resourceData();
+        virtual PassRefPtr<SharedBuffer> resourceData();
         void clearResourceData();
 
         virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
@@ -160,7 +160,7 @@ protected:
         NSURLAuthenticationChallenge *m_currentConnectionChallenge;
         RetainPtr<NSURLAuthenticationChallenge> m_currentWebChallenge;
         KURL m_originalURL;
-        RetainPtr<NSMutableData> m_resourceData;
+        RefPtr<SharedBuffer> m_resourceData;
 #endif
         bool m_defersLoading;
     };
index 430ffa4041eab0ec0e335b096b9c08e6a5336489..9c2314649253eb742c05a5d0c96633eb2adfe172 100644 (file)
 #ifndef SubresourceLoaderClient_h
 #define SubresourceLoaderClient_h
 
-// FIXME: This is just to define PlatformData, it should go away
-#include "ResourceHandleClient.h"
-
 namespace WebCore {
 
+class ResourceError;
 class ResourceRequest;
 class ResourceResponse;
 class SubresourceLoader;
@@ -49,9 +47,6 @@ public:
     virtual void didReceiveData(SubresourceLoader*, const char*, int) { }
     virtual void didFinishLoading(SubresourceLoader*) { }
     virtual void didFail(SubresourceLoader*, const ResourceError&) { }
-    
-    // FIXME: Get rid of this function
-    virtual void receivedAllData(SubresourceLoader*, PlatformData) { }
 };
 
 }
index 61fa4d999e581c61d8a6a48a692fee8c8653864a..d42ad46802848d1be5c05bd190c8b8e1ea98f76a 100644 (file)
@@ -92,7 +92,7 @@ void Loader::servePendingRequests()
         m_requestsLoading.add(loader.release(), req);
 }
 
-void Loader::receivedAllData(SubresourceLoader* loader, PlatformData allData)
+void Loader::didFinishLoading(SubresourceLoader* loader)
 {
     RequestMap::iterator i = m_requestsLoading.find(loader);
     if (i == m_requestsLoading.end())
@@ -106,7 +106,7 @@ void Loader::receivedAllData(SubresourceLoader* loader, PlatformData allData)
 
     docLoader->setLoadInProgress(true);
     object->data(req->buffer(), true);
-    object->setAllData(allData);
+    object->setAllData(loader->resourceData());
     docLoader->setLoadInProgress(false);
     object->finish();
 
index 470c437795262561938b63562f4097e283d67af1..7f5d0aef5d6315cdcc8f0bacc0ee5578d35365e7 100644 (file)
@@ -59,7 +59,7 @@ namespace WebCore {
     private:
         virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
         virtual void didReceiveData(SubresourceLoader*, const char*, int);
-        virtual void receivedAllData(SubresourceLoader*, PlatformData);
+        virtual void didFinishLoading(SubresourceLoader*);
         virtual void didFail(SubresourceLoader*, const ResourceError&);
 
         void servePendingRequests();
index 397623027f409418a78efd7797c045fc9b648e0a..b619f97ca99e3630eecebf3500a66f48544df333 100644 (file)
@@ -36,6 +36,7 @@
 #import "HistoryItem.h"
 #import "PageCache.h"
 #import "PlatformString.h"
+#import "SharedBuffer.h"
 #import "WebCoreSystemInterface.h"
 #import "WebDataProtocol.h"
 #import "XMLTokenizer.h"
@@ -130,12 +131,12 @@ DocumentLoader::~DocumentLoader()
     ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading());
 }
 
-void DocumentLoader::setMainResourceData(NSData *data)
+void DocumentLoader::setMainResourceData(PassRefPtr<SharedBuffer> data)
 {
     m_mainResourceData = data;
 }
 
-NSData *DocumentLoader::mainResourceData() const
+PassRefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
 {
     return m_mainResourceData ? m_mainResourceData.get() : frameLoader()->mainResourceData();
 }
@@ -363,7 +364,8 @@ void DocumentLoader::setupForReplaceByMIMEType(const String& newMIMEType)
     if (!doesProgressiveLoad(oldMIMEType)) {
         frameLoader()->revertToProvisional(this);
         setupForReplace();
-        commitLoad((const char*)[mainResourceData() bytes], [mainResourceData() length]);
+        RefPtr<SharedBuffer> resourceData = mainResourceData();
+        commitLoad(resourceData->data(), resourceData->size());
     }
     
     frameLoader()->finishedLoadingDocument(this);
index 5361052ff29a2ceee30467c1bad16f6acf4ab8cd..1bddb2e08dbe48777e7c1f276b524d3ccbc86d86 100644 (file)
@@ -61,6 +61,7 @@
 #import "ResourceHandle.h"
 #import "ResourceRequest.h"
 #import "ResourceResponse.h"
+#import "SharedBuffer.h"
 #import "Settings.h"
 #import "SubresourceLoader.h"
 #import "SystemTime.h"
@@ -1194,10 +1195,10 @@ String FrameLoader::overrideMediaType() const
     return String();
 }
 
-NSData *FrameLoader::mainResourceData() const
+PassRefPtr<SharedBuffer> FrameLoader::mainResourceData() const
 {
     if (!m_mainResourceLoader)
-        return nil;
+        return 0;
     return m_mainResourceLoader->resourceData();
 }
 
index a8c353a48000b767b394d47338853c4de825fa75..2257f9a8507aaa884d7b102a69cf24111c35bf98 100644 (file)
@@ -39,9 +39,7 @@ void finishImageLoad(Document* document, CachedImage* image, const void* imageDa
     // FIXME: This is terrible! Makes an extra copy of the image data!
     // Can't we get the NSData from NSURLConnection?
     // Why is this different from image subresources?
-    NSData* nsData = [[NSData alloc] initWithBytes:imageData length:imageDataSize];
-    image->setAllData(nsData);
-    [nsData release];
+    RefPtr<SharedBuffer> buffer = new SharedBuffer(reinterpret_cast<const char*>(imageData), imageDataSize);
 
     Frame* frame = document->frame();
     const ResourceResponse& response = frame->loader()->documentLoader()->response();
index 77f26f80df2070b414b9ec9d0ee936bc4ff22f86..6cb62067ce54a9b01b97a34e62ee29cb107e07ba 100644 (file)
@@ -74,21 +74,16 @@ void CheckCacheObjectStatus(DocLoader *loader, CachedResource *cachedResource)
         
     NSURLRequest *request = cachedResource->getNSURLRequest();
     const ResourceResponse& response = cachedResource->response();
-    NSData *data = cachedResource->allData();
+    RefPtr<SharedBuffer> data = cachedResource->allData();
     
     // FIXME: If the WebKit client changes or cancels the request, WebCore does not respect this and continues the load.
-    frame->loader()->loadedResourceFromMemoryCache(request, response, [data length]);
+    frame->loader()->loadedResourceFromMemoryCache(request, response, data->size());
     
     frame->loader()->didTellBridgeAboutLoad(cachedResource->url());
 }
 
-void CachedResource::setAllData(PlatformData allData)
+void CachedResource::setAllData(PassRefPtr<SharedBuffer> allData)
 {
-    HardRetain(allData);
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    HardRelease(m_allData);
-    END_BLOCK_OBJC_EXCEPTIONS;
-
     m_allData = allData;
 }
 
index 9333e6a75eb6446f55900b1ac74168c70512c814..3faa5806416d096210e1499cd09d9d23b718c123 100644 (file)
@@ -32,6 +32,7 @@
 #import "FrameLoader.h"
 #import "ResourceError.h"
 #import "ResourceResponse.h"
+#import "SharedBuffer.h"
 #import <wtf/PassRefPtr.h>
 
 namespace WebCore {
@@ -104,7 +105,9 @@ void NetscapePlugInStreamLoader::didFinishLoading()
     RefPtr<NetscapePlugInStreamLoader> protect(this);
 
     frameLoader()->removePlugInStreamLoader(this);
-    [m_stream.get() finishedLoadingWithData:resourceData()];
+    NSData *data = resourceData()->createNSData();
+    [m_stream.get() finishedLoadingWithData:data];
+    [data release];
     ResourceLoader::didFinishLoading();
 }
 
index ef1e69da592635319eb779bd41ebd92aa5ccda94..f21825dc82398107949b67287969cdc63118f5e5 100644 (file)
@@ -36,6 +36,7 @@
 #import "ResourceHandle.h"
 #import "ResourceRequest.h"
 #import "ResourceResponse.h"
+#import "SharedBuffer.h"
 #import "WebCoreSystemInterface.h"
 #import "WebDataProtocol.h"
 #import <Foundation/NSURLAuthenticationChallenge.h>
@@ -128,28 +129,26 @@ FrameLoader* ResourceLoader::frameLoader() const
 void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
 {
     if (allAtOnce) {
-        m_resourceData.adopt([[NSMutableData alloc] initWithBytes:data length:length]);
+        m_resourceData = new SharedBuffer(data, length);
         return;
     }
         
     if (ResourceHandle::supportsBufferedData()) {
         // Buffer data only if the connection has handed us the data because is has stopped buffering it.
         if (m_resourceData)
-            [m_resourceData.get() appendBytes:data length:length];
+            m_resourceData->append(data, length);
     } else {
-        if (!m_resourceData) 
-            m_resourceData.adopt([[NSMutableData alloc] init]);
-
-        [m_resourceData.get() appendBytes:data length:length];
+        if (!m_resourceData)
+            m_resourceData = new SharedBuffer(data, length);
+        else
+            m_resourceData->append(data, length);
     }
 }
 
-NSData *ResourceLoader::resourceData()
+PassRefPtr<SharedBuffer> ResourceLoader::resourceData()
 {
     if (m_resourceData)
-        // Retain and autorelease resourceData since releaseResources (which releases resourceData) may be called 
-        // before the caller of this method has an opportunity to retain the returned data (4070729).
-        return [[m_resourceData.get() retain] autorelease];
+        return m_resourceData;
 
     if (ResourceHandle::supportsBufferedData() && m_handle)
         return m_handle->bufferedData();
@@ -159,7 +158,7 @@ NSData *ResourceLoader::resourceData()
 
 void ResourceLoader::clearResourceData()
 {
-    [m_resourceData.get() setLength:0];
+    m_resourceData->clear();
 }
 
 void ResourceLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
@@ -266,7 +265,7 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
 void ResourceLoader::didReceiveData(const char* data, int length, long long lengthReceived, bool allAtOnce)
 {
     // The following assertions are not quite valid here, since a subclass
-    // might override didReceiveData: in a way that invalidates them. This
+    // might override didReceiveData in a way that invalidates them. This
     // happens with the steps listed in 3266216
     // ASSERT(con == connection);
     // ASSERT(!m_reachedTerminalState);
@@ -283,7 +282,7 @@ void ResourceLoader::didReceiveData(const char* data, int length, long long leng
 void ResourceLoader::willStopBufferingData(const char* data, int length)
 {
     ASSERT(!m_resourceData);
-    m_resourceData.adopt([[NSMutableData alloc] initWithBytes:data length:length]);
+    m_resourceData = new SharedBuffer(data, length);
 }
 
 void ResourceLoader::didFinishLoading()
index 9cfa770ec1b456425869a4f91760dfd6e44eeac4..43fb155203c1a439bdddc08648dd19923725b27a 100644 (file)
@@ -40,6 +40,7 @@
 #import "ResourceHandle.h"
 #import "ResourceRequest.h"
 #import "ResourceResponse.h"
+#import "SharedBuffer.h"
 #import "SubresourceLoaderClient.h"
 #import "WebCoreSystemInterface.h"
 #import <wtf/Assertions.h>
@@ -139,12 +140,13 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& r)
         return;
     ResourceLoader::didReceiveResponse(r);
     
-    if (m_loadingMultipartContent && [resourceData() length]) {
+    RefPtr<SharedBuffer> buffer = resourceData();
+    if (m_loadingMultipartContent && buffer && buffer->size()) {
         // Since a subresource loader does not load multipart sections progressively,
         // deliver the previously received data to the loader all at once now.
         // Then clear the data to make way for the next multipart section.
         if (m_client)
-            m_client->didReceiveData(this, (const char*)[resourceData() bytes], [resourceData() length]);
+            m_client->didReceiveData(this, buffer->data(), buffer->size());
         clearResourceData();
         
         // After the first multipart section is complete, signal to delegates that this load is "finished" 
@@ -175,10 +177,8 @@ void SubresourceLoader::didFinishLoading()
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
 
-    if (m_client) {
-        m_client->receivedAllData(this, resourceData());
+    if (m_client)
         m_client->didFinishLoading(this);
-    }
     
     m_handle = 0;
 
index ffe544a6b7804f61b3bbdb24f566f401578f4780..6a7ce2d2958b6af1e9ed9d11460b85f645eba332 100644 (file)
@@ -1558,7 +1558,12 @@ static NSCharacterSet *_getPostSmartSet(void)
     if (!resource)
         return NO;
 
-    *data = resource->allData();
+    SharedBuffer* buffer = resource->allData();
+    if (buffer)
+        *data = [buffer->createNSData() autorelease];
+    else
+        *data = nil;
+
     *response = resource->response().nsURLResponse();
     return YES;
 }
@@ -1580,7 +1585,16 @@ static NSCharacterSet *_getPostSmartSet(void)
 
     HashMap<String, CachedResource*>::const_iterator end = allResources.end();
     for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
-        [d addObject:it->second->allData()];
+        SharedBuffer* buffer = it->second->allData();
+        NSData *data;
+        
+        if (buffer)
+            data = buffer->createNSData();
+        else
+            data = nil;
+        
+        [d addObject:data];
+        [data release];
         [r addObject:it->second->response().nsURLResponse()];
     }
 
index 5a9217733fb4224fca9d7624c344c33de2801d02..52cb11d1bcf55bdd85fe5ceb5c0f4323cc635b8e 100644 (file)
@@ -35,10 +35,8 @@ typedef const struct __CFURL * CFURLRef;
 
 #if PLATFORM(MAC)
 #ifdef __OBJC__
-@class NSData;
 @class NSURL;
 #else
-class NSData;
 class NSURL;
 #endif
 #endif
diff --git a/WebCore/platform/SharedBuffer.cpp b/WebCore/platform/SharedBuffer.cpp
new file mode 100644 (file)
index 0000000..2996e0a
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "SharedBuffer.h"
+
+namespace WebCore {
+
+SharedBuffer::SharedBuffer(const char* data, int size)
+{
+    m_buffer.append(data, size);
+}
+
+unsigned SharedBuffer::size() const
+{
+    if (hasPlatformData())
+        return platformDataSize();
+    
+    return m_buffer.size();
+}
+
+const char* SharedBuffer::data() const
+{
+    if (hasPlatformData())
+        return platformData();
+    
+    return m_buffer.data();
+}
+
+void SharedBuffer::append(const char* data, int len)
+{
+    maybeTransferPlatformData();
+    
+    m_buffer.append(data, len);
+}
+
+void SharedBuffer::clear()
+{
+    clearPlatformData();
+    
+    m_buffer.resize(0);
+}
+
+#if !PLATFORM(MAC)
+inline void SharedBuffer::clearPlatformData()
+{
+}
+
+inline void SharedBuffer::maybeTransferPlatformData()
+{
+}
+
+inline bool SharedBuffer::hasPlatformData() const
+{
+    return false;
+}
+
+inline const char* SharedBuffer::platformData() const
+{
+    ASSERT_NOT_REACHED();
+
+    return 0;
+}
+
+inline unsigned SharedBuffer::platformDataSize() const;
+{
+    ASSERT_NOT_REACHED();
+    
+    return 0;
+}
+#endif
+
+}
diff --git a/WebCore/platform/SharedBuffer.h b/WebCore/platform/SharedBuffer.h
new file mode 100644 (file)
index 0000000..70936ee
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef SharedBuffer_h
+#define SharedBuffer_h
+
+#include "Shared.h"
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+#if PLATFORM(MAC)
+#include "RetainPtr.h"
+
+#ifdef __OBJC__
+@class NSData;
+#else
+class NSData;
+#endif
+
+#endif
+
+namespace WebCore {
+
+class SharedBuffer : public Shared<SharedBuffer> {
+public:
+    SharedBuffer(const char*, int);
+#if PLATFORM(MAC)
+    NSData *createNSData();
+    static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
+#endif
+        
+    const char* data() const;
+    unsigned size() const;
+
+    void append(const char*, int);
+    void clear();
+
+private:
+    void clearPlatformData();
+    void maybeTransferPlatformData();
+    bool hasPlatformData() const;
+    const char* platformData() const;
+    unsigned platformDataSize() const;
+    
+    Vector<char> m_buffer;
+#if PLATFORM(MAC)
+    SharedBuffer(NSData *nsdata);
+    RetainPtr<NSData> m_nsData;
+#endif
+};
+    
+}
+
+#endif
diff --git a/WebCore/platform/mac/SharedBufferMac.mm b/WebCore/platform/mac/SharedBufferMac.mm
new file mode 100644 (file)
index 0000000..9a5a99c
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "SharedBuffer.h"
+#include <string.h>
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+@interface SharedBufferData : NSData
+{
+    SharedBuffer* sharedBuffer;
+}
+
+- (id)initWithSharedBuffer:(SharedBuffer*)buffer;
+@end
+
+@implementation SharedBufferData
+
+- (void)dealloc
+{
+    sharedBuffer->deref();
+    
+    [super dealloc];
+}
+
+- (void)finalize
+{
+    sharedBuffer->deref();
+    
+    [super finalize];
+}
+
+- (id)initWithSharedBuffer:(SharedBuffer*)buffer
+{
+    self = [super init];
+    
+    if (self) {
+        sharedBuffer = buffer;
+        sharedBuffer->ref();
+    }
+    
+    return self;
+}
+
+- (unsigned)length
+{
+    return sharedBuffer->size();
+}
+
+- (const void *)bytes
+{
+    return reinterpret_cast<const void*>(sharedBuffer->data());
+}
+
+@end
+
+namespace WebCore {
+
+PassRefPtr<SharedBuffer> SharedBuffer::wrapNSData(NSData *nsData)
+{
+    return new SharedBuffer(nsData);
+}
+
+SharedBuffer::SharedBuffer(NSData *nsData)
+    : m_nsData(nsData)
+{
+}
+
+NSData *SharedBuffer::createNSData()
+{    
+    return [[SharedBufferData alloc] initWithSharedBuffer:this];
+}
+
+bool SharedBuffer::hasPlatformData() const
+{
+    return m_nsData;
+}
+
+const char* SharedBuffer::platformData() const
+{
+    return (const char*)[m_nsData.get() bytes];
+}
+
+unsigned SharedBuffer::platformDataSize() const
+{
+    return [m_nsData.get() length];
+}
+
+void SharedBuffer::maybeTransferPlatformData()
+{
+    if (!m_nsData)
+        return;
+    
+    ASSERT(m_buffer.size() == 0);
+        
+    m_buffer.append(reinterpret_cast<const char*>([m_nsData.get() bytes]), [m_nsData.get() length]);
+        
+    m_nsData = nil;
+}
+
+void SharedBuffer::clearPlatformData()
+{
+    m_nsData = 0;
+}
+
+}
index d630dd3f992ad7f04e4fe0d87f1574aa58a95a6c..1f19b23b32bd992503acdce26372b7604c4bfa93 100644 (file)
@@ -67,6 +67,7 @@ class ResourceHandleClient;
 class ResourceHandleInternal;
 class ResourceRequest;
 class ResourceResponse;
+class SharedBuffer;
 class SubresourceLoader;
 class SubresourceLoaderClient;
 
@@ -89,7 +90,7 @@ public:
     NSURLConnection *connection() const;
     WebCoreResourceHandleAsDelegate *delegate();
     void releaseDelegate();
-    NSData* bufferedData();
+    PassRefPtr<SharedBuffer> bufferedData();
     
     static bool supportsBufferedData();
     
index 291f697a59cab7c53ec6d0cf60a10c2f96ba1626..706992d55edbd63ea4d40541406de48877a66201 100644 (file)
@@ -55,22 +55,14 @@ class NSURLCredential;
 
 namespace WebCore {
 
-#if USE(CFNETWORK)
-    typedef void* PlatformData; // unused for now
-#elif PLATFORM(MAC)
-    typedef NSData* PlatformData;
-#elif PLATFORM(QT)
+#if PLATFORM(QT)
     class PlatformResponseQt : public Shared<PlatformResponseQt> {
     public:
         QString data;
         QString url;
     };
 
-    typedef void* PlatformData;
     typedef RefPtr<PlatformResponseQt> PlatformResponse;
-#else
-    // Not sure what the strategy for this will be on other platforms.
-    typedef struct PlatformDataStruct* PlatformData;
 #endif
 
     class KURL;
index 8ff3dc0a404050d2893b9782f80618efa09d742a..e9bf552b13d4829369c7fd049d2879577d56e20b 100644 (file)
@@ -33,6 +33,7 @@
 #import "FrameMac.h"
 #import "ResourceError.h"
 #import "ResourceResponse.h"
+#import "SharedBuffer.h"
 #import "SubresourceLoader.h"
 #import "WebCoreSystemInterface.h"
 
@@ -156,12 +157,12 @@ bool ResourceHandle::supportsBufferedData()
     return NSURLConnectionSupportsBufferedData;
 }
 
-NSData* ResourceHandle::bufferedData()
+PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
 {
     if (ResourceHandle::supportsBufferedData())
-        return [d->m_connection.get() _bufferedData];
+        return SharedBuffer::wrapNSData([d->m_connection.get() _bufferedData]);
 
-    return nil;
+    return 0;
 }
 
 id ResourceHandle::releaseProxy()
index 3b93a4db4483849e14062e9ead4e78081f76e6e8..b3ea1aaf76efd5e4c006fd497d5ddc835613e62b 100644 (file)
@@ -1,3 +1,12 @@
+2007-01-05  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        The data returned is now a SharedBuffer so wrap it in an NSData object.
+        
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource data]):
+
 2007-01-04  Adam Roben  <aroben@apple.com>
 
         Reviewed by Geoff, cheered by others.
index 93cac02915a0108f78db18216f74ecd5d4275d9a..5707ffa43d46b29e9663504fc0404b5dfbfabe61 100644 (file)
 #import <JavaScriptCore/Assertions.h>
 #import <WebCore/FrameLoader.h>
 #import <WebCore/KURL.h>
-#import <WebKit/DOMHTML.h>
+#import <WebCore/MimeTypeRegistry.h>
 #import <WebCore/ResourceRequest.h>
+#import <WebCore/SharedBuffer.h>
+#import <WebKit/DOMHTML.h>
 #import <WebKit/DOMPrivate.h>
 #import <WebKitSystemInterface.h>
-#import <WebCore/MimeTypeRegistry.h>
 
 using namespace WebCore;
 
@@ -376,7 +377,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (NSData *)data
 {
-    return _private->loader->mainResourceData();
+    return [_private->loader->mainResourceData()->createNSData() autorelease];
 }
 
 - (id <WebDocumentRepresentation>)representation