Source/WebCore: CachedResourceRequest is now the only SubresourceLoaderClient
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 20:40:12 +0000 (20:40 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 20:40:12 +0000 (20:40 +0000)
Merge CachedResourceRequest into SubresourceLoader and delete
the SubresourceLoaderClient interface. A few items were moved
to CachedResource instead of SubresourceLoader.
https://bugs.webkit.org/show_bug.cgi?id=71149

Reviewed by Adam Barth.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoadScheduler.cpp:
* loader/ResourceLoadScheduler.h:
* loader/ResourceLoader.cpp:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::SubresourceLoader):
(WebCore::SubresourceLoader::create):
(WebCore::SubresourceLoader::init): Do work that had previously been
    done in SubresourceLoader::create() after the constructor.
(WebCore::SubresourceLoader::willSendRequest):
(WebCore::SubresourceLoader::didSendData):
(WebCore::SubresourceLoader::didReceiveResponse):
(WebCore::SubresourceLoader::didReceiveData):
(WebCore::SubresourceLoader::didReceiveCachedMetadata):
(WebCore::SubresourceLoader::didFinishLoading):
(WebCore::SubresourceLoader::didFail):
(WebCore::SubresourceLoader::willCancel):
(WebCore::SubresourceLoader::releaseResources): Do the cleanup work that was
    duplicated throughout the various terminal CachedResourceRequest callbacks.
* loader/SubresourceLoader.h: Fix indentation style issues.
* loader/SubresourceLoaderClient.h: Removed.
* loader/cache/CachedImage.cpp:
* loader/cache/CachedRawResource.cpp:
* loader/cache/CachedResource.cpp:
(WebCore::cachedResourceTypeToTargetType):
(WebCore::CachedResource::load): Do the work that had been done in
    CachedResourceRequest::load().
(WebCore::CachedResource::finish):
(WebCore::CachedResource::setResponse):
(WebCore::CachedResource::stopLoading):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::canDelete):
* loader/cache/CachedResourceLoader.cpp:
* loader/cache/CachedResourceRequest.cpp: Removed.
* loader/cache/CachedResourceRequest.h: Removed.
* loader/cf/SubresourceLoaderCF.cpp:
* loader/chromium/CachedResourceRequestChromium.cpp: Removed.
* loader/chromium/SubresourceLoaderChromium.cpp:

LayoutTests: Test udpates for https://bugs.webkit.org/show_bug.cgi?id=71149.
The changes to SubresourceLoader slightly change the timings of
certain resource load callbacks.
https://bugs.webkit.org/show_bug.cgi?id=71149

Reviewed by Adam Barth.

* fast/loader/file-protocol-fragment-expected.txt:
* platform/chromium-cg-mac/security/block-test-expected.txt:
* platform/chromium-mac/security/block-test-expected.txt:
* platform/chromium-win/security/block-test-expected.txt:
* platform/mac/fast/images/support-broken-image-delegate-expected.txt:
* platform/mac/security/block-test-expected.txt:
* platform/mac/webarchive/loading/cache-expired-subresource-expected.txt:

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

32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/loader/file-protocol-fragment-expected.txt
LayoutTests/platform/chromium-cg-mac/security/block-test-expected.txt
LayoutTests/platform/chromium-mac/security/block-test-expected.txt
LayoutTests/platform/chromium-win/security/block-test-expected.txt
LayoutTests/platform/mac/fast/images/support-broken-image-delegate-expected.txt
LayoutTests/platform/mac/security/block-test-expected.txt
LayoutTests/platform/mac/webarchive/loading/cache-expired-subresource-expected.txt
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/ResourceLoadScheduler.cpp
Source/WebCore/loader/ResourceLoadScheduler.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.h
Source/WebCore/loader/SubresourceLoaderClient.h [deleted file]
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedRawResource.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp [deleted file]
Source/WebCore/loader/cache/CachedResourceRequest.h [deleted file]
Source/WebCore/loader/cf/SubresourceLoaderCF.cpp
Source/WebCore/loader/chromium/CachedResourceRequestChromium.cpp [deleted file]
Source/WebCore/loader/chromium/SubresourceLoaderChromium.cpp

index 24689a3..d3d9242 100644 (file)
@@ -1,3 +1,20 @@
+2011-11-15  Nate Chapin  <japhet@chromium.org>
+
+        Test udpates for https://bugs.webkit.org/show_bug.cgi?id=71149.
+        The changes to SubresourceLoader slightly change the timings of
+        certain resource load callbacks.
+        https://bugs.webkit.org/show_bug.cgi?id=71149
+
+        Reviewed by Adam Barth.
+
+        * fast/loader/file-protocol-fragment-expected.txt:
+        * platform/chromium-cg-mac/security/block-test-expected.txt:
+        * platform/chromium-mac/security/block-test-expected.txt:
+        * platform/chromium-win/security/block-test-expected.txt:
+        * platform/mac/fast/images/support-broken-image-delegate-expected.txt:
+        * platform/mac/security/block-test-expected.txt:
+        * platform/mac/webarchive/loading/cache-expired-subresource-expected.txt:
+
 2011-11-15  Gavin Barraclough  <barraclough@apple.com>
 
         Result of Error.prototype.toString not ES5 conformant
index a9fc2c8..cc848dd 100644 (file)
@@ -4,4 +4,5 @@ resources/stylesheet.css - willSendRequest <NSURLRequest URL resources/styleshee
 resources/stylesheet.css - didReceiveResponse <NSURLResponse resources/stylesheet.css, http status code 0>
 resources/stylesheet.css - didFinishLoading
 resources/stylesheet.css - didReceiveResponse <NSURLResponse resources/stylesheet.css, http status code 0>
+resources/stylesheet.css - didFinishLoading
 This tests that file: URL are loaded separately even if they differ by the fragment only.
index 18fa6c8..a4aff3a 100644 (file)
@@ -1,7 +1,7 @@
 http://255.255.255.255:1/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:1/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 <unknown> - didFinishLoading
-http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
+http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
 http://255.255.255.255:9/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:9/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:9/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:9/test.jpg">
index ef6dc52..820e7fd 100644 (file)
@@ -1,7 +1,7 @@
 http://255.255.255.255:1/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:1/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 <unknown> - didFinishLoading
-http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
+http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
 http://255.255.255.255:9/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:9/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:9/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:9/test.jpg">
index ebdc2b2..9cacbce 100644 (file)
@@ -1,7 +1,7 @@
 http://255.255.255.255:1/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:1/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 <unknown> - didFinishLoading
-http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
+http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
 http://255.255.255.255:9/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:9/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:9/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:9/test.jpg">
index e5c1856..d22002f 100644 (file)
@@ -2,6 +2,7 @@ resources/broken-image-with-invalid-format.png - willSendRequest <NSURLRequest U
 <unknown> - didFinishLoading
 resources/broken-image-with-invalid-format.png - didReceiveResponse <NSURLResponse resources/broken-image-with-invalid-format.png, http status code 0>
 resources/broken-image-with-invalid-format.png - shouldPaintBrokenImage: NO
+resources/broken-image-with-invalid-format.png - didFinishLoading
 Radar 8610908 - Add a resource delegate method to query if WebCore should paint the broken image.
 
 PASS
index 1197e45..296c4ba 100644 (file)
@@ -1,7 +1,7 @@
 http://255.255.255.255:1/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:1/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 <unknown> - didFinishLoading
-http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
+http://255.255.255.255:7/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:7/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
 http://255.255.255.255:9/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:9/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
 http://255.255.255.255:9/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:9/test.jpg">
