Reviewed by Darin.
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 03:07:16 +0000 (03:07 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 03:07:16 +0000 (03:07 +0000)
        Change all ResourceHandleClients to be SubresourceLoaderClients instead. Also,
        make SubresourceLoader a ResourceHandleClient. This is a first step towards turning ResourceHandle into a
        standalone class which doesn't need to know about SubresourceLoader.

        * WebCore.xcodeproj/project.pbxproj:
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::~ResourceLoader):
        (WebCore::ResourceLoader::ResourceLoader):
        (WebCore::ResourceLoader::setDefersLoading):
        * loader/SubresourceLoader.cpp:
        (WebCore::SubresourceLoader::SubresourceLoader):
        (WebCore::SubresourceLoader::~SubresourceLoader):
        (WebCore::SubresourceLoader::create):
        (WebCore::SubresourceLoader::willSendRequest):
        (WebCore::SubresourceLoader::didReceiveResponse):
        (WebCore::SubresourceLoader::didReceiveData):
        (WebCore::SubresourceLoader::didFinishLoading):
        (WebCore::SubresourceLoader::didFailWithError):
        (WebCore::SubresourceLoader::receivedAllData):
        * loader/SubresourceLoader.h:
        (WebCore::SubresourceLoader::loaderAsResourceHandleClient):
        (WebCore::SubresourceLoader::handle):
        * loader/SubresourceLoaderClient.h: Added.
        (WebCore::SubresourceLoaderClient::~SubresourceLoaderClient):
        (WebCore::SubresourceLoaderClient::willSendRequest):
        (WebCore::SubresourceLoaderClient::didReceiveResponse):
        (WebCore::SubresourceLoaderClient::didReceiveData):
        (WebCore::SubresourceLoaderClient::didFinishLoading):
        (WebCore::SubresourceLoaderClient::didFailWithError):
        (WebCore::SubresourceLoaderClient::receivedAllData):
        * loader/icon/IconLoader.cpp:
        (WebCore::IconLoader::startLoading):
        (WebCore::IconLoader::stopLoading):
        (WebCore::IconLoader::didReceiveResponse):
        (WebCore::IconLoader::didReceiveData):
        (WebCore::IconLoader::didFailWithError):
        (WebCore::IconLoader::didFinishLoading):
        (WebCore::IconLoader::clearLoadingState):
        * loader/icon/IconLoader.h:
        * loader/loader.cpp:
        (WebCore::Loader::servePendingRequests):
        (WebCore::Loader::receivedAllData):
        (WebCore::Loader::didFailWithError):
        (WebCore::Loader::didReceiveResponse):
        (WebCore::Loader::didReceiveData):
        (WebCore::Loader::cancelRequests):
        * loader/loader.h:
        * loader/mac/SubresourceLoaderMac.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/ResourceHandle.cpp:
        (WebCore::ResourceHandle::ResourceHandle):
        (WebCore::ResourceHandle::create):
        * platform/network/ResourceHandle.h:
        * platform/network/ResourceHandleClient.h:
        * platform/network/ResourceHandleInternal.h:
        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
        * platform/network/mac/ResourceHandleMac.mm:
        (WebCore::ResourceHandle::start):
        (WebCore::ResourceHandle::finishJobAndHandle):
        (WebCore::ResourceHandle::loader):
        * xml/xmlhttprequest.cpp:
        (WebCore::XMLHttpRequest::send):
        (WebCore::XMLHttpRequest::didFailWithError):
        (WebCore::XMLHttpRequest::didFinishLoading):
        (WebCore::XMLHttpRequest::willSendRequest):
        (WebCore::XMLHttpRequest::didReceiveResponse):
        (WebCore::XMLHttpRequest::didReceiveData):
        * xml/xmlhttprequest.h:

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

18 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/ResourceLoader.cpp
WebCore/loader/SubresourceLoader.cpp
WebCore/loader/SubresourceLoader.h
WebCore/loader/SubresourceLoaderClient.h [new file with mode: 0644]
WebCore/loader/icon/IconLoader.cpp
WebCore/loader/icon/IconLoader.h
WebCore/loader/loader.cpp
WebCore/loader/loader.h
WebCore/loader/mac/SubresourceLoaderMac.mm
WebCore/platform/network/ResourceHandle.cpp
WebCore/platform/network/ResourceHandle.h
WebCore/platform/network/ResourceHandleClient.h
WebCore/platform/network/ResourceHandleInternal.h
WebCore/platform/network/mac/ResourceHandleMac.mm
WebCore/xml/xmlhttprequest.cpp
WebCore/xml/xmlhttprequest.h

