Reviewed by Darin.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Oct 2006 07:30:17 +0000 (07:30 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Oct 2006 07:30:17 +0000 (07:30 +0000)
        - removed ObjC glue between ResourceLoader and SubresourceLoader, then now talk to each other directly

        Removed WebCoreResourceLoader, WebCoreResourceHandle and WebCoreResourceLoaderImp

        * WebCore.xcodeproj/project.pbxproj:
        * bridge/mac/WebCoreFrameBridge.h:
        * loader/mac/FrameLoader.h:
        * loader/mac/FrameLoader.mm:
        * loader/mac/LoaderFunctionsMac.mm:
        * loader/mac/WebLoader.h:
        * loader/mac/WebSubresourceLoader.h:
        * loader/mac/WebSubresourceLoader.mm:
        (WebCore::SubresourceLoader::SubresourceLoader):
        (WebCore::SubresourceLoader::create):
        (WebCore::SubresourceLoader::willSendRequest):
        (WebCore::SubresourceLoader::didReceiveResponse):
        (WebCore::SubresourceLoader::didReceiveData):
        (WebCore::SubresourceLoader::didFinishLoading):
        (WebCore::SubresourceLoader::didFail):
        (WebCore::SubresourceLoader::didCancel):
        * platform/network/ResourceLoader.h:
        * platform/network/ResourceLoaderInternal.h:
        * platform/network/mac/ResourceLoaderMac.mm:
        (WebCore::ResourceLoader::~ResourceLoader):
        (WebCore::ResourceLoader::start):
        (WebCore::ResourceLoader::receivedResponse):
        (WebCore::ResourceLoader::cancel):
        (WebCore::ResourceLoader::redirectedToURL):
        (WebCore::ResourceLoader::addData):
        (WebCore::ResourceLoader::finishJobAndHandle):
        (WebCore::ResourceLoader::reportError):
        * platform/network/mac/WebCoreResourceLoader.h: Removed.
        * platform/network/mac/WebCoreResourceLoaderImp.h: Removed.
        * platform/network/mac/WebCoreResourceLoaderImp.mm: Removed.

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

15 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/loader/mac/FrameLoader.h
WebCore/loader/mac/FrameLoader.mm
WebCore/loader/mac/LoaderFunctionsMac.mm
WebCore/loader/mac/WebLoader.h
WebCore/loader/mac/WebSubresourceLoader.h
WebCore/loader/mac/WebSubresourceLoader.mm
WebCore/platform/network/ResourceLoader.h
WebCore/platform/network/ResourceLoaderInternal.h
WebCore/platform/network/mac/ResourceLoaderMac.mm
WebCore/platform/network/mac/WebCoreResourceLoader.h [deleted file]
WebCore/platform/network/mac/WebCoreResourceLoaderImp.h [deleted file]
WebCore/platform/network/mac/WebCoreResourceLoaderImp.mm [deleted file]

index 2aa56ffa6f3ce61f6dae719cdd5fe53f64e8a6ac..d9d2045f567a78ff0bd7f2f8ee43b69990f6ac21 100644 (file)
@@ -1,3 +1,42 @@
+2006-10-29  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+        - removed ObjC glue between ResourceLoader and SubresourceLoader, then now talk to each other directly
+
+        Removed WebCoreResourceLoader, WebCoreResourceHandle and WebCoreResourceLoaderImp
+        
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * loader/mac/FrameLoader.h:
+        * loader/mac/FrameLoader.mm:
+        * loader/mac/LoaderFunctionsMac.mm:
+        * loader/mac/WebLoader.h:
+        * loader/mac/WebSubresourceLoader.h:
+        * loader/mac/WebSubresourceLoader.mm:
+        (WebCore::SubresourceLoader::SubresourceLoader):
+        (WebCore::SubresourceLoader::create):
+        (WebCore::SubresourceLoader::willSendRequest):
+        (WebCore::SubresourceLoader::didReceiveResponse):
+        (WebCore::SubresourceLoader::didReceiveData):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        (WebCore::SubresourceLoader::didFail):
+        (WebCore::SubresourceLoader::didCancel):
+        * platform/network/ResourceLoader.h:
+        * platform/network/ResourceLoaderInternal.h:
+        * platform/network/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::~ResourceLoader):
+        (WebCore::ResourceLoader::start):
+        (WebCore::ResourceLoader::receivedResponse):
+        (WebCore::ResourceLoader::cancel):
+        (WebCore::ResourceLoader::redirectedToURL):
+        (WebCore::ResourceLoader::addData):
+        (WebCore::ResourceLoader::finishJobAndHandle):
+        (WebCore::ResourceLoader::reportError):
+        * platform/network/mac/WebCoreResourceLoader.h: Removed.
+        * platform/network/mac/WebCoreResourceLoaderImp.h: Removed.
+        * platform/network/mac/WebCoreResourceLoaderImp.mm: Removed.
+
 2006-10-28  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index 942329f2ba5be445d5616c6c857a0cd7574d4cb4..2bd9131b900611d5b604dfbdab13419092c0c26a 100644 (file)
                6550B6A6099DF0270090D781 /* Text.h in Headers */ = {isa = PBXBuildFile; fileRef = 6550B69C099DF0270090D781 /* Text.h */; };
                6552E7AA096AA11B0006F248 /* WebCoreFrameNamespaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6552E7AB096AA11B0006F248 /* WebCoreFrameNamespaces.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.mm */; };