index aa6089a..3c2a8e9 100644 (file)
@@ -10,6 +10,7 @@ http://localhost/pink-bullet.png - willSendRequest <NSURLRequest URL http://loca
 frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
 resources/cache-expired-subresource.webarchive - didFinishLoading
 http://localhost/pink-bullet.png - didReceiveResponse <NSURLResponse http://localhost/test.php, http status code 200>
+http://localhost/pink-bullet.png - didFinishLoading
 frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
index 1f11658..627a58a 100644 (file)
@@ -10,6 +10,7 @@ file:///test.png - willSendRequest <NSURLRequest URL file:///test.png, main docu
 frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
 resources/subresource-null-mimetype.webarchive - didFinishLoading
 file:///test.png - didReceiveResponse <NSURLResponse file:///Users/pecoraro/Desktop/test.png, http status code 0>
+file:///test.png - didFinishLoading
 frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
index a3d2cee..e3f0bdb 100644 (file)
@@ -960,7 +960,6 @@ SET(WebCore_SOURCES
     loader/cache/CachedResource.cpp
     loader/cache/CachedResourceHandle.cpp
     loader/cache/CachedResourceLoader.cpp
-    loader/cache/CachedResourceRequest.cpp
     loader/cache/CachedScript.cpp
     loader/cache/CachedXSLStyleSheet.cpp
     loader/cache/MemoryCache.cpp
index bc7abfd..d1f0a2f 100644 (file)
@@ -1,3 +1,57 @@
+2011-11-15  Nate Chapin  <japhet@chromium.org>
+
+        CachedResourceRequest is now the only SubresourceLoaderClient
+        Merge CachedResourceRequest into SubresourceLoader and delete
+        the SubresourceLoaderClient interface. A few items were moved
+        to CachedResource instead of SubresourceLoader.
+        https://bugs.webkit.org/show_bug.cgi?id=71149
+
+        Reviewed by Adam Barth.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoadScheduler.cpp:
+        * loader/ResourceLoadScheduler.h:
+        * loader/ResourceLoader.cpp:
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::SubresourceLoader):
+        (WebCore::SubresourceLoader::create):
+        (WebCore::SubresourceLoader::init): Do work that had previously been
+            done in SubresourceLoader::create() after the constructor.
+        (WebCore::SubresourceLoader::willSendRequest):
+        (WebCore::SubresourceLoader::didSendData):
+        (WebCore::SubresourceLoader::didReceiveResponse):
+        (WebCore::SubresourceLoader::didReceiveData):
+        (WebCore::SubresourceLoader::didReceiveCachedMetadata):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        (WebCore::SubresourceLoader::didFail):
+        (WebCore::SubresourceLoader::willCancel):
+        (WebCore::SubresourceLoader::releaseResources): Do the cleanup work that was
+            duplicated throughout the various terminal CachedResourceRequest callbacks.
+        * loader/SubresourceLoader.h: Fix indentation style issues.
+        * loader/SubresourceLoaderClient.h: Removed.
+        * loader/cache/CachedImage.cpp:
+        * loader/cache/CachedRawResource.cpp:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::cachedResourceTypeToTargetType):
+        (WebCore::CachedResource::load): Do the work that had been done in
+            CachedResourceRequest::load().
+        (WebCore::CachedResource::finish):
+        (WebCore::CachedResource::setResponse):
+        (WebCore::CachedResource::stopLoading):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::canDelete):
+        * loader/cache/CachedResourceLoader.cpp:
+        * loader/cache/CachedResourceRequest.cpp: Removed.
+        * loader/cache/CachedResourceRequest.h: Removed.
+        * loader/cf/SubresourceLoaderCF.cpp:
+        * loader/chromium/CachedResourceRequestChromium.cpp: Removed.
+        * loader/chromium/SubresourceLoaderChromium.cpp:
+
 2011-11-15  Anders Carlsson  <andersca@apple.com>
 
         HostWindow screenToWindow/windowToScreen should be screenToRootView/rootViewToScreen
index b718c10..8d24cbd 100644 (file)
@@ -2165,8 +2165,6 @@ webcore_sources += \
        Source/WebCore/loader/cache/CachedResourceHandle.h \
        Source/WebCore/loader/cache/CachedResourceLoader.cpp \
        Source/WebCore/loader/cache/CachedResourceLoader.h \
-       Source/WebCore/loader/cache/CachedResourceRequest.cpp \
-       Source/WebCore/loader/cache/CachedResourceRequest.h \
        Source/WebCore/loader/cache/CachedScript.cpp \
        Source/WebCore/loader/cache/CachedScript.h \
        Source/WebCore/loader/cache/CachedStyleSheetClient.h \
@@ -2255,7 +2253,6 @@ webcore_sources += \
        Source/WebCore/loader/SinkDocument.h \
        Source/WebCore/loader/SubframeLoader.cpp \
        Source/WebCore/loader/SubframeLoader.h \
-       Source/WebCore/loader/SubresourceLoaderClient.h \
        Source/WebCore/loader/SubresourceLoader.cpp \
        Source/WebCore/loader/SubresourceLoader.h \
        Source/WebCore/loader/SubstituteData.h \
index 94a79e7..12b7acf 100644 (file)
@@ -908,7 +908,6 @@ SOURCES += \
     loader/cache/CachedImage.cpp \
     loader/cache/CachedRawResource.cpp \
     loader/cache/CachedResourceHandle.cpp \
-    loader/cache/CachedResourceRequest.cpp \
     loader/cache/CachedResource.cpp \
     loader/cache/CachedScript.cpp \
     loader/cache/CachedXSLStyleSheet.cpp \
@@ -1950,7 +1949,6 @@ HEADERS += \
     loader/cache/CachedResourceClientWalker.h \
     loader/cache/CachedResource.h \
     loader/cache/CachedResourceHandle.h \
-    loader/cache/CachedResourceRequest.h \
     loader/cache/CachedScript.h \
     loader/cache/CachedXSLStyleSheet.h \
     loader/cache/MemoryCache.h \
index e83061d..c02df6c 100644 (file)
             'loader/ResourceLoaderOptions.h',
             'loader/SubframeLoader.h',
             'loader/SubresourceLoader.h',
-            'loader/SubresourceLoaderClient.h',
             'loader/SubstituteData.h',
             'loader/SubstituteResource.h',
             'loader/TextResourceDecoder.h',
             'loader/cache/CachedResourceClient.h',
             'loader/cache/CachedResourceHandle.h',
             'loader/cache/CachedResourceLoader.h',
-            'loader/cache/CachedResourceRequest.h',
             'loader/cache/CachedStyleSheetClient.h',
             'loader/cache/MemoryCache.h',
             'loader/icon/IconController.h',
             'loader/cache/CachedResourceClientWalker.h',
             'loader/cache/CachedResourceHandle.cpp',
             'loader/cache/CachedResourceLoader.cpp',
-            'loader/cache/CachedResourceRequest.cpp',
             'loader/cache/CachedScript.cpp',
             'loader/cache/CachedScript.h',
             'loader/cache/CachedTextTrack.cpp',
             'loader/cache/MemoryCache.cpp',
             'loader/cf/ResourceLoaderCFNet.cpp',
             'loader/chromium/CachedRawResourceChromium.cpp',
-            'loader/chromium/CachedResourceRequestChromium.cpp',
             'loader/chromium/DocumentThreadableLoaderChromium.cpp',
             'loader/chromium/ResourceLoaderChromium.cpp',
             'loader/chromium/SubresourceLoaderChromium.cpp',
index 4129acf..414403a 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\loader\SubresourceLoaderClient.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\loader\SubstituteData.h"
                                >
                        </File>
                                        >
                                </File>
                                <File