index 2857e2cfc28b37742113af3f60d6378780fbb2bd..d66a1d348043280300aa980275b125d60c211463 100644 (file)
@@ -1,3 +1,83 @@
+2006-12-04  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+        
+        Change all ResourceHandleClients to be SubresourceLoaderClients instead. Also,
+        make SubresourceLoader a ResourceHandleClient. This is a first step towards turning ResourceHandle into a 
+        standalone class which doesn't need to know about SubresourceLoader.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::~ResourceLoader):
+        (WebCore::ResourceLoader::ResourceLoader):
+        (WebCore::ResourceLoader::setDefersLoading):
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::SubresourceLoader):
+        (WebCore::SubresourceLoader::~SubresourceLoader):
+        (WebCore::SubresourceLoader::create):
+        (WebCore::SubresourceLoader::willSendRequest):
+        (WebCore::SubresourceLoader::didReceiveResponse):
+        (WebCore::SubresourceLoader::didReceiveData):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        (WebCore::SubresourceLoader::didFailWithError):
+        (WebCore::SubresourceLoader::receivedAllData):
+        * loader/SubresourceLoader.h:
+        (WebCore::SubresourceLoader::loaderAsResourceHandleClient):
+        (WebCore::SubresourceLoader::handle):
+        * loader/SubresourceLoaderClient.h: Added.
+        (WebCore::SubresourceLoaderClient::~SubresourceLoaderClient):
+        (WebCore::SubresourceLoaderClient::willSendRequest):
+        (WebCore::SubresourceLoaderClient::didReceiveResponse):
+        (WebCore::SubresourceLoaderClient::didReceiveData):
+        (WebCore::SubresourceLoaderClient::didFinishLoading):
+        (WebCore::SubresourceLoaderClient::didFailWithError):
+        (WebCore::SubresourceLoaderClient::receivedAllData):
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading):
+        (WebCore::IconLoader::stopLoading):
+        (WebCore::IconLoader::didReceiveResponse):
+        (WebCore::IconLoader::didReceiveData):
+        (WebCore::IconLoader::didFailWithError):
+        (WebCore::IconLoader::didFinishLoading):
+        (WebCore::IconLoader::clearLoadingState):
+        * loader/icon/IconLoader.h:
+        * loader/loader.cpp:
+        (WebCore::Loader::servePendingRequests):
+        (WebCore::Loader::receivedAllData):
+        (WebCore::Loader::didFailWithError):
+        (WebCore::Loader::didReceiveResponse):
+        (WebCore::Loader::didReceiveData):
+        (WebCore::Loader::cancelRequests):
+        * loader/loader.h:
+        * loader/mac/SubresourceLoaderMac.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/ResourceHandle.cpp:
+        (WebCore::ResourceHandle::ResourceHandle):
+        (WebCore::ResourceHandle::create):
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleClient.h:
+        * platform/network/ResourceHandleInternal.h:
+        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::start):
+        (WebCore::ResourceHandle::finishJobAndHandle):
+        (WebCore::ResourceHandle::loader):
+        * xml/xmlhttprequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+        (WebCore::XMLHttpRequest::didFailWithError):
+        (WebCore::XMLHttpRequest::didFinishLoading):
+        (WebCore::XMLHttpRequest::willSendRequest):
+        (WebCore::XMLHttpRequest::didReceiveResponse):
+        (WebCore::XMLHttpRequest::didReceiveData):
+        * xml/xmlhttprequest.h:
+
 2006-12-04  Darin Adler  <darin@apple.com>
 
         Reviewed by Adele.
index c941d3b8178cce50e13b9e10ba8d87478dbbd241..f223bc5991ac893fcb56aec156a211caf06b9b8a 100644 (file)
@@ -72,6 +72,7 @@
                1A0D57410A5C7867007EDD4C /* JSOverflowEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0D573F0A5C7867007EDD4C /* JSOverflowEvent.h */; };
                1A1D13800A5325520064BF5F /* DOMXPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D137E0A5325520064BF5F /* DOMXPath.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A1D13810A5325520064BF5F /* DOMXPath.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D137F0A5325520064BF5F /* DOMXPath.mm */; };
+               1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
                1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */; };
                1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */; };
                1A0D573F0A5C7867007EDD4C /* JSOverflowEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSOverflowEvent.h; sourceTree = "<group>"; };
                1A1D137E0A5325520064BF5F /* DOMXPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMXPath.h; sourceTree = "<group>"; };
                1A1D137F0A5325520064BF5F /* DOMXPath.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMXPath.mm; sourceTree = "<group>"; };
+               1A3178920B20A81600316987 /* SubresourceLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceLoaderClient.h; sourceTree = "<group>"; };
                1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
                1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElement.cpp; sourceTree = "<group>"; };
                1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElement.h; sourceTree = "<group>"; };
                                656D37270ADBA5DE00A4554D /* ResourceLoader.h */,
                                93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */,
                                656D37300ADBA5DE00A4554D /* SubresourceLoader.h */,
+                               1A3178920B20A81600316987 /* SubresourceLoaderClient.h */,
                                1A6937FF0A11100A00C127FE /* TextDocument.cpp */,
                                1A6938000A11100A00C127FE /* TextDocument.h */,
                                F523D27802DE43D7018635CA /* TextResourceDecoder.cpp */,
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */,
                                93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
                                93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
                                93F198EF08245E59001E9ABC /* HTMLParser.h in Headers */,
index fe16288f5a35094386c589da620568987dac9430..472dc1314a6869baf92d9ac06fb95a0b070d8cdb 100644 (file)
 #include "config.h"
 #include "ResourceLoader.h"
 
+#include "Frame.h"
+#include "Page.h"
+
 namespace WebCore {
 
+#if !PLATFORM(MAC)
+// FIXME: This is only temporary until ResourceLoader is truly platform independent.
+
+ResourceLoader::~ResourceLoader()
+{
+}
+
+ResourceLoader::ResourceLoader(Frame* frame)
+    : m_reachedTerminalState(false)
+    , m_cancelled(false)
+    , m_calledDidFinishLoad(false)
+    , m_frame(frame)
+    , m_defersLoading(frame->page()->defersLoading())
+{
+}
+
+void ResourceLoader::setDefersLoading(bool)
+{
+}
+
+#endif
+
 }
index 660f4e3f3690dfd17dead6e6151f6f9c7d3c769f..43f63c522bdd93efbe25ce6057de79eac7baa79e 100644 (file)
 #include "config.h"
 #include "SubresourceLoader.h"
 