-               655A81BA0AEF67D3000975F0 /* WebCoreResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 655A81B70AEF67D3000975F0 /* WebCoreResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               655A81BB0AEF67D4000975F0 /* WebCoreResourceLoaderImp.h in Headers */ = {isa = PBXBuildFile; fileRef = 655A81B80AEF67D3000975F0 /* WebCoreResourceLoaderImp.h */; };
-               655A81BC0AEF67D4000975F0 /* WebCoreResourceLoaderImp.mm in Sources */ = {isa = PBXBuildFile; fileRef = 655A81B90AEF67D3000975F0 /* WebCoreResourceLoaderImp.mm */; };
                655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 655A81BD0AEF67E6000975F0 /* HTTPHeaderMap.h */; };
                6563A9A70ADF4094000ED2CD /* LoaderNSURLRequestExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 6563A9A50ADF4094000ED2CD /* LoaderNSURLRequestExtras.h */; };
                6563A9A80ADF4094000ED2CD /* LoaderNSURLRequestExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 6563A9A60ADF4094000ED2CD /* LoaderNSURLRequestExtras.m */; };
                6550B69C099DF0270090D781 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = "<group>"; };
                6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreFrameNamespaces.h; sourceTree = "<group>"; };
                6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFrameNamespaces.mm; sourceTree = "<group>"; };