-                                       RelativePath="..\loader\cache\CachedResourceRequest.cpp"
-                                       >
-                               </File>
-                               <File
-                                       RelativePath="..\loader\cache\CachedResourceRequest.h"
-                                       >
-                               </File>
-                               <File
                                        RelativePath="..\loader\cache\CachedScript.cpp"
                                        >
                                </File>
index 3984a92..29da7c4 100644 (file)
                1A2E6E590CC55213004A2062 /* SQLValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E570CC55213004A2062 /* SQLValue.cpp */; };
                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E580CC55213004A2062 /* SQLValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
-               1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */; };
                1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */; };
                1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
                D0BC54491443AC4A00E105DA /* CachedStyleSheetClient.h in Headers */ = {isa = PBXBuildFile; fileRef = D0BC54481443AC4A00E105DA /* CachedStyleSheetClient.h */; };
                D0CE58F8125E4CC200F3F199 /* ResourceLoadScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0CE58F6125E4CC200F3F199 /* ResourceLoadScheduler.cpp */; };
                D0CE58F9125E4CC200F3F199 /* ResourceLoadScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               D0D141B212B2BF5200E39620 /* CachedResourceRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */; };
-               D0D141B312B2BF5200E39620 /* CachedResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
                D0EDA774143E303C0028E383 /* CachedRawResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0EDA772143E303C0028E383 /* CachedRawResource.cpp */; };
                D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EDA773143E303C0028E383 /* CachedRawResource.h */; };
                D0FF2A5D11F8C45A007E74E0 /* PingLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */; };
                1A2E6E570CC55213004A2062 /* SQLValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLValue.cpp; path = sql/SQLValue.cpp; sourceTree = "<group>"; };
                1A2E6E580CC55213004A2062 /* SQLValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLValue.h; path = sql/SQLValue.h; sourceTree = "<group>"; };
                1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteAuthorizer.cpp; path = sql/SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
-               1A3178920B20A81600316987 /* SubresourceLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceLoaderClient.h; sourceTree = "<group>"; };
                1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomVoidCallback.h; sourceTree = "<group>"; };
                1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomVoidCallback.cpp; sourceTree = "<group>"; };
                1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
                D0BC54481443AC4A00E105DA /* CachedStyleSheetClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedStyleSheetClient.h; sourceTree = "<group>"; };
                D0CE58F6125E4CC200F3F199 /* ResourceLoadScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadScheduler.cpp; sourceTree = "<group>"; };
                D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadScheduler.h; sourceTree = "<group>"; };
-               D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequest.cpp; sourceTree = "<group>"; };
-               D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequest.h; sourceTree = "<group>"; };
                D0EDA772143E303C0028E383 /* CachedRawResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedRawResource.cpp; sourceTree = "<group>"; };
                D0EDA773143E303C0028E383 /* CachedRawResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRawResource.h; sourceTree = "<group>"; };
                D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoader.cpp; sourceTree = "<group>"; };
                                E47B4BE60E71241600038854 /* CachedResourceHandle.h */,
                                BCB16C100979C3BD00467741 /* CachedResourceLoader.cpp */,
                                BCB16C110979C3BD00467741 /* CachedResourceLoader.h */,
-                               D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */,
-                               D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */,
                                BCB16C0A0979C3BD00467741 /* CachedScript.cpp */,
                                BCB16C0B0979C3BD00467741 /* CachedScript.h */,
                                D0BC54481443AC4A00E105DA /* CachedStyleSheetClient.h */,
                                D000ED2611C1B9CD00C47726 /* SubframeLoader.h */,
                                93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */,
                                656D37300ADBA5DE00A4554D /* SubresourceLoader.h */,
-                               1A3178920B20A81600316987 /* SubresourceLoaderClient.h */,
                                659A7D120B6DB4D9001155B3 /* SubstituteData.h */,
                                1A8F6B010DB53006001DB794 /* SubstituteResource.h */,
                                F523D27802DE43D7018635CA /* TextResourceDecoder.cpp */,
                                BCB16C220979C3BD00467741 /* CachedResourceClientWalker.h in Headers */,
                                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */,
                                BCB16C2A0979C3BD00467741 /* CachedResourceLoader.h in Headers */,
-                               D0D141B312B2BF5200E39620 /* CachedResourceRequest.h in Headers */,
                                BCB16C240979C3BD00467741 /* CachedScript.h in Headers */,
                                BCD533640ED6848900887468 /* CachedScriptSourceProvider.h in Headers */,
                                D0BC54491443AC4A00E105DA /* CachedStyleSheetClient.h in Headers */,
                                D000ED2811C1B9CD00C47726 /* SubframeLoader.h in Headers */,
                                F55B3DD41251F12D003EF269 /* SubmitInputType.h in Headers */,
                                656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */,
-                               1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */,
                                659A7D130B6DB4D9001155B3 /* SubstituteData.h in Headers */,
                                1A8F6B020DB53006001DB794 /* SubstituteResource.h in Headers */,
                                93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */,
                                BCB16C1F0979C3BD00467741 /* CachedResource.cpp in Sources */,
                                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */,
                                BCB16C290979C3BD00467741 /* CachedResourceLoader.cpp in Sources */,
-                               D0D141B212B2BF5200E39620 /* CachedResourceRequest.cpp in Sources */,
                                BCB16C230979C3BD00467741 /* CachedScript.cpp in Sources */,
                                BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
                                B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */,
index a1640fe..8bf9330 100644 (file)
@@ -85,9 +85,9 @@ ResourceLoadScheduler::ResourceLoadScheduler()
 #endif
 }
 
-PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
+PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, CachedResource* resource, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
 {
-    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, client, request, options);
+    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, resource, request, options);
     if (loader)
         scheduleLoad(loader.get(), priority);
     return loader.release();
index 91df64d..337edc6 100644 (file)
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 
+class CachedResource;
 class Frame;
 class KURL;
 class NetscapePlugInStreamLoader;
@@ -44,14 +45,13 @@ class NetscapePlugInStreamLoaderClient;
 class ResourceLoader;
 class ResourceRequest;
 class SubresourceLoader;
-class SubresourceLoaderClient;
 
 class ResourceLoadScheduler {
     WTF_MAKE_NONCOPYABLE(ResourceLoadScheduler);
 public:
     friend ResourceLoadScheduler* resourceLoadScheduler();
 
-    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
+    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, CachedResource*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
     PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
     void addMainResourceLoad(ResourceLoader*);
     void remove(ResourceLoader*);
index 8f23387..4ec26cc 100644 (file)
@@ -131,7 +131,7 @@ bool ResourceLoader::init(const ResourceRequest& r)
 
     willSendRequest(clientRequest, ResourceResponse());
     if (clientRequest.isNull()) {
-        didFail(cancelledError());
+        cancel();
         return false;
     }
 
index 9e14510..fc76efc 100644 (file)
 #include "config.h"
 #include "SubresourceLoader.h"
 
+#include "CachedImage.h"
+#include "CachedResourceLoader.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoader.h"
-#include "ResourceHandle.h"
+#include "Logging.h"
+#include "MemoryCache.h"
 #include "SecurityOrigin.h"
 #include "SecurityPolicy.h"
-#include "SubresourceLoaderClient.h"
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
 
@@ -44,10 +46,12 @@ namespace WebCore {
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, subresourceLoaderCounter, ("SubresourceLoader"));
 
-SubresourceLoader::SubresourceLoader(Frame* frame, SubresourceLoaderClient* client, const ResourceLoaderOptions& options)
+SubresourceLoader::SubresourceLoader(Frame* frame, CachedResource* resource, const ResourceLoaderOptions& options)
     : ResourceLoader(frame, options)
-    , m_client(client)
+    , m_resource(resource)
+    , m_document(frame->document())
     , m_loadingMultipartContent(false)
+    , m_state(Uninitialized)
 {
 #ifndef NDEBUG
     subresourceLoaderCounter.increment();
@@ -61,7 +65,7 @@ SubresourceLoader::~SubresourceLoader()
 #endif
 }
 
-PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, const ResourceLoaderOptions& options)
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
 {
     if (!frame)
         return 0;
@@ -94,58 +98,88 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc
 
     frameLoader->addExtraFieldsToSubresourceRequest(newRequest);
 
-    RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(frame, client, options)));
+    RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(frame, resource, options)));
     if (!subloader->init(newRequest))
         return 0;