+#include "Document.h"
+#include "Frame.h"
+#include "ResourceHandle.h"
+#include "ResourceRequest.h"
+#include "SubresourceLoaderClient.h"
+
 namespace WebCore {
 
+#if !PLATFORM(MAC)
+
+SubresourceLoader::SubresourceLoader(Frame* frame, SubresourceLoaderClient* client, ResourceHandle* handle)
+    : ResourceLoader(frame)
+    , m_client(client)
+    , m_handle(handle)
+    , m_loadingMultipartContent(false)
+{
+}
+
+SubresourceLoader::~SubresourceLoader()
+{
+}
+
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request)
+{
+    // FIXME: This is only temporary until we get the Mac version of SubresourceLoader::create cross-platform.
+    RefPtr<SubresourceLoader> subloader(new SubresourceLoader(frame, client, 0));
+
+    subloader->m_handle = ResourceHandle::create(request, subloader.get(), frame->document()->docLoader());
+
+    return subloader.release();
+}
+
+#endif
+
+void SubresourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+    if (m_client)
+        m_client->willSendRequest(this, request, redirectResponse);
+}
+
+void SubresourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
+{
+    if (m_client)
+        m_client->didReceiveResponse(this, response);
+}
+
+void SubresourceLoader::didReceiveData(ResourceHandle*, const char* data, int length)
+{
+    if (m_client)
+        m_client->didReceiveData(this, data, length);
+}
+
+void SubresourceLoader::didFinishLoading(ResourceHandle*)
+{
+    if (m_client) {
+        // We must protect the resource loader in case the call to receivedAllData causes a deref.
+        RefPtr<SubresourceLoader> protect(this);
+        
+#if PLATFORM(MAC)
+        m_client->receivedAllData(this, resourceData());
+#else
+        m_client->receivedAllData(this, 0);
+#endif
+        m_client->didFinishLoading(this);
+    }
+}
+
+void SubresourceLoader::didFailWithError(ResourceHandle*, const ResourceError& error)
+{
+    if (m_client)
+        m_client->didFailWithError(this, error);
+}
+
+void SubresourceLoader::receivedAllData(ResourceHandle*, PlatformData data)
+{
+    if (m_client)
+        m_client->receivedAllData(this, data);
+}
+
 }
index 214d4b0a12cc8fa38c24a0b2bb8c747adf8a31e2..2470914b47f38b48d864cf7330a338e483b1ab6c 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef SubresourceLoader_H_
 #define SubresourceLoader_H_
  
+#include "ResourceHandleClient.h"
 #include "ResourceLoader.h"
 #include <wtf/PassRefPtr.h>
  
@@ -44,10 +45,15 @@ namespace WebCore {
     class String;
     class ResourceHandle;
     class ResourceRequest;
+    class SubresourceLoaderClient;
     
-    class SubresourceLoader : public ResourceLoader {
+    class SubresourceLoader : public ResourceLoader, ResourceHandleClient {
     public:
-        static PassRefPtr<SubresourceLoader> create(Frame*, ResourceHandle*, ResourceRequest&);
+        static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, const ResourceRequest&);
+        
+#if PLATFORM(MAC)
+        static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, ResourceHandle*, ResourceRequest&);
+#endif
 
         virtual ~SubresourceLoader();
 
@@ -57,18 +63,33 @@ namespace WebCore {
         virtual void didReceiveData(NSData *, long long lengthReceived, bool allAtOnce);
         virtual void didFinishLoading();
         virtual void didFail(NSError *);
+        
+        // FIXME: This function is here because we want ResourceHandleClient to be privately inherited, but 
+        // ResourceHandle needs to be passed a ResourceHandleClient.
+        ResourceHandleClient* loaderAsResourceHandleClient() { return this; }
 #endif
 
+        // ResourceHandleClient
+        virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse);
+        
+        virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
+        virtual void didReceiveData(ResourceHandle*, const char*, int);
+        virtual void didFinishLoading(ResourceHandle*);
+        virtual void didFailWithError(ResourceHandle*, const ResourceError&);
+
+        virtual void receivedAllData(ResourceHandle*, PlatformData);
+
+        ResourceHandle* handle() const { return m_handle.get(); }
     private:
         static PassRefPtr<SubresourceLoader> create(Frame*, ResourceHandle*,
             NSMutableURLRequest *, NSDictionary *customHeaders, const String& referrer);
 
-        SubresourceLoader(Frame*, ResourceHandle*);
+        SubresourceLoader(Frame*, SubresourceLoaderClient*, ResourceHandle*);
 
 #if PLATFORM(MAC)
         virtual void didCancel(NSError *);
 #endif
-
+        SubresourceLoaderClient* m_client;
         RefPtr<ResourceHandle> m_handle;
         bool m_loadingMultipartContent;
     };
