+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.
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;
@class WebView;
@protocol WebCoreRenderTreeCopier;
-@protocol WebCoreResourceHandle;
-@protocol WebCoreResourceLoader;
extern NSString *WebCorePageCacheStateKey;
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();
[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);
#import "FormData.h"
#import "FormDataMac.h"
#import "FrameLoader.h"
-#import "WebCoreResourceLoaderImp.h"
#import "Logging.h"
#import "Request.h"
#import "ResourceLoader.h"
#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 {
* 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();
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_
#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);
{
}
-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();
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];
// 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)
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;
}
// 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"
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);
}
// 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);
// 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);
// 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
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)
#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).
CFURLConnectionRef m_connection;
#elif PLATFORM(MAC)
WebCoreResourceLoaderImp* loader;
+ RefPtr<WebCore::SubresourceLoader> m_subresourceLoader;
NSURLResponse* response;
#endif
#if USE(WININET)
#import "KURL.h"
#import "FormDataMac.h"
#import "LoaderFunctions.h"
-#import "WebCoreResourceLoaderImp.h"
#import "Logging.h"
#import "WebCoreFrameBridge.h"
+#import "WebSubresourceLoader.h"
namespace WebCore {
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;
}
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;
}
}
-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;
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
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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