-    subloader->documentLoader()->addSubresourceLoader(subloader.get());
-
     return subloader.release();
 }
 
+bool SubresourceLoader::init(const ResourceRequest& request)
+{
+    if (!ResourceLoader::init(request))
+        return false;
+
+    m_state = Initialized;
+    m_documentLoader->addSubresourceLoader(this);
+    return true;
+}
+
 void SubresourceLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
 {
     // Store the previous URL because the call to ResourceLoader::willSendRequest will modify it.
     KURL previousURL = request().url();
     
     ResourceLoader::willSendRequest(newRequest, redirectResponse);
-    if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url() && m_client)
-        m_client->willSendRequest(this, newRequest, redirectResponse);
+    if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url()) {
+        if (!m_document->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
+            cancel();
+            return;
+        }
+        m_resource->willSendRequest(newRequest, redirectResponse);
+    }
 }
 
 void SubresourceLoader::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
 {
     RefPtr<SubresourceLoader> protect(this);
-
-    if (m_client)
-        m_client->didSendData(this, bytesSent, totalBytesToBeSent);
+    m_resource->didSendData(bytesSent, totalBytesToBeSent);
 }
 
-void SubresourceLoader::didReceiveResponse(const ResourceResponse& r)
+void SubresourceLoader::didReceiveResponse(const ResourceResponse& response)
 {
-    ASSERT(!r.isNull());
-
-    if (r.isMultipart())
-        m_loadingMultipartContent = true;
+    ASSERT(!response.isNull());
 
     // Reference the object in this method since the additional processing can do
     // anything including removing the last reference to this object; one example of this is 3266216.
     RefPtr<SubresourceLoader> protect(this);
 
-    if (m_client)
-        m_client->didReceiveResponse(this, r);
-    
-    // The loader can cancel a load if it receives a multipart response for a non-image
+    if (m_resource->resourceToRevalidate()) {
+        if (response.httpStatusCode() == 304) {
+            // 304 Not modified / Use local copy
+            // Existing resource is ok, just use it updating the expiration time.
+            memoryCache()->revalidationSucceeded(m_resource, response);
+            ResourceLoader::didReceiveResponse(response);
+            return;
+        } 
+        // Did not get 304 response, continue as a regular resource load.
+        memoryCache()->revalidationFailed(m_resource);
+    }
+
+    m_resource->setResponse(response);
     if (reachedTerminalState())
         return;
-    ResourceLoader::didReceiveResponse(r);
-    
+    ResourceLoader::didReceiveResponse(response);
+
+    if (m_loadingMultipartContent) {
+        ASSERT(m_resource->isImage());
+        static_cast<CachedImage*>(m_resource)->clear();
+    } else if (response.isMultipart()) {
+        m_loadingMultipartContent = true;
+
+        // We don't count multiParts in a CachedResourceLoader's request count
+        m_document->cachedResourceLoader()->decrementRequestCount(m_resource);
+        if (!m_resource->isImage()) {
+            cancel();
+            return;
+        }
+    }
+
     RefPtr<SharedBuffer> buffer = resourceData();
     if (m_loadingMultipartContent && buffer && buffer->size()) {
         // Since a subresource loader does not load multipart sections progressively,
         // deliver the previously received data to the loader all at once now.
         // Then clear the data to make way for the next multipart section.
-        if (m_client)
-            m_client->didReceiveData(this, buffer->data(), buffer->size());
+        didReceiveData(buffer->data(), buffer->size(), -1, true);
         clearResourceData();
         
         // After the first multipart section is complete, signal to delegates that this load is "finished" 
@@ -156,77 +190,101 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& r)
 
 void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
 {
+    ASSERT(!m_resource->resourceToRevalidate());
+    ASSERT(!m_resource->errorOccurred());
     // Reference the object in this method since the additional processing can do
     // anything including removing the last reference to this object; one example of this is 3266216.
     RefPtr<SubresourceLoader> protect(this);
-    
     ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
 
-    // A subresource loader does not load multipart sections progressively.
-    // So don't deliver any data to the loader yet.
-    if (!m_loadingMultipartContent && m_client)
-        m_client->didReceiveData(this, data, length);
+    if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors()) {
+        m_resource->error(CachedResource::LoadError);
+        m_state = Finishing;
+        cancel();
+        return;
+    }
+
+    // There are two cases where we might need to create our own SharedBuffer instead of copying the one in ResourceLoader.
+    // (1) Multipart content: The loader delivers the data in a multipart section all at once, then sends eof.
+    //     The resource data will change as the next part is loaded, so we need to make a copy.
+    // (2) Our client requested that the data not be buffered at the ResourceLoader level via ResourceLoaderOptions. In this case,
+    //     ResourceLoader::resourceData() will be null. However, unlike the multipart case, we don't want to tell the CachedResource
+    //     that all data has been received yet.
+    if (m_loadingMultipartContent || !resourceData()) {
+        RefPtr<SharedBuffer> copiedData = SharedBuffer::create(data, length);
+        m_resource->data(copiedData.release(), m_loadingMultipartContent);
+    } else
+        m_resource->data(resourceData(), false);
 }
 
 void SubresourceLoader::didReceiveCachedMetadata(const char* data, int length)
 {
-    // Reference the object in this method since the additional processing can do
-    // anything including removing the last reference to this object; one example of this is 3266216.
-    RefPtr<SubresourceLoader> protect(this);
-    
-    if (m_client)
-        m_client->didReceiveCachedMetadata(this, data, length);
+    ASSERT(!m_resource->resourceToRevalidate());
+    m_resource->setSerializedCachedMetadata(data, length);
 }
 
 void SubresourceLoader::didFinishLoading(double finishTime)
 {
-    if (cancelled())
+    if (m_state != Initialized)
         return;
     ASSERT(!reachedTerminalState());
+    ASSERT(!m_resource->resourceToRevalidate());
+    ASSERT(!m_resource->errorOccurred());
+    LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data());
 
-    // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
-
-    if (m_client)
-        m_client->didFinishLoading(this, finishTime);
-    
-    m_handle = 0;
-
-    if (cancelled())
-        return;
-    m_documentLoader->removeSubresourceLoader(this);
+    m_state = Finishing;
+    m_resource->setLoadFinishTime(finishTime);
+    m_resource->data(resourceData(), true);
+    m_resource->finish();
     ResourceLoader::didFinishLoading(finishTime);
 }
 
 void SubresourceLoader::didFail(const ResourceError& error)
 {
-    if (cancelled())
+    if (m_state != Initialized)
         return;
     ASSERT(!reachedTerminalState());
+    ASSERT(!m_resource->resourceToRevalidate());
+    LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
 
-    // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
     RefPtr<SubresourceLoader> protect(this);
-
-    if (m_client)
-        m_client->didFail(this, error);
-    
-    m_handle = 0;
-    
-    if (cancelled())
-        return;
-    m_documentLoader->removeSubresourceLoader(this);
+    m_state = Finishing;
+    m_resource->error(CachedResource::LoadError);
+    if (!m_resource->isPreloaded())
+        memoryCache()->remove(m_resource);
     ResourceLoader::didFail(error);
 }
 