diff --git a/WebCore/loader/SubresourceLoaderClient.h b/WebCore/loader/SubresourceLoaderClient.h
new file mode 100644 (file)
index 0000000..cc11aa3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 SubresourceLoaderClient_h
+#define SubresourceLoaderClient_h
+
+// FIXME: This is just to define PlatformData, it should go away
+#include "ResourceHandleClient.h"
+
+namespace WebCore {
+
+class ResourceRequest;
+class ResourceResponse;
+class SubresourceLoader;
+    
+class SubresourceLoaderClient {
+public:
+    virtual ~SubresourceLoaderClient() { } 
+    
+    // request may be modified
+    virtual void willSendRequest(SubresourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse) { }
+
+    virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&) { }
+    virtual void didReceiveData(SubresourceLoader*, const char*, int) { }
+    virtual void didFinishLoading(SubresourceLoader*) { }
+    virtual void didFailWithError(SubresourceLoader*, const ResourceError&) { }
+    
+    // FIXME: Get rid of this function
+    virtual void receivedAllData(SubresourceLoader*, PlatformData) { }
+};
+
+}
+
+#endif
index 798082a1d1ac2026733f9455e55b6ced7efeab45..b113ddba8d890678f7621b17a3780232f9272990 100644 (file)
@@ -35,6 +35,7 @@
 #include "ResourceHandle.h"
 #include "ResourceResponse.h"
 #include "ResourceRequest.h"
+#include "SubresourceLoader.h"
 
 using namespace std;
 
@@ -59,7 +60,7 @@ IconLoader::~IconLoader()
 
 void IconLoader::startLoading()
 {    
-    if (m_handle)
+    if (m_resourceLoader)
         return;
 
     // FIXME: http://bugs.webkit.org/show_bug.cgi?id=10902
@@ -71,60 +72,59 @@ void IconLoader::startLoading()
     }
 
     // Set flag so we can detect the case where the load completes before
-    // ResourceHandle::create returns.
+    // SubresourceLoader::create returns.
     m_loadIsInProgress = true;
     m_buffer.reserveCapacity(defaultBufferSize);
 
-    RefPtr<ResourceHandle> loader = ResourceHandle::create(m_frame->loader()->iconURL(),
-        this, m_frame->document()->docLoader());
+    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(m_frame, this, m_frame->loader()->iconURL());
     if (!loader)
         LOG_ERROR("Failed to start load for icon at url %s", m_frame->loader()->iconURL().url().ascii());
 
     // Store the handle so we can cancel the load if stopLoading is called later.
     // But only do it if the load hasn't already completed.
     if (m_loadIsInProgress)
-        m_handle = loader.release();
+        m_resourceLoader = loader.release();
 }
 
 void IconLoader::stopLoading()
 {
-    m_handle = 0;
+    m_resourceLoader = 0;
     clearLoadingState();
 }
 
-void IconLoader::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response)
+void IconLoader::didReceiveResponse(SubresourceLoader* resourceLoader, const ResourceResponse& response)
 {
     // If we got a status code indicating an invalid response, then lets
     // ignore the data and not try to decode the error page as an icon.
     int status = response.httpStatusCode();
     if (status && (status < 200 || status > 299)) {
-        KURL iconURL = handle->url();
-        m_handle = 0;
+        KURL iconURL = resourceLoader->handle()->url();
+        m_resourceLoader = 0;
         finishLoading(iconURL);
     }
 }
 
-void IconLoader::didReceiveData(ResourceHandle*, const char* data, int size)
+void IconLoader::didReceiveData(SubresourceLoader*, const char* data, int size)
 {
     ASSERT(data || size == 0);
     ASSERT(size >= 0);
     m_buffer.append(data, size);
 }
 
-void IconLoader::didFailWithError(ResourceHandle* handle, const ResourceError&)
+void IconLoader::didFailWithError(SubresourceLoader* resourceLoader, const ResourceError&)
 {
     ASSERT(m_loadIsInProgress);
     m_buffer.clear();
-    finishLoading(handle->url());
+    finishLoading(resourceLoader->handle()->url());
 }
 
-void IconLoader::didFinishLoading(ResourceHandle* handle)
+void IconLoader::didFinishLoading(SubresourceLoader* resourceLoader)
 {
     // If the icon load resulted in an error-response earlier, the ResourceHandle was killed and icon data commited via finishLoading().
     // In that case this didFinishLoading callback is pointless and we bail.  Otherwise, finishLoading() as expected
     if (m_loadIsInProgress) {
-        ASSERT(handle == m_handle);
-        finishLoading(handle->url());
+        ASSERT(resourceLoader == m_resourceLoader);
+        finishLoading(resourceLoader->handle()->url());
     }
 }
 
@@ -138,7 +138,7 @@ void IconLoader::finishLoading(const KURL& iconURL)
 
 void IconLoader::clearLoadingState()
 {
-    m_handle = 0;
+    m_resourceLoader = 0;
     m_buffer.clear();
     m_loadIsInProgress = false;
 }
index c60a5db9c8f9b25899f86f37ce0013696a42f6ce..021be27b08c888364c90acb395fffc64a4a07aa3 100644 (file)
@@ -27,7 +27,7 @@
 #define ICONLOADER_H_
 
 #include "KURL.h"
-#include "ResourceHandleClient.h"
+#include "SubresourceLoaderClient.h"
 #include <memory>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