-               655A81B70AEF67D3000975F0 /* WebCoreResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreResourceLoader.h; sourceTree = "<group>"; };
-               655A81B80AEF67D3000975F0 /* WebCoreResourceLoaderImp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreResourceLoaderImp.h; sourceTree = "<group>"; };
-               655A81B90AEF67D3000975F0 /* WebCoreResourceLoaderImp.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreResourceLoaderImp.mm; sourceTree = "<group>"; };
                655A81BD0AEF67E6000975F0 /* HTTPHeaderMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderMap.h; sourceTree = "<group>"; };
                6563A9A50ADF4094000ED2CD /* LoaderNSURLRequestExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LoaderNSURLRequestExtras.h; sourceTree = "<group>"; };
                6563A9A60ADF4094000ED2CD /* LoaderNSURLRequestExtras.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = LoaderNSURLRequestExtras.m; sourceTree = "<group>"; };
                656B84E70AEA1DAE00A095B4 /* mac */ = {
                        isa = PBXGroup;
                        children = (
-                               655A81B70AEF67D3000975F0 /* WebCoreResourceLoader.h */,
-                               655A81B80AEF67D3000975F0 /* WebCoreResourceLoaderImp.h */,
-                               655A81B90AEF67D3000975F0 /* WebCoreResourceLoaderImp.mm */,
                                656B84EA0AEA1DDA00A095B4 /* ResourceLoaderMac.mm */,
                        );
                        path = mac;
                                853CA9E90AEEC608002372DC /* SVGRootInlineBox.h in Headers */,
                                853CA9ED0AEEC63C002372DC /* RenderForeignObject.h in Headers */,
                                853CA9F10AEEC657002372DC /* RenderPath.h in Headers */,
-                               655A81BA0AEF67D3000975F0 /* WebCoreResourceLoader.h in Headers */,
-                               655A81BB0AEF67D4000975F0 /* WebCoreResourceLoaderImp.h in Headers */,
                                655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */,
                                930500200AF025D300FFF491 /* ClipboardAccessPolicy.h in Headers */,
                                9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
                                853CA9EC0AEEC63C002372DC /* RenderForeignObject.cpp in Sources */,
                                853CA9F00AEEC657002372DC /* RenderPath.cpp in Sources */,
                                654F68880AF1B7C50065BDD6 /* CachedResourceMac.mm in Sources */,
-                               655A81BC0AEF67D4000975F0 /* WebCoreResourceLoaderImp.mm in Sources */,
                                9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
index 5fb2d866a92bd80f4316b2da0d6e5e1fe2d87e52..7b83ca00ae25fa9bf2501d769e20f520da8d07da 100644 (file)
@@ -67,8 +67,6 @@ typedef WebCore::FrameMac WebCoreFrameMac;
 @class WebView;
 
 @protocol WebCoreRenderTreeCopier;
-@protocol WebCoreResourceHandle;
-@protocol WebCoreResourceLoader;
 
 extern NSString *WebCorePageCacheStateKey;
 
index b3bd27d74fbd07ec605949a2adc86cdd0e471f0e..14fbf577210f48d2225cfcea6fadda4d563699ac 100644 (file)
@@ -182,11 +182,6 @@ namespace WebCore {
         String referrer() const;
         void loadEmptyDocumentSynchronously();
 
-#ifdef __OBJC__
-        id <WebCoreResourceHandle> startLoadingResource(id <WebCoreResourceLoader>, const String& method, NSURL *, NSDictionary *customHeaders);
-        id <WebCoreResourceHandle> startLoadingResource(id <WebCoreResourceLoader>, const String& method, NSURL *, NSDictionary *customHeaders, NSArray *postData);
-#endif
-        
         DocumentLoader* activeDocumentLoader() const;
         DocumentLoader* documentLoader() const;
         DocumentLoader* provisionalDocumentLoader();
index be7f5ba5c70e5441d14b93af28734d69e5d6256e..b903fcdcdd0ae0ecc0c48942265b60167de080f7 100644 (file)
@@ -1919,42 +1919,6 @@ void FrameLoader::loadEmptyDocumentSynchronously()
     [url release];
 }
 
-id <WebCoreResourceHandle> FrameLoader::startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders)
-{
-    // If we are no longer attached to a page, this must be an attempted load from an
-    // onunload handler, so let's just block it.
-    if (!m_frame->page())
-        return nil;
-    
-    // Since this is a subresource, we can load any URL (we ignore the return value).
-    // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
-    String referrer = m_frame->referrer();
-    bool hideReferrer;
-    canLoad(URL, referrer, hideReferrer);
-    if (hideReferrer)
-        referrer = String();
-    
-    return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, referrer);
-}
-
-id <WebCoreResourceHandle> FrameLoader::startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders, NSArray *postData)
-{
-    // If we are no longer attached to a Page, this must be an attempted load from an
-    // onunload handler, so let's just block it.
-    if (!m_frame->page())
-        return nil;
-    
-    // Since this is a subresource, we can load any URL (we ignore the return value).
-    // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
-    String referrer = m_frame->referrer();
-    bool hideReferrer;
-    canLoad(URL, referrer, hideReferrer);
-    if (hideReferrer)
-        referrer = String();
-    
-    return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, postData, referrer);
-}
-
 void FrameLoader::setClient(FrameLoaderClient* client)
 {
     ASSERT(client);
index 1d508b5878eac41442251eae979a86dbf97a266c..a8be01583efb5e7d202b87939d0a55605c2237c3 100644 (file)
@@ -36,7 +36,6 @@
 #import "FormData.h"
 #import "FormDataMac.h"
 #import "FrameLoader.h"
-#import "WebCoreResourceLoaderImp.h"
 #import "Logging.h"
 #import "Request.h"
 #import "ResourceLoader.h"
index d91ca20b0e0fb6ae91c60766974e10c2f45eb8ef..48b518e46409cbdc2982ec7299583eba083e1dd2 100644 (file)
 #include "Shared.h"
 #include <wtf/RefPtr.h>
 
+#ifdef __OBJC__
 @class NSError;
 @class NSURLAuthenticationChallenge;
 @class NSURLConnection;
 @class NSURLRequest;
 @class NSURLResponse;
 @class WebCoreResourceLoaderAsDelegate;
+@class NSCachedURLResponse;
+#else
+class NSError;
+class NSURLAuthenticationChallenge;
+class NSURLConnection;
+class NSURLRequest;
+class NSURLResponse;
+class WebCoreResourceLoaderAsDelegate;
+class NSCachedURLResponse;
+class NSObject;
+class NSURLCredential;
+class NSMutableData;
+typedef NSObject* id;
+#endif
 
 namespace WebCore {
 
index d5abb29f839fd9f8ec6d5d7c72f1b7edc0c13e5d..31d2091d16f6452407f8d03e49e95eedf93b3adf 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef SubresourceLoader_H_
+#define SubresourceLoader_H_
 #import "WebLoader.h"
-#import "WebCoreResourceLoader.h"
-
+#include <wtf/PassRefPtr.h>
+#ifndef __OBJC__
+class NSArray;
+class NSDictionary;
+class NSMutableURLRequest;
+#endif
 namespace WebCore {
 
     class String;
+    class ResourceLoader;
     
     class SubresourceLoader : public WebResourceLoader {
     public:
-        static id <WebCoreResourceHandle> create(Frame*, id <WebCoreResourceLoader>,
-            const String& method, NSURL *URL, NSDictionary *customHeaders, const String& referrer);
-        static id <WebCoreResourceHandle> create(Frame*, id <WebCoreResourceLoader>,
-            const String& method, NSURL *URL, NSDictionary *customHeaders, NSArray *postData, const String& referrer);
+        static PassRefPtr<SubresourceLoader> create(Frame*, ResourceLoader*, const String& method, 
+                                                    NSURL *URL, NSDictionary *customHeaders, const String& referrer);
+        static PassRefPtr<SubresourceLoader> create(Frame*, ResourceLoader*, const String& method, 
+                                                    NSURL *URL, NSDictionary *customHeaders, NSArray *postData, const String& referrer);
 
         virtual ~SubresourceLoader();
 
@@ -49,16 +59,17 @@ namespace WebCore {
         virtual void didFail(NSError *);
 
     private:
-        static id <WebCoreResourceHandle> create(Frame*, id <WebCoreResourceLoader>,
+        static PassRefPtr<SubresourceLoader> create(Frame*, ResourceLoader*,
             NSMutableURLRequest *, NSDictionary *customHeaders, const String& referrer);
 
-        SubresourceLoader(Frame*, id <WebCoreResourceLoader>);
-        id <WebCoreResourceHandle> handle();
+        SubresourceLoader(Frame*, ResourceLoader*);
 
         virtual void didCancel(NSError *);
 
-        RetainPtr<id <WebCoreResourceLoader> > m_coreLoader;
+        RefPtr<ResourceLoader> m_loader;
         bool m_loadingMultipartContent;
     };
 
 }
+
+#endif // SubresourceLoader_H_
index 2e7098fffb06e308824825c57c9666d7e6fba9ea..fa4205b70b730b1c7bf8a9b130dd17a1e59c99d1 100644 (file)
@@ -33,8 +33,8 @@
 #import "FrameMac.h"
 #import "LoaderNSURLExtras.h"
 #import "LoaderNSURLRequestExtras.h"
+#import "ResourceLoader.h"
 #import "WebCoreFrameBridge.h"
-#import "WebCoreResourceLoader.h"
 #import "WebCoreSystemInterface.h"
 #import "WebFormDataStream.h"
 #import <Foundation/NSURLResponse.h>
 
 using namespace WebCore;
 
-@interface WebCoreSubresourceHandle : NSObject <WebCoreResourceHandle>
-{
-    SubresourceLoader* m_loader;
-}
-- (id)initWithLoader:(SubresourceLoader*)loader;
-@end
-
 namespace WebCore {
 
-SubresourceLoader::SubresourceLoader(Frame* frame, id <WebCoreResourceLoader> l)
+SubresourceLoader::SubresourceLoader(Frame* frame, ResourceLoader* loader)
     : WebResourceLoader(frame)
-    , m_coreLoader(l)
+    , m_loader(loader)
     , m_loadingMultipartContent(false)
 {
     frameLoader()->addSubresourceLoader(this);
@@ -63,7 +56,7 @@ SubresourceLoader::~SubresourceLoader()
 {
 }
 
-id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreResourceLoader> rLoader,
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, ResourceLoader* loader,
     NSMutableURLRequest *newRequest, NSDictionary *customHeaders, const String& referrer)
 {
     FrameLoader* fl = frame->loader();
@@ -91,23 +84,24 @@ id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreRe
     
     fl->addExtraFieldsToRequest(newRequest, false, false);
 
-    RefPtr<SubresourceLoader> loader(new SubresourceLoader(frame, rLoader));
-    if (!loader->load(newRequest))
-        return nil;
-    return loader->handle();
+    RefPtr<SubresourceLoader> subloader(new SubresourceLoader(frame, loader));
+    if (!subloader->load(newRequest))
+        return 0;
+
+    return subloader.release();
 }
 
-id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreResourceLoader> rLoader,
-    const String& method, NSURL *URL, NSDictionary *customHeaders, const String& referrer)
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, ResourceLoader* loader,
+                   const String& method, NSURL *URL, NSDictionary *customHeaders, const String& referrer)
 {
     NSMutableURLRequest *newRequest = [[NSMutableURLRequest alloc] initWithURL:URL];    
     [newRequest setHTTPMethod:method];
-    id <WebCoreResourceHandle> handle = create(frame, rLoader, newRequest, customHeaders, referrer);
+    RefPtr<SubresourceLoader> subloader = create(frame, loader, newRequest, customHeaders, referrer);
     [newRequest release];
-    return handle;
+    return subloader.release();
 }
 
-id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreResourceLoader> rLoader,
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, ResourceLoader* loader,
     const String& method, NSURL *URL, NSDictionary *customHeaders, NSArray *postData, const String& referrer)
 {
     NSMutableURLRequest *newRequest = [[NSMutableURLRequest alloc] initWithURL:URL];
@@ -115,9 +109,9 @@ id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreRe
     // Once this is fixed we can pass the method to create like we used to.
     [newRequest setHTTPMethod:method];
     webSetHTTPBody(newRequest, postData);
-    id <WebCoreResourceHandle> handle = create(frame, rLoader, newRequest, customHeaders, referrer);
+    RefPtr<SubresourceLoader> subloader = create(frame, loader, newRequest, customHeaders, referrer);
     [newRequest release];
-    return handle;
+    return subloader.release();
 }
 
 NSURLRequest *SubresourceLoader::willSendRequest(NSURLRequest *newRequest, NSURLResponse *redirectResponse)
@@ -125,7 +119,7 @@ NSURLRequest *SubresourceLoader::willSendRequest(NSURLRequest *newRequest, NSURL
     NSURL *oldURL = [request() URL];
     NSURLRequest *clientRequest = WebResourceLoader::willSendRequest(newRequest, redirectResponse);
     if (clientRequest && oldURL != [clientRequest URL] && ![oldURL isEqual:[clientRequest URL]])
-        [m_coreLoader.get() redirectedToURL:[clientRequest URL]];
+        m_loader->redirectedToURL([clientRequest URL]);
     return clientRequest;
 }
 
@@ -140,17 +134,17 @@ void SubresourceLoader::didReceiveResponse(NSURLResponse *r)
     // anything including removing the last reference to this object; one example of this is 3266216.
     RefPtr<SubresourceLoader> protect(this);
 
-    [m_coreLoader.get() receivedResponse:r];
-    // The coreLoader can cancel a load if it receives a multipart response for a non-image
+    m_loader->receivedResponse(r);
+    // The loader can cancel a load if it receives a multipart response for a non-image
     if (reachedTerminalState())
         return;
     WebResourceLoader::didReceiveResponse(r);
     
     if (m_loadingMultipartContent && [resourceData() length]) {
         // Since a subresource loader does not load multipart sections progressively,
-        // deliver the previously received data to the coreLoader all at once now.
+        // deliver the previously received data to the loader all at once now.
         // Then clear the data to make way for the next multipart section.
-        [m_coreLoader.get() addData:resourceData()];
+        m_loader->addData(resourceData());
         clearResourceData();
         
         // After the first multipart section is complete, signal to delegates that this load is "finished" 
@@ -165,9 +159,9 @@ void SubresourceLoader::didReceiveData(NSData *data, long long lengthReceived, b
     RefPtr<SubresourceLoader> protect(this);
 
     // A subresource loader does not load multipart sections progressively.
-    // So don't deliver any data to the coreLoader yet.
+    // So don't deliver any data to the loader yet.
     if (!m_loadingMultipartContent)
-        [m_coreLoader.get() addData:data];
+        m_loader->addData(data);
     WebResourceLoader::didReceiveData(data, lengthReceived, allAtOnce);
 }
 
@@ -180,7 +174,10 @@ void SubresourceLoader::didFinishLoading()
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
 
-    [m_coreLoader.get() finishWithData:resourceData()];
+    if (m_loader)
+        m_loader->finishJobAndHandle(resourceData());
+    m_loader = 0;
+
     if (cancelled())
         return;
     frameLoader()->removeSubresourceLoader(this);
@@ -196,7 +193,10 @@ void SubresourceLoader::didFail(NSError *error)
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
 
-    [m_coreLoader.get() reportError];
+    if (m_loader)
+        m_loader->reportError();
+    m_loader = 0;
+
     if (cancelled())
         return;
     frameLoader()->removeSubresourceLoader(this);
@@ -209,48 +209,16 @@ void SubresourceLoader::didCancel(NSError *error)
 
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
+    
+    if (m_loader)
+        m_loader->reportError();
+    m_loader = 0;
 
-    [m_coreLoader.get() cancel];
     if (cancelled())
         return;
     frameLoader()->removeSubresourceLoader(this);
     WebResourceLoader::didCancel(error);
 }
 
-id <WebCoreResourceHandle> SubresourceLoader::handle()
-{
-    return [[[WebCoreSubresourceHandle alloc] initWithLoader:this] autorelease];
-}
-
-}
-
-@implementation WebCoreSubresourceHandle
-
-- (id)initWithLoader:(SubresourceLoader*)loader
-{
-    self = [self init];
-    if (!self)
-        return nil;
-    loader->ref();
-    m_loader = loader;
-    return self;
-}
-
-- (void)dealloc
-{
-    m_loader->deref();
-    [super dealloc];
-}
-
-- (void)finalize
-{
-    m_loader->deref();
-    [super finalize];
-}
-
-- (void)cancel
-{
-    m_loader->cancel();
 }
 
-@end
index 888e32776786535457e672c6f4abb9e3b3062464..28909cb8020c8b6299b0094363635f2c933442a5 100644 (file)
@@ -81,7 +81,10 @@ public:
     void kill();
 
 #if PLATFORM(MAC)
-    void setLoader(WebCoreResourceLoaderImp*);
+    void redirectedToURL(NSURL *url);
+    void addData(NSData *data);
+    void finishJobAndHandle(NSData *data);
+    void reportError();
 #endif
 
 #if USE(WININET)
index b95d4c3367d25b96357fe327e082cea520b349f6..3adad37b6d31a2039becdc357ab87a2fcb9638a3 100644 (file)
@@ -49,6 +49,10 @@ typedef void CURL;
 #include <QString>
 #endif
 
+#if PLATFORM(MAC)
+#include "WebSubresourceLoader.h"
+#endif
+
 // The allocations and releases in ResourceLoaderInternal are
 // Cocoa-exception-free (either simple Foundation classes or
 // WebCoreResourceLoaderImp which avoids doing work in dealloc).
@@ -112,6 +116,7 @@ namespace WebCore {
         CFURLConnectionRef m_connection;
 #elif PLATFORM(MAC)
         WebCoreResourceLoaderImp* loader;
+        RefPtr<WebCore::SubresourceLoader> m_subresourceLoader;
         NSURLResponse* response;
 #endif
 #if USE(WININET)
index 0d0bc2c540ff5d9819a503cd267c7f53bd62bc92..b746eeb6a65a7c9b3fa98502f630d196102a186b 100644 (file)
@@ -35,9 +35,9 @@
 #import "KURL.h"
 #import "FormDataMac.h"
 #import "LoaderFunctions.h"
-#import "WebCoreResourceLoaderImp.h"
 #import "Logging.h"
 #import "WebCoreFrameBridge.h"
+#import "WebSubresourceLoader.h"
 
 namespace WebCore {
     
@@ -49,10 +49,8 @@ ResourceLoaderInternal::~ResourceLoaderInternal()
 
 ResourceLoader::~ResourceLoader()
 {
-    // This will cancel the handle, and who knows what that could do
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [d->loader jobWillBeDeallocated];
-    END_BLOCK_OBJC_EXCEPTIONS;
+    if (d->m_subresourceLoader)
+        d->m_subresourceLoader->cancel();
     delete d;
 }
 
@@ -73,23 +71,33 @@ bool ResourceLoader::start(DocLoader* docLoader)
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    WebCoreResourceLoaderImp* resourceLoader = [[WebCoreResourceLoaderImp alloc] initWithJob:this];
-
-    id <WebCoreResourceHandle> handle;
-
     NSDictionary* headerDict = nil;
     
     if (!d->m_request.httpHeaderFields().isEmpty())
         headerDict = [NSDictionary _webcore_dictionaryWithHeaderMap:d->m_request.httpHeaderFields()];
 
+    // If we are no longer attached to a Page, this must be an attempted load from an
+    // onUnload handler, so let's just block it.
+    if (!frame->page()) {
+        kill();
+        return false;
+    }
+    
+    // Since this is a subresource, we can load any URL (we ignore the return value).
+    // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
+    // FIXME: is that really the rule we want for subresources? also, this is the wrong level to do this check.
+    bool hideReferrer;
+    frame->loader()->canLoad(url().getNSURL(), frame->loader()->referrer(), hideReferrer);
+    
     if (!postData().elements().isEmpty())
-        handle = frame->loader()->startLoadingResource(resourceLoader, method(), url().getNSURL(), headerDict, arrayFromFormData(postData()));
+        d->m_subresourceLoader = SubresourceLoader::create(frame, this,
+                                                           method(), url().getNSURL(), headerDict, arrayFromFormData(postData()), hideReferrer ? String() : frame->loader()->referrer());
     else
-        handle = frame->loader()->startLoadingResource(resourceLoader, method(), url().getNSURL(), headerDict);
-    [resourceLoader setHandle:handle];
-    [resourceLoader release];
+        d->m_subresourceLoader = SubresourceLoader::create(frame, this, 
+                                                            method(), url().getNSURL(), headerDict, hideReferrer ? String() : frame->loader()->referrer());
 
-    if (handle)
+    if (d->m_subresourceLoader)
         return true;
 
     END_BLOCK_OBJC_EXCEPTIONS;
@@ -120,15 +128,10 @@ void ResourceLoader::retrieveResponseEncoding() const
     }
 }
 
-void ResourceLoader::setLoader(WebCoreResourceLoaderImp *loader)
-{
-    HardRetain(loader);
-    HardRelease(d->loader);
-    d->loader = loader;
-}
-
 void ResourceLoader::receivedResponse(NSURLResponse* response)
 {
+    ASSERT(response);
+
     d->assembledResponseHeaders = false;
     d->m_retrievedResponseEncoding = false;
     d->response = response;
@@ -139,7 +142,36 @@ void ResourceLoader::receivedResponse(NSURLResponse* response)
 
 void ResourceLoader::cancel()
 {
-    [d->loader jobCanceledLoad];
+    d->m_subresourceLoader->cancel();
+}
+
+void ResourceLoader::redirectedToURL(NSURL *url)
+{
+    ASSERT(url);
+    if (ResourceLoaderClient* c = client())
+        c->receivedRedirect(this, KURL(url));
+}
+
+void ResourceLoader::addData(NSData *data)
+{
+    ASSERT(data);
+    if (ResourceLoaderClient* c = client())
+        c->didReceiveData(this, (const char *)[data bytes], [data length]);
+}
+
+void ResourceLoader::finishJobAndHandle(NSData *data)
+{
+    if (ResourceLoaderClient* c = client()) {
+        c->receivedAllData(this, data);
+        c->didFinishLoading(this);
+    }
+    kill();
+}
+
+void ResourceLoader::reportError()
+{
+    setError(1);
+    finishJobAndHandle(nil);
 }
 
 } // namespace WebCore
diff --git a/WebCore/platform/network/mac/WebCoreResourceLoader.h b/WebCore/platform/network/mac/WebCoreResourceLoader.h
deleted file mode 100644 (file)
index 5f37938..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2003 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. 
- */
-
-@protocol WebCoreResourceLoader <NSObject>
-
-- (void)receivedResponse:(NSURLResponse *)response;
-- (void)redirectedToURL:(NSURL *)url;
-
-- (void)addData:(NSData *)data;
-
-// Either finishWithData:, reportError, or cancel must be called before the
-// loader is released, but never more than one.
-- (void)finishWithData:(NSData *)data;
-- (void)reportError;
-- (void)cancel;
-
-@end
-
-@protocol WebCoreResourceHandle <NSObject>
-
-- (void)cancel;
-
-@end
diff --git a/WebCore/platform/network/mac/WebCoreResourceLoaderImp.h b/WebCore/platform/network/mac/WebCoreResourceLoaderImp.h
deleted file mode 100644 (file)
index 41c8150..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2003, 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. 
- */
-
-#import "WebCoreResourceLoader.h"
-
-namespace WebCore {
-    class ResourceLoader;
-}
-
-@interface WebCoreResourceLoaderImp : NSObject <WebCoreResourceLoader>
-{
-    WebCore::ResourceLoader* _job;
-    id <WebCoreResourceHandle> _handle;
-}
-
-- (id)initWithJob:(WebCore::ResourceLoader*)job;
-- (void)setHandle:(id <WebCoreResourceHandle>)handle;
-- (void)jobWillBeDeallocated;
-- (void)jobCanceledLoad;
-
-@end
diff --git a/WebCore/platform/network/mac/WebCoreResourceLoaderImp.mm b/WebCore/platform/network/mac/WebCoreResourceLoaderImp.mm
deleted file mode 100644 (file)
index 701609f..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2003, 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"
-#import "WebCoreResourceLoaderImp.h"
-
-#import "ResourceLoader.h"
-#import "KURL.h"
-#import "loader.h"
-#import <wtf/Assertions.h>
-
-using namespace WebCore;
-
-@implementation WebCoreResourceLoaderImp
-
-- (id)initWithJob:(ResourceLoader *)job;
-{
-    [super init];
-
-    _job = job;
-
-    job->setLoader(self);
-
-    return self;
-}
-
-- (void)setHandle:(id <WebCoreResourceHandle>)handle
-{
-    ASSERT(_handle == nil);
-    _handle = [handle retain];
-}
-
-- (void)receivedResponse:(NSURLResponse *)response
-{
-    ASSERT(response);
-    ASSERT(_job);
-    _job->receivedResponse(response);
-}
-
-- (void)redirectedToURL:(NSURL *)url
-{
-    ASSERT(url);
-    ASSERT(_job);
-    if (ResourceLoaderClient* client = _job->client())
-        client->receivedRedirect(_job, KURL(url));
-}
-
-- (void)addData:(NSData *)data
-{
-    ASSERT(data);
-    ASSERT(_job);
-    if (ResourceLoaderClient* client = _job->client())
-        client->didReceiveData(_job, (const char *)[data bytes], [data length]);
-}
-
-- (void)jobWillBeDeallocated
-{
-    id <WebCoreResourceHandle> handle = _handle;
-    _job = 0;
-    _handle = nil;
-
-    [handle cancel];
-    [handle release];
-}
-
-- (void)finishJobAndHandle:(NSData *)data
-{
-    ResourceLoader* job = _job;
-    id <WebCoreResourceHandle> handle = _handle;
-    _job = 0;
-    _handle = nil;
-
-    if (job) {
-        if (ResourceLoaderClient* client = job->client()) {
-            client->receivedAllData(job, data);
-            client->didFinishLoading(job);
-        }
-        job->kill();
-    }
-    [handle release];
-}
-
-- (void)jobCanceledLoad
-{
-    [_handle cancel];
-}
-
-- (void)cancel
-{
-    if (_job) {
-        _job->setError(1);
-    }
-    [self finishJobAndHandle:nil];
-}
-
-- (void)reportError
-{
-    ASSERT(_job);
-    _job->setError(1);
-    [self finishJobAndHandle:nil];
-}
-
-- (void)finishWithData:(NSData *)data
-{
-    ASSERT(_job);
-    ASSERT(_handle);
-    [self finishJobAndHandle:data];
-}
-
-@end