-void SubresourceLoader::willCancel(const ResourceError& error)
+void SubresourceLoader::willCancel(const ResourceError&)
 {
-    if (m_client)
-        m_client->didFail(this, error);
+    if (m_state != Initialized)
+        return;
+    ASSERT(!reachedTerminalState());
+    LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string().latin1().data());
+
+    RefPtr<SubresourceLoader> protect(this);
+    m_state = Finishing;
+    if (m_resource->resourceToRevalidate())
+        memoryCache()->revalidationFailed(m_resource);
+    memoryCache()->remove(m_resource);
 }
 
-void SubresourceLoader::didCancel(const ResourceError&)
+void SubresourceLoader::releaseResources()
 {
-    m_documentLoader->removeSubresourceLoader(this);
+    ASSERT(!reachedTerminalState());
+    if (m_state != Uninitialized) {
+        if (!m_loadingMultipartContent && m_state != Releasing)
+            m_document->cachedResourceLoader()->decrementRequestCount(m_resource);
+        m_state = Releasing;
+        m_document->cachedResourceLoader()->loadDone();
+        if (reachedTerminalState())
+            return;
+        m_resource->stopLoading();
+        m_documentLoader->removeSubresourceLoader(this);
+    }
+    m_document = 0;
+    ResourceLoader::releaseResources();
 }
 
 }
index 0e6f47f..f11588c 100644 (file)
  
 namespace WebCore {
 
-    class ResourceRequest;
-    class SubresourceLoaderClient;
-    
-    class SubresourceLoader : public ResourceLoader {
-    public:
-        static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, const ResourceRequest&, const ResourceLoaderOptions&);
+class CachedResource;
+class Document;
+class ResourceRequest;
 
-        void clearClient() { m_client = 0; }
+class SubresourceLoader : public ResourceLoader {
+public:
+    static PassRefPtr<SubresourceLoader> create(Frame*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
 
-    private:
-        SubresourceLoader(Frame*, SubresourceLoaderClient*, const ResourceLoaderOptions&);
-        virtual ~SubresourceLoader();
-        
-        virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
-        virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
-        virtual void didReceiveResponse(const ResourceResponse&);
-        virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
-        virtual void didReceiveCachedMetadata(const char*, int);
-        virtual void didFinishLoading(double finishTime);
-        virtual void didFail(const ResourceError&);
-        virtual void willCancel(const ResourceError&);
-        virtual void didCancel(const ResourceError&);
+private:
+    SubresourceLoader(Frame*, CachedResource*, const ResourceLoaderOptions&);
+    virtual ~SubresourceLoader();
+    virtual bool init(const ResourceRequest&);
+
+    virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
+    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
+    virtual void didReceiveResponse(const ResourceResponse&);
+    virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
+    virtual void didReceiveCachedMetadata(const char*, int);
+    virtual void didFinishLoading(double finishTime);
+    virtual void didFail(const ResourceError&);
+    virtual void willCancel(const ResourceError&);
+    virtual void didCancel(const ResourceError&) { }
 
 #if HAVE(NETWORK_CFDATA_ARRAY_CALLBACK)
-        virtual bool supportsDataArray() { return true; }
-        virtual void didReceiveDataArray(CFArrayRef);
+    virtual bool supportsDataArray() { return true; }
+    virtual void didReceiveDataArray(CFArrayRef);
 #endif
 #if PLATFORM(CHROMIUM)
-        virtual void didDownloadData(int);
+    virtual void didDownloadData(int);
 #endif
+    virtual void releaseResources();
 
-        SubresourceLoaderClient* m_client;
-        bool m_loadingMultipartContent;
+    enum SubresourceLoaderState {
+        Uninitialized,
+        Initialized,
+        Finishing,
+        Releasing
     };
 
+    CachedResource* m_resource;
+    RefPtr<Document> m_document;
+    bool m_loadingMultipartContent;
+    SubresourceLoaderState m_state;
+};
+
 }
 
 #endif // SubresourceLoader_h
diff --git a/Source/WebCore/loader/SubresourceLoaderClient.h b/Source/WebCore/loader/SubresourceLoaderClient.h
deleted file mode 100644 (file)
index 9528ab8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
-
-namespace WebCore {
-
-class AuthenticationChallenge;
-class ResourceError;
-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 didSendData(SubresourceLoader*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
-
-    virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&) { }
-    virtual void didReceiveData(SubresourceLoader*, const char*, int /*dataLength*/) { }
-    virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int /*dataLength*/) { }
-    virtual void didFinishLoading(SubresourceLoader*, double /*finishTime*/) { }
-    virtual void didFail(SubresourceLoader*, const ResourceError&) { }
-
-#if PLATFORM(CHROMIUM)
-    virtual void didDownloadData(SubresourceLoader*, int /*dataLength*/) { }
-#endif
-};
-
-} // namespace WebCore
-
-#endif // SubresourceLoaderClient_h
index 1c45895..d624e36 100644 (file)
@@ -29,7 +29,6 @@
 #include "CachedResourceClient.h"
 #include "CachedResourceClientWalker.h"
 #include "CachedResourceLoader.h"
-#include "CachedResourceRequest.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
 #include "FrameLoaderTypes.h"
@@ -37,6 +36,7 @@
 #include "RenderObject.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
+#include "SubresourceLoader.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
@@ -287,11 +287,10 @@ void CachedImage::notifyObservers(const IntRect* changeRect)
 
 void CachedImage::checkShouldPaintBrokenImage()
 {
-    Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
-    if (!frame)
+    if (!m_loader || m_loader->reachedTerminalState())
         return;
 
-    m_shouldPaintBrokenImage = frame->loader()->client()->shouldPaintBrokenImage(m_resourceRequest.url());
+    m_shouldPaintBrokenImage = m_loader->frameLoader()->client()->shouldPaintBrokenImage(m_resourceRequest.url());
 }
 
 void CachedImage::clear()
@@ -328,10 +327,9 @@ inline void CachedImage::createImage()
 
 size_t CachedImage::maximumDecodedImageSize()
 {
-    Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
-    if (!frame)
+    if (!m_loader || m_loader->reachedTerminalState())
         return 0;
-    Settings* settings = frame->settings();
+    Settings* settings = m_loader->frameLoader()->frame()->settings();
     return settings ? settings->maximumDecodedImageSize() : 0;
 }
 
index c92bf8e..5c565f2 100644 (file)
@@ -29,8 +29,8 @@
 #include "CachedResourceClient.h"
 #include "CachedResourceClientWalker.h"
 #include "CachedResourceLoader.h"
-#include "CachedResourceRequest.h"
 #include "SharedBuffer.h"
+#include "SubresourceLoader.h"
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
@@ -78,8 +78,8 @@ void CachedRawResource::didAddClient(CachedResourceClient* c)
 
 void CachedRawResource::allClientsRemoved()
 {
-    if (m_request)
-        m_request->cancel();
+    if (m_loader)
+        m_loader->cancel();
 }
 
 void CachedRawResource::willSendRequest(ResourceRequest& request, const ResourceResponse& response)