@@ -36,7 +36,7 @@ namespace WebCore {
 
 class Frame;
 
-class IconLoader : public ResourceHandleClient, Noncopyable {
+class IconLoader : private SubresourceLoaderClient, Noncopyable {
 public:
     static std::auto_ptr<IconLoader> create(Frame*);
     ~IconLoader();
@@ -47,17 +47,17 @@ public:
 private:
     IconLoader(Frame*);
 
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char*, int);
-    virtual void didFinishLoading(ResourceHandle*);
-    virtual void didFailWithError(ResourceHandle*, const ResourceError&);
+    virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
+    virtual void didReceiveData(SubresourceLoader*, const char*, int);
+    virtual void didFinishLoading(SubresourceLoader*);
+    virtual void didFailWithError(SubresourceLoader*, const ResourceError&);
 
     void finishLoading(const KURL&);
     void clearLoadingState();
 
     Frame* m_frame;
 
-    RefPtr<ResourceHandle> m_handle;
+    RefPtr<SubresourceLoader> m_resourceLoader;
     Vector<char> m_buffer;
     bool m_loadIsInProgress;
 }; // class IconLoader
index 0bb606d12dd3abc18fc9e5afa7cac5363cdace6b..68a58330d97d117e22e959e3f7955b422b78c10d 100644 (file)
@@ -41,6 +41,7 @@
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
+#include "SubresourceLoader.h"
 #include <wtf/Assertions.h>
 #include <wtf/Vector.h>
 
@@ -85,15 +86,16 @@ void Loader::servePendingRequests()
             domain = static_cast<HTMLDocument*>(req->docLoader()->doc())->domain().deprecatedString();
     }
     
-    RefPtr<ResourceHandle> loader = ResourceHandle::create(request, this, req->docLoader());
+    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(req->docLoader()->doc()->frame(), this, request);
 
     if (loader)
         m_requestsLoading.add(loader.release(), req);
 }
 
-void Loader::receivedAllData(ResourceHandle* job, PlatformData allData)
+void Loader::receivedAllData(SubresourceLoader* loader, PlatformData allData)
 {
-    RequestMap::iterator i = m_requestsLoading.find(job);
+    loader->ref();
+    RequestMap::iterator i = m_requestsLoading.find(loader);
     if (i == m_requestsLoading.end())
         return;
 
@@ -114,9 +116,10 @@ void Loader::receivedAllData(ResourceHandle* job, PlatformData allData)
     servePendingRequests();
 }
 
-void Loader::didFailWithError(ResourceHandle* handle, const ResourceError& error)
+void Loader::didFailWithError(SubresourceLoader* loader, const ResourceError& error)
 {
-    RequestMap::iterator i = m_requestsLoading.find(handle);
+    ASSERT(loader->handle());
+    RequestMap::iterator i = m_requestsLoading.find(loader);
     if (i == m_requestsLoading.end())
         return;
 
@@ -136,9 +139,10 @@ void Loader::didFailWithError(ResourceHandle* handle, const ResourceError& error
     servePendingRequests();
 }
 
-void Loader::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response)
+void Loader::didReceiveResponse(SubresourceLoader* loader, const ResourceResponse& response)
 {
-    Request* req = m_requestsLoading.get(handle);
+    ASSERT(loader->handle());
+    Request* req = m_requestsLoading.get(loader);
     ASSERT(req);
     req->cachedResource()->setResponse(response);
     
@@ -151,16 +155,17 @@ void Loader::didReceiveResponse(ResourceHandle* handle, const ResourceResponse&
         static_cast<CachedImage*>(req->cachedResource())->clear();
         if (req->docLoader()->frame())
             req->docLoader()->frame()->loader()->checkCompleted();
-     } else if (response.isMultipart()) {
+    } else if (response.isMultipart()) {
         req->setIsMultipart(true);
         if (!req->cachedResource()->isImage())
-            handle->cancel();
+            loader->handle()->cancel();
     }
 }
 
-void Loader::didReceiveData(ResourceHandle* job, const char* data, int size)
+void Loader::didReceiveData(SubresourceLoader* loader, const char* data, int size)
 {
-    Request* request = m_requestsLoading.get(job);
+    ASSERT(loader->handle());
+    Request* request = m_requestsLoading.get(loader);
     if (!request)
         return;
 
@@ -215,19 +220,19 @@ void Loader::cancelRequests(DocLoader* dl)
             ++pIt;
     }
 
-    Vector<ResourceHandle*, 256> jobsToCancel;
+    Vector<SubresourceLoader*, 256> loadersToCancel;
 
     RequestMap::iterator end = m_requestsLoading.end();
     for (RequestMap::iterator i = m_requestsLoading.begin(); i != end; ++i) {
         Request* r = i->second;
         if (r->docLoader() == dl)
-            jobsToCancel.append(i->first.get());
+            loadersToCancel.append(i->first.get());
     }
 
-    for (unsigned i = 0; i < jobsToCancel.size(); ++i) {
-        ResourceHandle* job = jobsToCancel[i];
-        Request* r = m_requestsLoading.get(job);
-        m_requestsLoading.remove(job);
+    for (unsigned i = 0; i < loadersToCancel.size(); ++i) {
+        SubresourceLoader* loader = loadersToCancel[i];
+        Request* r = m_requestsLoading.get(loader);
+        m_requestsLoading.remove(loader);
         cache()->remove(r->cachedResource());
     }
 
@@ -247,15 +252,4 @@ void Loader::removeBackgroundDecodingRequest(Request* r)
         m_requestsBackgroundDecoding.remove(r);
 }
 
-ResourceHandle* Loader::jobForRequest(const String& URL) const
-{
-    RequestMap::const_iterator end = m_requestsLoading.end();
-    for (RequestMap::const_iterator i = m_requestsLoading.begin(); i != end; ++i) {
-        CachedResource* obj = i->second->cachedResource();
-        if (obj && obj->url() == URL)
-            return i->first.get();
-    }
-    return 0;
-}
-
 } //namespace WebCore
index ae5e4cce4d4be8d6ea04166b520446c490170f17..f46680a72ea585023ac196f410f62ab33e3b6f6e 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef loader_h
 #define loader_h
 
-#include "ResourceHandleClient.h"
+#include "SubresourceLoaderClient.h"
 #include <wtf/HashMap.h>
 #include "DeprecatedPtrList.h"
 