@@ -109,13 +109,13 @@ void CachedRawResource::didSendData(unsigned long long bytesSent, unsigned long
 
 void CachedRawResource::setDefersLoading(bool defers)
 {
-    if (m_request)
-        m_request->setDefersLoading(defers);
+    if (m_loader)
+        m_loader->setDefersLoading(defers);
 }
 
 unsigned long CachedRawResource::identifier() const
 {
-    return m_request ? m_request->identifier() : 0;
+    return m_loader ? m_loader->identifier() : 0;
 }
 
 } // namespace WebCore
index b49dabd..6cca41e 100644 (file)
 #include "CachedResourceClientWalker.h"
 #include "CachedResourceHandle.h"
 #include "CachedResourceLoader.h"
-#include "CachedResourceRequest.h"
 #include "CrossOriginAccessControl.h"
+#include "Document.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
 #include "KURL.h"
 #include "Logging.h"
 #include "PurgeableBuffer.h"
 #include "ResourceHandle.h"
+#include "ResourceLoadScheduler.h"
 #include "SharedBuffer.h"
+#include "SubresourceLoader.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -80,6 +82,41 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type
     return ResourceLoadPriorityLow;
 }
 
+#if PLATFORM(CHROMIUM)
+static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
+{
+    switch (type) {
+    case CachedResource::CSSStyleSheet:
+#if ENABLE(XSLT)
+    case CachedResource::XSLStyleSheet:
+#endif
+        return ResourceRequest::TargetIsStyleSheet;
+    case CachedResource::Script: 
+        return ResourceRequest::TargetIsScript;
+    case CachedResource::FontResource:
+        return ResourceRequest::TargetIsFontResource;
+    case CachedResource::ImageResource:
+        return ResourceRequest::TargetIsImage;
+    case CachedResource::RawResource:
+        return ResourceRequest::TargetIsSubresource;    
+#if ENABLE(LINK_PREFETCH)
+    case CachedResource::LinkPrefetch:
+        return ResourceRequest::TargetIsPrefetch;
+    case CachedResource::LinkPrerender:
+        return ResourceRequest::TargetIsPrerender;
+    case CachedResource::LinkSubresource:
+        return ResourceRequest::TargetIsSubresource;
+#endif
+#if ENABLE(VIDEO_TRACK)
+    case CachedResource::TextTrackResource:
+        return ResourceRequest::TargetIsTextTrack;
+#endif
+    }
+    ASSERT_NOT_REACHED();
+    return ResourceRequest::TargetIsSubresource;
+}
+#endif
+
 DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("CachedResource"));
 
 CachedResource::CachedResource(const ResourceRequest& request, Type type)
@@ -139,11 +176,50 @@ void CachedResource::load(CachedResourceLoader* cachedResourceLoader, const Reso
 {
     m_options = options;
     m_loading = true;
-    m_request = CachedResourceRequest::load(cachedResourceLoader, this, options);
-    if (m_request) {
-        m_status = Pending;
-        cachedResourceLoader->incrementRequestCount(this);
+
+#if PLATFORM(CHROMIUM)
+    if (m_resourceRequest.targetType() == ResourceRequest::TargetIsUnspecified)
+        m_resourceRequest.setTargetType(cachedResourceTypeToTargetType(type()));
+#endif
+
+    if (!accept().isEmpty())
+        m_resourceRequest.setHTTPAccept(accept());
+
+    if (isCacheValidator()) {
+        CachedResource* resourceToRevalidate = m_resourceToRevalidate;
+        ASSERT(resourceToRevalidate->canUseCacheValidator());
+        ASSERT(resourceToRevalidate->isLoaded());
+        const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified");
+        const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag");
+        if (!lastModified.isEmpty() || !eTag.isEmpty()) {
+            ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload);
+            if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate)
+                m_resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0");
+            if (!lastModified.isEmpty())
+                m_resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified);
+            if (!eTag.isEmpty())
+                m_resourceRequest.setHTTPHeaderField("If-None-Match", eTag);
+        }
+    }
+
+#if ENABLE(LINK_PREFETCH)
+    if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkPrerender || type() == CachedResource::LinkSubresource)
+        m_resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
+#endif
+    m_resourceRequest.setPriority(loadPriority());
+    
+    m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), this, m_resourceRequest, m_resourceRequest.priority(), options);
+    if (!m_loader || m_loader->reachedTerminalState()) {
+        // FIXME: What if resources in other frames were waiting for this revalidation?
+        LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().data());
+        if (m_resourceToRevalidate) 
+            memoryCache()->revalidationFailed(this); 
+        error(CachedResource::LoadError);
+        return;
     }
+
+    m_status = Pending;
+    cachedResourceLoader->incrementRequestCount(this);
 }
 
 void CachedResource::checkNotify()
@@ -177,7 +253,8 @@ void CachedResource::error(CachedResource::Status status)
 
 void CachedResource::finish()
 {
-    m_status = Cached;
+    if (!errorOccurred())
+        m_status = Cached;
 }
 
 bool CachedResource::passesAccessControlCheck(SecurityOrigin* securityOrigin)
@@ -232,6 +309,9 @@ void CachedResource::setResponse(const ResourceResponse& response)
 {
     m_response = response;
     m_responseTimestamp = currentTime();
+    String encoding = response.textEncodingName();
+    if (!encoding.isNull())
+        setEncoding(encoding);
 }
 
 void CachedResource::setSerializedCachedMetadata(const char* data, size_t size)