@@ -46,8 +46,7 @@ namespace WebCore {
     class Request;
     class String;
 
-    class Loader : ResourceHandleClient
-    {
+    class Loader : private SubresourceLoaderClient {
     public:
         Loader();
         ~Loader();
@@ -59,19 +58,16 @@ namespace WebCore {
 
         void removeBackgroundDecodingRequest(Request*);
         
-        // may return 0
-        ResourceHandle* jobForRequest(const String& URL) const;
-
     private:
-        virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-        virtual void didReceiveData(ResourceHandle*, const char*, int);
-        virtual void receivedAllData(ResourceHandle*, PlatformData);
-        virtual void didFailWithError(ResourceHandle*, const ResourceError&);
+        virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
+        virtual void didReceiveData(SubresourceLoader*, const char*, int);
+        virtual void receivedAllData(SubresourceLoader*, PlatformData);
+        virtual void didFailWithError(SubresourceLoader*, const ResourceError&);
 
         void servePendingRequests();
 
         DeprecatedPtrList<Request> m_requestsPending;
-        typedef HashMap<RefPtr<ResourceHandle>, Request*> RequestMap;
+        typedef HashMap<RefPtr<SubresourceLoader>, Request*> RequestMap;
         RequestMap m_requestsLoading;
 
         DeprecatedPtrList<Request> m_requestsBackgroundDecoding;
index aab6d813eeb1e7b23c43e6226ad2ed9f1de56259..535df5da805d56efd416ffdcc9faa11fb371aa30 100644 (file)
 #import "config.h"
 #import "SubresourceLoader.h"
 
+#import "Document.h"
 #import "FormDataStreamMac.h"
 #import "FrameLoader.h"
 #import "FrameMac.h"
 #import "LoaderFunctions.h"
 #import "LoaderNSURLExtras.h"
 #import "LoaderNSURLRequestExtras.h"
+#import "ResourceError.h"
 #import "ResourceHandle.h"
 #import "ResourceRequest.h"
+#import "ResourceResponse.h"
+#import "SubresourceLoaderClient.h"
 #import "WebCoreSystemInterface.h"
 #import <Foundation/NSURLResponse.h>
 #import <wtf/Assertions.h>
 
 namespace WebCore {
 
-SubresourceLoader::SubresourceLoader(Frame* frame, ResourceHandle* handle)
+SubresourceLoader::SubresourceLoader(Frame* frame, SubresourceLoaderClient* client, ResourceHandle* handle)
     : ResourceLoader(frame)
+    , m_client(client)
     , m_handle(handle)
     , m_loadingMultipartContent(false)
 {
     frameLoader()->addSubresourceLoader(this);
 }
 
-SubresourceLoader::~SubresourceLoader()
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request)
 {
+    if (!frame)
+        return 0;
+    
+    RefPtr<ResourceHandle> handle = ResourceHandle::create(request, 0, frame->document()->docLoader(), client);
+    
+    if (!handle)
+        return 0;
+    
+    return handle->loader();
 }
 
-PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, ResourceHandle* handle, ResourceRequest& request)
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, SubresourceLoaderClient* client, ResourceHandle* handle, ResourceRequest& request)
 {
     FrameLoader* fl = frame->loader();
     if (fl->state() == FrameStateProvisional)
-        return nil;
+        return 0;
 
     // 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.
@@ -96,7 +110,7 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, ResourceHa
     
     fl->addExtraFieldsToRequest(newRequest, false, false);
 
-    RefPtr<SubresourceLoader> subloader(new SubresourceLoader(frame, handle));
+    RefPtr<SubresourceLoader> subloader(new SubresourceLoader(frame, client, handle));
     if (!subloader->load(newRequest))
         return 0;
 
@@ -111,6 +125,7 @@ NSURLRequest *SubresourceLoader::willSendRequest(NSURLRequest *newRequest, NSURL
     NSURLRequest *clientRequest = ResourceLoader::willSendRequest(newRequest, redirectResponse);
     if (clientRequest && oldURL != [clientRequest URL] && ![oldURL isEqual:[clientRequest URL]])
         clientRequest = m_handle->willSendRequest(clientRequest, redirectResponse);
+    
     return clientRequest;
 }
 
@@ -126,6 +141,7 @@ void SubresourceLoader::didReceiveResponse(NSURLResponse *r)
     RefPtr<SubresourceLoader> protect(this);
 
     m_handle->didReceiveResponse(r);
+    
     // The loader can cancel a load if it receives a multipart response for a non-image
     if (reachedTerminalState())
         return;
@@ -153,6 +169,7 @@ void SubresourceLoader::didReceiveData(NSData *data, long long lengthReceived, b
     // So don't deliver any data to the loader yet.
     if (!m_loadingMultipartContent)
         m_handle->addData(data);
+
     ResourceLoader::didReceiveData(data, lengthReceived, allAtOnce);
 }
 
@@ -165,8 +182,11 @@ void SubresourceLoader::didFinishLoading()
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
 
-    if (RefPtr<ResourceHandle> handle = m_handle.release())
+    if (RefPtr<ResourceHandle> handle = m_handle) {
         handle->finishJobAndHandle(resourceData());
+        // FIXME: Once SubresourceLoader::handle() is removed, we can move back .release() to the assignment expression
+        m_handle = 0;
+    }
 
     if (cancelled())
         return;
@@ -183,9 +203,12 @@ void SubresourceLoader::didFail(NSError *error)
     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
 
-    if (RefPtr<ResourceHandle> handle = m_handle.release())
+    if (RefPtr<ResourceHandle> handle = m_handle) {
         handle->reportError(error);
-
+        // FIXME: Once SubresourceLoader::handle() is removed, we can move back .release() to the assignment expression
+        m_handle = 0;
+    }
+    
     if (cancelled())
         return;
     frameLoader()->removeSubresourceLoader(this);
@@ -198,9 +221,12 @@ 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 (RefPtr<ResourceHandle> handle = m_handle.release())
+
+    if (RefPtr<ResourceHandle> handle = m_handle) {
         handle->reportError(error);
+        // FIXME: Once SubresourceLoader::handle() is removed, we can move back .release() to the assignment expression
+        m_handle = 0;
+    }
 
     if (cancelled())
         return;
index bd85ee103e22a4575ad9f181e7d027a09a3fd500..a8d5318fbe3e15085e59384cbc8ea8f76407aff3 100644 (file)
 
 namespace WebCore {
 
-ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
-    : d(new ResourceHandleInternal(this, request, client))
+ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, SubresourceLoaderClient* loaderClient)
+    : d(new ResourceHandleInternal(this, request, client, loaderClient))
 {
 }
 
-PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, ResourceHandleClient* client, DocLoader* dl)
+PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, ResourceHandleClient* client, DocLoader* dl, SubresourceLoaderClient* loaderClient)
 {
-    RefPtr<ResourceHandle> newLoader(new ResourceHandle(request, client));
+    RefPtr<ResourceHandle> newLoader(new ResourceHandle(request, client, loaderClient));
     
     if (newLoader->start(dl))
         return newLoader.release();
index 2424cb1533765681f3bcbc8214c1c6b57126638f..24471cc4a2579f9ea2fd928b6af0f4bc311ed31e 100644 (file)
@@ -59,6 +59,8 @@ class DocLoader;
 class FormData;
 class KURL;
 class ResourceHandleInternal;
+class SubresourceLoader;
+class SubresourceLoaderClient;
 
 struct ResourceRequest;
 
@@ -66,11 +68,11 @@ template <typename T> class Timer;
 
 class ResourceHandle : public Shared<ResourceHandle> {
 private:
-    ResourceHandle(const ResourceRequest&, ResourceHandleClient*);
+    ResourceHandle(const ResourceRequest&, ResourceHandleClient*, SubresourceLoaderClient*);
 
 public:
     // FIXME: should not need the DocLoader
-    static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, DocLoader*);
+    static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, DocLoader*, SubresourceLoaderClient* = 0);
 
     ~ResourceHandle();
 
@@ -80,6 +82,7 @@ public:
     void addData(NSData *);
     void finishJobAndHandle(NSData *);
     void reportError(NSError* error);
+    SubresourceLoader* loader() const;
 #endif
 
 #if USE(WININET)
@@ -104,7 +107,7 @@ public:
     void cancel();
     
     ResourceHandleClient* client() const;
-
+      
     const HTTPHeaderMap& requestHeaders() const;
     const KURL& url() const;
     const String& method() const;
index b11bcc8182a17557ec05a9100e150af41b522735..fda64cfa4c0133a8374163396efc902865fa1192 100644 (file)
@@ -95,10 +95,6 @@ namespace WebCore {
 
         // cached response may be modified
         // void willCacheResponse(ResourceHandle*, CachedResourceResponse&) { }
-
-        // old-style methods
-        virtual void receivedResponse(ResourceHandle*, PlatformResponse) { }
-        virtual void receivedAllData(ResourceHandle*, PlatformData) { }
     };
 
 }