@@ -264,8 +344,8 @@ CachedMetadata* CachedResource::cachedMetadata(unsigned dataTypeID) const
 
 void CachedResource::stopLoading()
 {
-    ASSERT(m_request);            
-    m_request.clear();
+    ASSERT(m_loader);            
+    m_loader = 0;
 
     CachedResourceHandle<CachedResource> protect(this);
 
index 5d11467..ba339f8 100644 (file)
@@ -44,11 +44,11 @@ class CachedMetadata;
 class CachedResourceClient;
 class CachedResourceHandleBase;
 class CachedResourceLoader;
-class CachedResourceRequest;
 class Frame;
 class InspectorResource;
 class PurgeableBuffer;
 class SecurityOrigin;
+class SubresourceLoader;
 
 // A resource that is held in the cache. Classes who want to use this object should derive
 // from CachedResourceClient, to get the function calls in case the requested data has arrived.
@@ -187,7 +187,7 @@ public:
     // Returns cached metadata of the given type associated with this resource.
     CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
 
-    bool canDelete() const { return !hasClients() && !m_request && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
+    bool canDelete() const { return !hasClients() && !m_loader && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
     bool hasOneHandle() const { return m_handleCount == 1; }
 
     bool isExpired() const;
@@ -253,7 +253,7 @@ protected:
 
     ResourceRequest m_resourceRequest;
     String m_accept;
-    OwnPtr<CachedResourceRequest> m_request;
+    RefPtr<SubresourceLoader> m_loader;
     ResourceLoaderOptions m_options;
     ResourceLoadPriority m_loadPriority;
 
index e7f3936..3ca92db 100644 (file)
@@ -31,7 +31,6 @@
 #include "CachedFont.h"
 #include "CachedImage.h"
 #include "CachedRawResource.h"
-#include "CachedResourceRequest.h"
 #include "CachedScript.h"
 #include "CachedXSLStyleSheet.h"
 #include "Console.h"
diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.cpp b/Source/WebCore/loader/cache/CachedResourceRequest.cpp
deleted file mode 100644 (file)
index 71c84b2..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
-    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
-    Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
-    Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
-    Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
-    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "CachedResourceRequest.h"
-
-#include "CachedImage.h"
-#include "CachedResource.h"
-#include "CachedResourceLoader.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "Logging.h"
-#include "MemoryCache.h"
-#include "ResourceHandle.h"
-#include "ResourceLoadScheduler.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "SharedBuffer.h"
-#include "SubresourceLoader.h"
-#include <wtf/Assertions.h>
-#include <wtf/UnusedParam.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-#if PLATFORM(CHROMIUM)
-static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
-{
-    switch (type) {
-    case CachedResource::CSSStyleSheet:
-#if ENABLE(XSLT)
-    case CachedResource::XSLStyleSheet:
-#endif
-        return ResourceRequest::TargetIsStyleSheet;
-    case CachedResource::Script: 
-        return ResourceRequest::TargetIsScript;
-    case CachedResource::FontResource:
-        return ResourceRequest::TargetIsFontResource;
-    case CachedResource::ImageResource:
-        return ResourceRequest::TargetIsImage;
-    case CachedResource::RawResource:
-        return ResourceRequest::TargetIsSubresource;    
-#if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkPrefetch:
-        return ResourceRequest::TargetIsPrefetch;
-    case CachedResource::LinkPrerender:
-        return ResourceRequest::TargetIsPrerender;
-    case CachedResource::LinkSubresource:
-        return ResourceRequest::TargetIsSubresource;
-#endif
-#if ENABLE(VIDEO_TRACK)
-    case CachedResource::TextTrackResource:
-        return ResourceRequest::TargetIsTextTrack;
-#endif
-    }
-    ASSERT_NOT_REACHED();
-    return ResourceRequest::TargetIsSubresource;
-}
-#endif
-
-CachedResourceRequest::CachedResourceRequest(CachedResourceLoader* cachedResourceLoader, CachedResource* resource)
-    : m_cachedResourceLoader(cachedResourceLoader)
-    , m_resource(resource)
-    , m_multipart(false)
-    , m_finishing(false)
-{
-}
-
-CachedResourceRequest::~CachedResourceRequest()
-{
-    if (m_loader)
-        m_loader->clearClient();
-}
-
-PassOwnPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoader* cachedResourceLoader, CachedResource* resource, const ResourceLoaderOptions& options)
-{
-    OwnPtr<CachedResourceRequest> request = adoptPtr(new CachedResourceRequest(cachedResourceLoader, resource));
-
-    ResourceRequest resourceRequest = resource->resourceRequest();
-#if PLATFORM(CHROMIUM)
-    if (resourceRequest.targetType() == ResourceRequest::TargetIsUnspecified)
-        resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type()));
-#endif
-
-    if (!resource->accept().isEmpty())
-        resourceRequest.setHTTPAccept(resource->accept());
-
-    if (resource->isCacheValidator()) {
-        CachedResource* resourceToRevalidate = resource->resourceToRevalidate();
-        ASSERT(resourceToRevalidate->canUseCacheValidator());
-        ASSERT(resourceToRevalidate->isLoaded());
-        const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified");
-        const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag");
-        if (!lastModified.isEmpty() || !eTag.isEmpty()) {
-            ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload);
-            if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate)
-                resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0");
-            if (!lastModified.isEmpty())
-                resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified);
-            if (!eTag.isEmpty())
-                resourceRequest.setHTTPHeaderField("If-None-Match", eTag);
-        }
-    }
-    
-#if ENABLE(LINK_PREFETCH)
-    if (resource->type() == CachedResource::LinkPrefetch || resource->type() == CachedResource::LinkPrerender || resource->type() == CachedResource::LinkSubresource)
-        resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
-#endif
-
-    ResourceLoadPriority priority = resource->loadPriority();
-    resourceRequest.setPriority(priority);
-
-    RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), request.get(), resourceRequest, priority, options);
-    if (!loader || loader->reachedTerminalState()) {
-        // FIXME: What if resources in other frames were waiting for this revalidation?
-        LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().string().latin1().data());
-        if (resource->resourceToRevalidate()) 
-            memoryCache()->revalidationFailed(resource); 
-        resource->error(CachedResource::LoadError);
-        return PassOwnPtr<CachedResourceRequest>(nullptr);
-    }
-    request->m_loader = loader;
-    return request.release();
-}
-
-void CachedResourceRequest::willSendRequest(SubresourceLoader* loader, ResourceRequest& req, const ResourceResponse& response)
-{
-    if (!m_cachedResourceLoader->canRequest(m_resource->type(), req.url())) {
-        loader->cancel();
-        return;
-    }
-    m_resource->willSendRequest(req, response);
-}
-
-void CachedResourceRequest::cancel()
-{
-    if (m_finishing)
-        return;
-    m_loader->cancel();
-}
-
-unsigned long CachedResourceRequest::identifier() const
-{
-    return m_loader->identifier();
-}
-
-void CachedResourceRequest::setDefersLoading(bool defers)
-{
-    if (m_loader)
-        m_loader->setDefersLoading(defers);
-}
-
-void CachedResourceRequest::didFinishLoading(SubresourceLoader* loader, double finishTime)
-{
-    if (m_finishing)
-        return;
-
-    ASSERT(loader == m_loader.get());
-    ASSERT(!m_resource->resourceToRevalidate());
-    LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data());
-
-    // Prevent the document from being destroyed before we are done with
-    // the cachedResourceLoader that it will delete when the document gets deleted.
-    RefPtr<Document> protector(m_cachedResourceLoader->document());
-    if (!m_multipart)
-        m_cachedResourceLoader->decrementRequestCount(m_resource);
-    m_finishing = true;
-
-    // If we got a 4xx response, we're pretending to have received a network
-    // error, so we can't send the successful data() and finish() callbacks.
-    if (!m_resource->errorOccurred()) {
-        m_cachedResourceLoader->loadFinishing();
-        m_resource->setLoadFinishTime(finishTime);
-        m_resource->data(loader->resourceData(), true);
-        if (!m_resource->errorOccurred())
-            m_resource->finish();
-    }
-    end();
-}
-
-void CachedResourceRequest::didFail(SubresourceLoader*, const ResourceError& error)
-{
-    if (m_finishing || !m_loader)
-        return;
-
-    bool cancelled = error.isCancellation();
-    LOG(ResourceLoading, "Failed to load '%s' (cancelled=%d).\n", m_resource->url().string().latin1().data(), cancelled);
-
-    // Prevent the document from being destroyed before we are done with
-    // the cachedResourceLoader that it will delete when the document gets deleted.
-    RefPtr<Document> protector(m_cachedResourceLoader->document());
-    if (!m_multipart)
-        m_cachedResourceLoader->decrementRequestCount(m_resource);
-    m_finishing = true;
-    m_loader->clearClient();
-
-    if (m_resource->resourceToRevalidate())
-        memoryCache()->revalidationFailed(m_resource);
-
-    if (!cancelled) {
-        m_cachedResourceLoader->loadFinishing();
-        m_resource->error(CachedResource::LoadError);
-    }
-
-    if (cancelled || !m_resource->isPreloaded())
-        memoryCache()->remove(m_resource);
-    
-    end();
-}
-
-void CachedResourceRequest::didReceiveResponse(SubresourceLoader* loader, const ResourceResponse& response)
-{
-    ASSERT(loader == m_loader.get());
-    if (m_resource->isCacheValidator()) {
-        if (response.httpStatusCode() == 304) {
-            // 304 Not modified / Use local copy
-            loader->clearClient();
-            RefPtr<Document> protector(m_cachedResourceLoader->document());
-            m_cachedResourceLoader->decrementRequestCount(m_resource);
-            m_finishing = true;
-
-            // Existing resource is ok, just use it updating the expiration time.
-            memoryCache()->revalidationSucceeded(m_resource, response);
-            
-            if (m_cachedResourceLoader->frame())
-                m_cachedResourceLoader->frame()->loader()->checkCompleted();
-
-            end();
-            return;
-        } 
-        // Did not get 304 response, continue as a regular resource load.
-        memoryCache()->revalidationFailed(m_resource);
-    }
-
-    // setResponse() might cancel the request, so we need to keep ourselves alive. Unfortunately,
-    // we can't protect a CachedResourceRequest, but we can protect m_resource, which has the
-    // power to kill the CachedResourceRequest (and will switch isLoading() to false if it does so).
-    CachedResourceHandle<CachedResource> protect(m_resource);
-    m_resource->setResponse(response);
-    if (!protect->isLoading())
-        return;
-
-    String encoding = response.textEncodingName();
-    if (!encoding.isNull())
-        m_resource->setEncoding(encoding);
-    
-    if (m_multipart) {
-        ASSERT(m_resource->isImage());
-        static_cast<CachedImage*>(m_resource)->clear();
-        if (m_cachedResourceLoader->frame())
-            m_cachedResourceLoader->frame()->loader()->checkCompleted();
-    } else if (response.isMultipart()) {
-        m_multipart = true;
-        
-        // We don't count multiParts in a CachedResourceLoader's request count
-        m_cachedResourceLoader->decrementRequestCount(m_resource);
-
-        // If we get a multipart response, we must have a handle
-        ASSERT(loader->handle());
-        if (!m_resource->isImage())
-            loader->handle()->cancel();
-    }
-}
-
-void CachedResourceRequest::didReceiveData(SubresourceLoader* loader, const char* data, int size)
-{
-    ASSERT(loader == m_loader.get());
-    ASSERT(!m_resource->isCacheValidator());
-    
-    if (m_resource->errorOccurred())
-        return;
-
-    if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors()) {
-        // Prevent the document from being destroyed before we are done with
-        // the cachedResourceLoader that it will delete when the document gets deleted.
-        RefPtr<Document> protector(m_cachedResourceLoader->document());
-        if (!m_multipart)
-            m_cachedResourceLoader->decrementRequestCount(m_resource);
-        m_finishing = true;
-        m_loader->clearClient();
-        m_resource->error(CachedResource::LoadError);
-        end();
-        return;
-    }
-
-    // There are two cases where we might need to create our own SharedBuffer instead of copying the one in ResourceLoader.
-    // (1) Multipart content: The loader delivers the data in a multipart section all at once, then sends eof.
-    //     The resource data will change as the next part is loaded, so we need to make a copy.
-    // (2) Our client requested that the data not be buffered at the ResourceLoader level via ResourceLoaderOptions. In this case,
-    //     ResourceLoader::resourceData() will be null. However, unlike the multipart case, we don't want to tell the CachedResource
-    //     that all data has been received yet.
-    if (m_multipart || !loader->resourceData()) {
-        RefPtr<SharedBuffer> copiedData = SharedBuffer::create(data, size);
-        m_resource->data(copiedData.release(), m_multipart);
-    } else
-        m_resource->data(loader->resourceData(), false);
-}
-
-void CachedResourceRequest::didReceiveCachedMetadata(SubresourceLoader*, const char* data, int size)
-{
-    ASSERT(!m_resource->isCacheValidator());
-    m_resource->setSerializedCachedMetadata(data, size);
-}
-
-void CachedResourceRequest::didSendData(SubresourceLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
-{
-    m_resource->didSendData(bytesSent, totalBytesToBeSent);
-}
-
-void CachedResourceRequest::end()
-{
-    m_cachedResourceLoader->loadDone();
-    m_resource->stopLoading();
-}
-
-} //namespace WebCore
diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.h b/Source/WebCore/loader/cache/CachedResourceRequest.h
deleted file mode 100644 (file)
index 3176608..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
-    Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
-    Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CachedResourceRequest_h
-#define CachedResourceRequest_h
-
-#include "FrameLoaderTypes.h"
-#include "ResourceHandle.h"
-#include "ResourceLoaderOptions.h"
-#include "SubresourceLoaderClient.h"
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-    class CachedResource;
-    class CachedResourceLoader;
-    class ResourceError;
-    class ResourceRequest;
-    class ResourceResponse;
-    class SubresourceLoader;
-
-    class CachedResourceRequest : private SubresourceLoaderClient {
-    public:
-        static PassOwnPtr<CachedResourceRequest> load(CachedResourceLoader*, CachedResource*, const ResourceLoaderOptions&);
-        ~CachedResourceRequest();
-
-        CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; }
-        void cancel();
-
-        // FIXME: Like CachedResource::identifier(), this is a lame hack for preflight InspectorInstrumentation in DocumentThreadableLoader.
-        unsigned long identifier() const;
-
-        // FIXME: See CachedRawResource::setDefersLoading() for the relevant rant.
-        void setDefersLoading(bool);
-
-    private:
-        CachedResourceRequest(CachedResourceLoader*, CachedResource*);
-        virtual void willSendRequest(SubresourceLoader*, ResourceRequest&, const ResourceResponse&);
-        virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
-        virtual void didReceiveData(SubresourceLoader*, const char*, int);
-        virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int);
-        virtual void didFinishLoading(SubresourceLoader*, double);
-        virtual void didFail(SubresourceLoader*, const ResourceError&);
-        void end();
-
-        virtual void didSendData(SubresourceLoader*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/);
-#if PLATFORM(CHROMIUM)
-        virtual void didDownloadData(SubresourceLoader*, int);
-#endif
-
-        RefPtr<SubresourceLoader> m_loader;
-        CachedResourceLoader* m_cachedResourceLoader;
-        CachedResource* m_resource;
-        bool m_multipart;
-        bool m_finishing;
-    };
-
-}
-
-#endif
index ee72cbe..562d12c 100644 (file)
@@ -25,8 +25,6 @@
 #include "config.h"
 #include "SubresourceLoader.h"
 