index d69bbb21baf35d61987acefd92c27d97c7123a84..993cd12a6940b6425e2768a5694f312a81d3954a 100644 (file)
@@ -60,8 +60,9 @@ namespace WebCore {
     class ResourceHandleInternal
     {
     public:
-        ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c)
+        ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, SubresourceLoaderClient* client)
             : m_client(c)
+            , m_subresourceLoaderClient(client)
             , m_request(request)
             , status(0)
             , m_loading(false)
@@ -94,6 +95,9 @@ namespace WebCore {
         ResourceHandleClient* client() const { return m_client; }
        
         ResourceHandleClient* m_client;
+
+        // FIXME: This is only used on mac and should be removed when ResourceHandle no longer depends on SubresourceLoader.
+        SubresourceLoaderClient* m_subresourceLoaderClient;
         
         ResourceRequest m_request;
         
@@ -105,7 +109,7 @@ namespace WebCore {
 #if USE(CFNETWORK)
         CFURLConnectionRef m_connection;
 #elif PLATFORM(MAC)
-        RefPtr<WebCore::SubresourceLoader> m_subresourceLoader;
+        RefPtr<SubresourceLoader> m_subresourceLoader;
 #endif
 #if USE(WININET)
         HANDLE m_fileHandle;
index 90a0230c82497d3483830d800cfb650494fc2b36..83bfa8df0cc1ac2d567fd6722e5b1e53a65cea08 100644 (file)
@@ -65,8 +65,9 @@ bool ResourceHandle::start(DocLoader* docLoader)
     if (!frame->page())
         return false;
     
-    d->m_subresourceLoader = SubresourceLoader::create(frame, this, d->m_request);
-
+    d->m_subresourceLoader = SubresourceLoader::create(frame, d->m_subresourceLoaderClient, this, d->m_request);
+    d->m_client = d->m_subresourceLoader->loaderAsResourceHandleClient();
+    
     if (d->m_subresourceLoader)
         return true;
 
@@ -109,12 +110,8 @@ void ResourceHandle::addData(NSData *data)
 
 void ResourceHandle::finishJobAndHandle(NSData *data)
 {
-    if (ResourceHandleClient* c = client()) {
-        // We must protect the resource handle in case the call to receivedAllData causes a deref.
-        RefPtr<ResourceHandle> protect(this);
-        c->receivedAllData(this, data);
+    if (ResourceHandleClient* c = client())
         c->didFinishLoading(this);
-    }
 }
 
 void ResourceHandle::reportError(NSError* error)
@@ -123,4 +120,9 @@ void ResourceHandle::reportError(NSError* error)
         c->didFailWithError(this, error);
 }
 
+SubresourceLoader* ResourceHandle::loader() const
+{
+    return d->m_subresourceLoader.get();
+}
+
 } // namespace WebCore
index f7ee4a9b3938db82a18f212333325ba95767c8eb..afa0254729751fc613ec4995ba5187567af1c595 100644 (file)
@@ -38,6 +38,7 @@
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
 #include "Settings.h"
+#include "SubresourceLoader.h"
 #include "TextEncoding.h"
 #include "kjs_binding.h"
 #include <kjs/protect.h>
@@ -357,7 +358,7 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
     // create can return null here, for example if we're no longer attached to a page.
     // this is true while running onunload handlers
     // FIXME: Maybe create can return false for other reasons too?
-    m_loader = ResourceHandle::create(request, this, m_doc->docLoader());
+    m_loader = SubresourceLoader::create(m_doc->frame(), this, request);
 }
 
 void XMLHttpRequest::abort()
@@ -491,17 +492,17 @@ void XMLHttpRequest::processSyncLoadResults(const Vector<char>& data, const Reso
     didFinishLoading(0);
 }
 
-void XMLHttpRequest::didFailWithError(ResourceHandle* handle, const ResourceError&)
+void XMLHttpRequest::didFailWithError(SubresourceLoader* loader, const ResourceError&)
 {
-    didFinishLoading(handle);
+    didFinishLoading(loader);
 }
 
-void XMLHttpRequest::didFinishLoading(ResourceHandle* handle)
+void XMLHttpRequest::didFinishLoading(SubresourceLoader* loader)
 {
     if (m_aborted)
         return;
         
-    ASSERT(handle == m_loader.get());
+    ASSERT(loader == m_loader);
 
     if (m_state < Sent)
         changeState(Sent);
@@ -524,13 +525,13 @@ void XMLHttpRequest::didFinishLoading(ResourceHandle* handle)
     }
 }
 
-void XMLHttpRequest::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void XMLHttpRequest::willSendRequest(SubresourceLoader*, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
     if (!urlMatchesDocumentDomain(request.url()))
         abort();
 }
 
-void XMLHttpRequest::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
+void XMLHttpRequest::didReceiveResponse(SubresourceLoader*, const ResourceResponse& response)
 {
     m_response = response;
     m_encoding = getCharset(m_mimeTypeOverride);
@@ -539,7 +540,7 @@ void XMLHttpRequest::didReceiveResponse(ResourceHandle*, const ResourceResponse&
 
 }
 
-void XMLHttpRequest::didReceiveData(ResourceHandle*, const char* data, int len)
+void XMLHttpRequest::didReceiveData(SubresourceLoader*, const char* data, int len)
 {
     if (m_state < Sent)
         changeState(Sent);
index 1e510f1191116e36486acd3abdcc1c37c3ff8904..3bfb4728567a07bf706a3c919686711671450f77 100644 (file)
 #include <wtf/HashMap.h>
 #include <wtf/Vector.h>
 #include "KURL.h"
-#include "ResourceHandleClient.h"
 #include "ResourceResponse.h"
 #include "PlatformString.h"
 #include "HTTPHeaderMap.h"
 #include "StringHash.h"
+#include "SubresourceLoaderClient.h"
 
 namespace WebCore {
 
@@ -53,7 +53,7 @@ enum XMLHttpRequestState {
     Loaded = 4          // The data transfer has been completed.
 };
 
-class XMLHttpRequest : public Shared<XMLHttpRequest>, ResourceHandleClient {
+class XMLHttpRequest : public Shared<XMLHttpRequest>, private SubresourceLoaderClient {
 public:
     XMLHttpRequest(Document*);
     ~XMLHttpRequest();
@@ -82,11 +82,11 @@ public:
 private:
     bool urlMatchesDocumentDomain(const KURL&) const;
 
-    virtual void willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse);
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
-    virtual void didReceiveData(ResourceHandle*, const char* data, int size);
-    virtual void didFailWithError(ResourceHandle*, const ResourceError&);
-    virtual void didFinishLoading(ResourceHandle*);
+    virtual void willSendRequest(SubresourceLoader*, ResourceRequest& request, const ResourceResponse& redirectResponse);
+    virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
+    virtual void didReceiveData(SubresourceLoader*, const char* data, int size);
+    virtual void didFailWithError(SubresourceLoader*, const ResourceError&);
+    virtual void didFinishLoading(SubresourceLoader*);
 
     void processSyncLoadResults(const Vector<char>& data, const ResourceResponse&);
 
@@ -107,7 +107,7 @@ private:
     String m_mimeTypeOverride;
     bool m_async;
 
-    RefPtr<ResourceHandle> m_loader;
+    RefPtr<SubresourceLoader> m_loader;
     XMLHttpRequestState m_state;
 
     ResourceResponse m_response;