-#include "SubresourceLoaderClient.h"
-
 namespace WebCore {
 
 #if HAVE(NETWORK_CFDATA_ARRAY_CALLBACK)
@@ -46,7 +44,7 @@ void SubresourceLoader::didReceiveDataArray(CFArrayRef dataArray)
             if (!m_client)
                 break;
             CFDataRef data = reinterpret_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, i));
-            m_client->didReceiveData(this, reinterpret_cast<const char *>(CFDataGetBytePtr(data)), static_cast<int>(CFDataGetLength(data)));
+            didReceiveData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), static_cast<int>(CFDataGetLength(data)), -1, false);
         }
     }
 }
diff --git a/Source/WebCore/loader/chromium/CachedResourceRequestChromium.cpp b/Source/WebCore/loader/chromium/CachedResourceRequestChromium.cpp
deleted file mode 100644 (file)
index daa6b8a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011, Google 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:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CachedResourceRequest.h"
-
-#include "CachedResource.h"
-#include "SubresourceLoader.h"
-
-namespace WebCore {
-
-void CachedResourceRequest::didDownloadData(SubresourceLoader* loader, int length)
-{
-    ASSERT_UNUSED(loader, loader == m_loader);
-    m_resource->didDownloadData(length);
-}
-
-}
index fc97cf2..e9339b4 100644 (file)
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "SubresourceLoader.h"
 
-#include "SubresourceLoaderClient.h"
+#include "CachedResource.h"
 #include <wtf/RefCountedLeakCounter.h>
 
 namespace WebCore {
@@ -43,9 +43,7 @@ void SubresourceLoader::didDownloadData(int length)
     RefPtr<SubresourceLoader> protect(this);
     
     ResourceLoader::didDownloadData(length);
-
-    if (m_client)
-        m_client->didDownloadData(this, length);
+    m_resource->didDownloadData(length);
 }
 
 }