Changeset 100311 in webkit


Ignore:
Timestamp:
Nov 15, 2011 12:40:12 PM (12 years ago)
Author:
Nate Chapin
Message:

Source/WebCore: 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:

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:
Location:
trunk
Files:
4 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r100310 r100311  
     12011-11-15  Nate Chapin  <japhet@chromium.org>
     2
     3        Test udpates for https://bugs.webkit.org/show_bug.cgi?id=71149.
     4        The changes to SubresourceLoader slightly change the timings of
     5        certain resource load callbacks.
     6        https://bugs.webkit.org/show_bug.cgi?id=71149
     7
     8        Reviewed by Adam Barth.
     9
     10        * fast/loader/file-protocol-fragment-expected.txt:
     11        * platform/chromium-cg-mac/security/block-test-expected.txt:
     12        * platform/chromium-mac/security/block-test-expected.txt:
     13        * platform/chromium-win/security/block-test-expected.txt:
     14        * platform/mac/fast/images/support-broken-image-delegate-expected.txt:
     15        * platform/mac/security/block-test-expected.txt:
     16        * platform/mac/webarchive/loading/cache-expired-subresource-expected.txt:
     17
    1182011-11-15  Gavin Barraclough  <barraclough@apple.com>
    219
  • trunk/LayoutTests/fast/loader/file-protocol-fragment-expected.txt

    r84930 r100311  
    55resources/stylesheet.css - didFinishLoading
    66resources/stylesheet.css - didReceiveResponse <NSURLResponse resources/stylesheet.css, http status code 0>
     7resources/stylesheet.css - didFinishLoading
    78This tests that file: URL are loaded separately even if they differ by the fragment only.
  • trunk/LayoutTests/platform/chromium-cg-mac/security/block-test-expected.txt

    r56251 r100311  
    11http://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)
    22<unknown> - didFinishLoading
     3http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    34http://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)
    4 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    55http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
    66http://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)
  • trunk/LayoutTests/platform/chromium-mac/security/block-test-expected.txt

    r94434 r100311  
    11http://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)
    22<unknown> - didFinishLoading
     3http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    34http://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)
    4 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    55http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
    66http://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)
  • trunk/LayoutTests/platform/chromium-win/security/block-test-expected.txt

    r56271 r100311  
    11http://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)
    22<unknown> - didFinishLoading
     3http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    34http://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)
    4 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    55http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
    66http://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)
  • trunk/LayoutTests/platform/mac/fast/images/support-broken-image-delegate-expected.txt

    r79771 r100311  
    33resources/broken-image-with-invalid-format.png - didReceiveResponse <NSURLResponse resources/broken-image-with-invalid-format.png, http status code 0>
    44resources/broken-image-with-invalid-format.png - shouldPaintBrokenImage: NO
     5resources/broken-image-with-invalid-format.png - didFinishLoading
    56Radar 8610908 - Add a resource delegate method to query if WebCore should paint the broken image.
    67
  • trunk/LayoutTests/platform/mac/security/block-test-expected.txt

    r78383 r100311  
    11http://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)
    22<unknown> - didFinishLoading
     3http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    34http://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)
    4 http://255.255.255.255:1/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:1/test.jpg">
    55http://255.255.255.255:7/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:7/test.jpg">
    66http://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)
  • trunk/LayoutTests/platform/mac/webarchive/loading/cache-expired-subresource-expected.txt

    r63403 r100311  
    1111resources/cache-expired-subresource.webarchive - didFinishLoading
    1212http://localhost/pink-bullet.png - didReceiveResponse <NSURLResponse http://localhost/test.php, http status code 200>
     13http://localhost/pink-bullet.png - didFinishLoading
    1314frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
    1415main frame - didHandleOnloadEventsForFrame
  • trunk/LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt

    r99031 r100311  
    1111resources/subresource-null-mimetype.webarchive - didFinishLoading
    1212file:///test.png - didReceiveResponse <NSURLResponse file:///Users/pecoraro/Desktop/test.png, http status code 0>
     13file:///test.png - didFinishLoading
    1314frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
    1415main frame - didHandleOnloadEventsForFrame
  • trunk/Source/WebCore/CMakeLists.txt

    r100255 r100311  
    961961    loader/cache/CachedResourceHandle.cpp
    962962    loader/cache/CachedResourceLoader.cpp
    963     loader/cache/CachedResourceRequest.cpp
    964963    loader/cache/CachedScript.cpp
    965964    loader/cache/CachedXSLStyleSheet.cpp
  • trunk/Source/WebCore/ChangeLog

    r100309 r100311  
     12011-11-15  Nate Chapin  <japhet@chromium.org>
     2
     3        CachedResourceRequest is now the only SubresourceLoaderClient
     4        Merge CachedResourceRequest into SubresourceLoader and delete
     5        the SubresourceLoaderClient interface. A few items were moved
     6        to CachedResource instead of SubresourceLoader.
     7        https://bugs.webkit.org/show_bug.cgi?id=71149
     8
     9        Reviewed by Adam Barth.
     10
     11        * CMakeLists.txt:
     12        * GNUmakefile.list.am:
     13        * WebCore.gypi:
     14        * WebCore.pro:
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * loader/ResourceLoadScheduler.cpp:
     18        * loader/ResourceLoadScheduler.h:
     19        * loader/ResourceLoader.cpp:
     20        * loader/SubresourceLoader.cpp:
     21        (WebCore::SubresourceLoader::SubresourceLoader):
     22        (WebCore::SubresourceLoader::create):
     23        (WebCore::SubresourceLoader::init): Do work that had previously been
     24            done in SubresourceLoader::create() after the constructor.
     25        (WebCore::SubresourceLoader::willSendRequest):
     26        (WebCore::SubresourceLoader::didSendData):
     27        (WebCore::SubresourceLoader::didReceiveResponse):
     28        (WebCore::SubresourceLoader::didReceiveData):
     29        (WebCore::SubresourceLoader::didReceiveCachedMetadata):
     30        (WebCore::SubresourceLoader::didFinishLoading):
     31        (WebCore::SubresourceLoader::didFail):
     32        (WebCore::SubresourceLoader::willCancel):
     33        (WebCore::SubresourceLoader::releaseResources): Do the cleanup work that was
     34            duplicated throughout the various terminal CachedResourceRequest callbacks.
     35        * loader/SubresourceLoader.h: Fix indentation style issues.
     36        * loader/SubresourceLoaderClient.h: Removed.
     37        * loader/cache/CachedImage.cpp:
     38        * loader/cache/CachedRawResource.cpp:
     39        * loader/cache/CachedResource.cpp:
     40        (WebCore::cachedResourceTypeToTargetType):
     41        (WebCore::CachedResource::load): Do the work that had been done in
     42            CachedResourceRequest::load().
     43        (WebCore::CachedResource::finish):
     44        (WebCore::CachedResource::setResponse):
     45        (WebCore::CachedResource::stopLoading):
     46        * loader/cache/CachedResource.h:
     47        (WebCore::CachedResource::canDelete):
     48        * loader/cache/CachedResourceLoader.cpp:
     49        * loader/cache/CachedResourceRequest.cpp: Removed.
     50        * loader/cache/CachedResourceRequest.h: Removed.
     51        * loader/cf/SubresourceLoaderCF.cpp:
     52        * loader/chromium/CachedResourceRequestChromium.cpp: Removed.
     53        * loader/chromium/SubresourceLoaderChromium.cpp:
     54
    1552011-11-15  Anders Carlsson  <andersca@apple.com>
    256
  • trunk/Source/WebCore/GNUmakefile.list.am

    r100191 r100311  
    21662166        Source/WebCore/loader/cache/CachedResourceLoader.cpp \
    21672167        Source/WebCore/loader/cache/CachedResourceLoader.h \
    2168         Source/WebCore/loader/cache/CachedResourceRequest.cpp \
    2169         Source/WebCore/loader/cache/CachedResourceRequest.h \
    21702168        Source/WebCore/loader/cache/CachedScript.cpp \
    21712169        Source/WebCore/loader/cache/CachedScript.h \
     
    22562254        Source/WebCore/loader/SubframeLoader.cpp \
    22572255        Source/WebCore/loader/SubframeLoader.h \
    2258         Source/WebCore/loader/SubresourceLoaderClient.h \
    22592256        Source/WebCore/loader/SubresourceLoader.cpp \
    22602257        Source/WebCore/loader/SubresourceLoader.h \
  • trunk/Source/WebCore/Target.pri

    r100266 r100311  
    909909    loader/cache/CachedRawResource.cpp \
    910910    loader/cache/CachedResourceHandle.cpp \
    911     loader/cache/CachedResourceRequest.cpp \
    912911    loader/cache/CachedResource.cpp \
    913912    loader/cache/CachedScript.cpp \
     
    19511950    loader/cache/CachedResource.h \
    19521951    loader/cache/CachedResourceHandle.h \
    1953     loader/cache/CachedResourceRequest.h \
    19541952    loader/cache/CachedScript.h \
    19551953    loader/cache/CachedXSLStyleSheet.h \
  • trunk/Source/WebCore/WebCore.gypi

    r100191 r100311  
    578578            'loader/SubframeLoader.h',
    579579            'loader/SubresourceLoader.h',
    580             'loader/SubresourceLoaderClient.h',
    581580            'loader/SubstituteData.h',
    582581            'loader/SubstituteResource.h',
     
    597596            'loader/cache/CachedResourceHandle.h',
    598597            'loader/cache/CachedResourceLoader.h',
    599             'loader/cache/CachedResourceRequest.h',
    600598            'loader/cache/CachedStyleSheetClient.h',
    601599            'loader/cache/MemoryCache.h',
     
    28622860            'loader/cache/CachedResourceHandle.cpp',
    28632861            'loader/cache/CachedResourceLoader.cpp',
    2864             'loader/cache/CachedResourceRequest.cpp',
    28652862            'loader/cache/CachedScript.cpp',
    28662863            'loader/cache/CachedScript.h',
     
    28722869            'loader/cf/ResourceLoaderCFNet.cpp',
    28732870            'loader/chromium/CachedRawResourceChromium.cpp',
    2874             'loader/chromium/CachedResourceRequestChromium.cpp',
    28752871            'loader/chromium/DocumentThreadableLoaderChromium.cpp',
    28762872            'loader/chromium/ResourceLoaderChromium.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r100198 r100311  
    2589525895                        </File>
    2589625896                        <File
    25897                                 RelativePath="..\loader\SubresourceLoaderClient.h"
    25898                                 >
    25899                         </File>
    25900                         <File
    2590125897                                RelativePath="..\loader\SubstituteData.h"
    2590225898                                >
     
    2618726183                                <File
    2618826184                                        RelativePath="..\loader\cache\CachedResourceLoader.h"
    26189                                         >
    26190                                 </File>
    26191                                 <File
    26192                                         RelativePath="..\loader\cache\CachedResourceRequest.cpp"
    26193                                         >
    26194                                 </File>
    26195                                 <File
    26196                                         RelativePath="..\loader\cache\CachedResourceRequest.h"
    2619726185                                        >
    2619826186                                </File>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r100178 r100311  
    361361                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E580CC55213004A2062 /* SQLValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    362362                1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
    363                 1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    364363                1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */; };
    365364                1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */; };
     
    57645763                D0CE58F8125E4CC200F3F199 /* ResourceLoadScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0CE58F6125E4CC200F3F199 /* ResourceLoadScheduler.cpp */; };
    57655764                D0CE58F9125E4CC200F3F199 /* ResourceLoadScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    5766                 D0D141B212B2BF5200E39620 /* CachedResourceRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */; };
    5767                 D0D141B312B2BF5200E39620 /* CachedResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
    57685765                D0EDA774143E303C0028E383 /* CachedRawResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0EDA772143E303C0028E383 /* CachedRawResource.cpp */; };
    57695766                D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EDA773143E303C0028E383 /* CachedRawResource.h */; };
     
    74257422                1A2E6E580CC55213004A2062 /* SQLValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLValue.h; path = sql/SQLValue.h; sourceTree = "<group>"; };
    74267423                1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteAuthorizer.cpp; path = sql/SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
    7427                 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceLoaderClient.h; sourceTree = "<group>"; };
    74287424                1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomVoidCallback.h; sourceTree = "<group>"; };
    74297425                1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomVoidCallback.cpp; sourceTree = "<group>"; };
     
    1309613092                D0CE58F6125E4CC200F3F199 /* ResourceLoadScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadScheduler.cpp; sourceTree = "<group>"; };
    1309713093                D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadScheduler.h; sourceTree = "<group>"; };
    13098                 D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequest.cpp; sourceTree = "<group>"; };
    13099                 D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequest.h; sourceTree = "<group>"; };
    1310013094                D0EDA772143E303C0028E383 /* CachedRawResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedRawResource.cpp; sourceTree = "<group>"; };
    1310113095                D0EDA773143E303C0028E383 /* CachedRawResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRawResource.h; sourceTree = "<group>"; };
     
    1849818492                                BCB16C100979C3BD00467741 /* CachedResourceLoader.cpp */,
    1849918493                                BCB16C110979C3BD00467741 /* CachedResourceLoader.h */,
    18500                                 D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */,
    18501                                 D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */,
    1850218494                                BCB16C0A0979C3BD00467741 /* CachedScript.cpp */,
    1850318495                                BCB16C0B0979C3BD00467741 /* CachedScript.h */,
     
    1995019942                                93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */,
    1995119943                                656D37300ADBA5DE00A4554D /* SubresourceLoader.h */,
    19952                                 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */,
    1995319944                                659A7D120B6DB4D9001155B3 /* SubstituteData.h */,
    1995419945                                1A8F6B010DB53006001DB794 /* SubstituteResource.h */,
     
    2180421795                                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */,
    2180521796                                BCB16C2A0979C3BD00467741 /* CachedResourceLoader.h in Headers */,
    21806                                 D0D141B312B2BF5200E39620 /* CachedResourceRequest.h in Headers */,
    2180721797                                BCB16C240979C3BD00467741 /* CachedScript.h in Headers */,
    2180821798                                BCD533640ED6848900887468 /* CachedScriptSourceProvider.h in Headers */,
     
    2414424134                                F55B3DD41251F12D003EF269 /* SubmitInputType.h in Headers */,
    2414524135                                656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */,
    24146                                 1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */,
    2414724136                                659A7D130B6DB4D9001155B3 /* SubstituteData.h in Headers */,
    2414824137                                1A8F6B020DB53006001DB794 /* SubstituteResource.h in Headers */,
     
    2515525144                                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */,
    2515625145                                BCB16C290979C3BD00467741 /* CachedResourceLoader.cpp in Sources */,
    25157                                 D0D141B212B2BF5200E39620 /* CachedResourceRequest.cpp in Sources */,
    2515825146                                BCB16C230979C3BD00467741 /* CachedScript.cpp in Sources */,
    2515925147                                BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
  • trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp

    r96060 r100311  
    8686}
    8787
    88 PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
    89 {
    90     RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, client, request, options);
     88PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, CachedResource* resource, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
     89{
     90    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, resource, request, options);
    9191    if (loader)
    9292        scheduleLoad(loader.get(), priority);
  • trunk/Source/WebCore/loader/ResourceLoadScheduler.h

    r96060 r100311  
    3838namespace WebCore {
    3939
     40class CachedResource;
    4041class Frame;
    4142class KURL;
     
    4546class ResourceRequest;
    4647class SubresourceLoader;
    47 class SubresourceLoaderClient;
    4848
    4949class ResourceLoadScheduler {
     
    5252    friend ResourceLoadScheduler* resourceLoadScheduler();
    5353
    54     PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
     54    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, CachedResource*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
    5555    PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
    5656    void addMainResourceLoad(ResourceLoader*);
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r96249 r100311  
    132132    willSendRequest(clientRequest, ResourceResponse());
    133133    if (clientRequest.isNull()) {
    134         didFail(cancelledError());
     134        cancel();
    135135        return false;
    136136    }
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r99659 r100311  
    3030#include "SubresourceLoader.h"
    3131
     32#include "CachedImage.h"
     33#include "CachedResourceLoader.h"
    3234#include "Document.h"
    3335#include "DocumentLoader.h"
    3436#include "Frame.h"
    3537#include "FrameLoader.h"
    36 #include "ResourceHandle.h"
     38#include "Logging.h"
     39#include "MemoryCache.h"
    3740#include "SecurityOrigin.h"
    3841#include "SecurityPolicy.h"
    39 #include "SubresourceLoaderClient.h"
    4042#include <wtf/RefCountedLeakCounter.h>
    4143#include <wtf/StdLibExtras.h>
     
    4547DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, subresourceLoaderCounter, ("SubresourceLoader"));
    4648
    47 SubresourceLoader::SubresourceLoader(Frame* frame, SubresourceLoaderClient* client, const ResourceLoaderOptions& options)
     49SubresourceLoader::SubresourceLoader(Frame* frame, CachedResource* resource, const ResourceLoaderOptions& options)
    4850    : ResourceLoader(frame, options)
    49     , m_client(client)
     51    , m_resource(resource)
     52    , m_document(frame->document())
    5053    , m_loadingMultipartContent(false)
     54    , m_state(Uninitialized)
    5155{
    5256#ifndef NDEBUG
     
    6266}
    6367
    64 PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, const ResourceLoaderOptions& options)
     68PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
    6569{
    6670    if (!frame)
     
    9599    frameLoader->addExtraFieldsToSubresourceRequest(newRequest);
    96100
    97     RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(frame, client, options)));
     101    RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(frame, resource, options)));
    98102    if (!subloader->init(newRequest))
    99103        return 0;
    100     subloader->documentLoader()->addSubresourceLoader(subloader.get());
    101 
    102104    return subloader.release();
     105}
     106
     107bool SubresourceLoader::init(const ResourceRequest& request)
     108{
     109    if (!ResourceLoader::init(request))
     110        return false;
     111
     112    m_state = Initialized;
     113    m_documentLoader->addSubresourceLoader(this);
     114    return true;
    103115}
    104116
     
    109121   
    110122    ResourceLoader::willSendRequest(newRequest, redirectResponse);
    111     if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url() && m_client)
    112         m_client->willSendRequest(this, newRequest, redirectResponse);
     123    if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url()) {
     124        if (!m_document->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
     125            cancel();
     126            return;
     127        }
     128        m_resource->willSendRequest(newRequest, redirectResponse);
     129    }
    113130}
    114131
     
    116133{
    117134    RefPtr<SubresourceLoader> protect(this);
    118 
    119     if (m_client)
    120         m_client->didSendData(this, bytesSent, totalBytesToBeSent);
    121 }
    122 
    123 void SubresourceLoader::didReceiveResponse(const ResourceResponse& r)
    124 {
    125     ASSERT(!r.isNull());
    126 
    127     if (r.isMultipart())
    128         m_loadingMultipartContent = true;
     135    m_resource->didSendData(bytesSent, totalBytesToBeSent);
     136}
     137
     138void SubresourceLoader::didReceiveResponse(const ResourceResponse& response)
     139{
     140    ASSERT(!response.isNull());
    129141
    130142    // Reference the object in this method since the additional processing can do
     
    132144    RefPtr<SubresourceLoader> protect(this);
    133145
    134     if (m_client)
    135         m_client->didReceiveResponse(this, r);
    136    
    137     // The loader can cancel a load if it receives a multipart response for a non-image
     146    if (m_resource->resourceToRevalidate()) {
     147        if (response.httpStatusCode() == 304) {
     148            // 304 Not modified / Use local copy
     149            // Existing resource is ok, just use it updating the expiration time.
     150            memoryCache()->revalidationSucceeded(m_resource, response);
     151            ResourceLoader::didReceiveResponse(response);
     152            return;
     153        }
     154        // Did not get 304 response, continue as a regular resource load.
     155        memoryCache()->revalidationFailed(m_resource);
     156    }
     157
     158    m_resource->setResponse(response);
    138159    if (reachedTerminalState())
    139160        return;
    140     ResourceLoader::didReceiveResponse(r);
    141    
     161    ResourceLoader::didReceiveResponse(response);
     162
     163    if (m_loadingMultipartContent) {
     164        ASSERT(m_resource->isImage());
     165        static_cast<CachedImage*>(m_resource)->clear();
     166    } else if (response.isMultipart()) {
     167        m_loadingMultipartContent = true;
     168
     169        // We don't count multiParts in a CachedResourceLoader's request count
     170        m_document->cachedResourceLoader()->decrementRequestCount(m_resource);
     171        if (!m_resource->isImage()) {
     172            cancel();
     173            return;
     174        }
     175    }
     176
    142177    RefPtr<SharedBuffer> buffer = resourceData();
    143178    if (m_loadingMultipartContent && buffer && buffer->size()) {
     
    145180        // deliver the previously received data to the loader all at once now.
    146181        // Then clear the data to make way for the next multipart section.
    147         if (m_client)
    148             m_client->didReceiveData(this, buffer->data(), buffer->size());
     182        didReceiveData(buffer->data(), buffer->size(), -1, true);
    149183        clearResourceData();
    150184       
     
    157191void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
    158192{
     193    ASSERT(!m_resource->resourceToRevalidate());
     194    ASSERT(!m_resource->errorOccurred());
    159195    // Reference the object in this method since the additional processing can do
    160196    // anything including removing the last reference to this object; one example of this is 3266216.
    161197    RefPtr<SubresourceLoader> protect(this);
    162    
    163198    ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
    164199
    165     // A subresource loader does not load multipart sections progressively.
    166     // So don't deliver any data to the loader yet.
    167     if (!m_loadingMultipartContent && m_client)
    168         m_client->didReceiveData(this, data, length);
     200    if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors()) {
     201        m_resource->error(CachedResource::LoadError);
     202        m_state = Finishing;
     203        cancel();
     204        return;
     205    }
     206
     207    // There are two cases where we might need to create our own SharedBuffer instead of copying the one in ResourceLoader.
     208    // (1) Multipart content: The loader delivers the data in a multipart section all at once, then sends eof.
     209    //     The resource data will change as the next part is loaded, so we need to make a copy.
     210    // (2) Our client requested that the data not be buffered at the ResourceLoader level via ResourceLoaderOptions. In this case,
     211    //     ResourceLoader::resourceData() will be null. However, unlike the multipart case, we don't want to tell the CachedResource
     212    //     that all data has been received yet.
     213    if (m_loadingMultipartContent || !resourceData()) {
     214        RefPtr<SharedBuffer> copiedData = SharedBuffer::create(data, length);
     215        m_resource->data(copiedData.release(), m_loadingMultipartContent);
     216    } else
     217        m_resource->data(resourceData(), false);
    169218}
    170219
    171220void SubresourceLoader::didReceiveCachedMetadata(const char* data, int length)
    172221{
    173     // Reference the object in this method since the additional processing can do
    174     // anything including removing the last reference to this object; one example of this is 3266216.
    175     RefPtr<SubresourceLoader> protect(this);
    176    
    177     if (m_client)
    178         m_client->didReceiveCachedMetadata(this, data, length);
     222    ASSERT(!m_resource->resourceToRevalidate());
     223    m_resource->setSerializedCachedMetadata(data, length);
    179224}
    180225
    181226void SubresourceLoader::didFinishLoading(double finishTime)
    182227{
    183     if (cancelled())
    184         return;
    185     ASSERT(!reachedTerminalState());
    186 
    187     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
    188     RefPtr<SubresourceLoader> protect(this);
    189 
    190     if (m_client)
    191         m_client->didFinishLoading(this, finishTime);
    192    
    193     m_handle = 0;
    194 
    195     if (cancelled())
    196         return;
    197     m_documentLoader->removeSubresourceLoader(this);
     228    if (m_state != Initialized)
     229        return;
     230    ASSERT(!reachedTerminalState());
     231    ASSERT(!m_resource->resourceToRevalidate());
     232    ASSERT(!m_resource->errorOccurred());
     233    LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data());
     234
     235    RefPtr<SubresourceLoader> protect(this);
     236    m_state = Finishing;
     237    m_resource->setLoadFinishTime(finishTime);
     238    m_resource->data(resourceData(), true);
     239    m_resource->finish();
    198240    ResourceLoader::didFinishLoading(finishTime);
    199241}
     
    201243void SubresourceLoader::didFail(const ResourceError& error)
    202244{
    203     if (cancelled())
    204         return;
    205     ASSERT(!reachedTerminalState());
    206 
    207     // Calling removeSubresourceLoader will likely result in a call to deref, so we must protect ourselves.
    208     RefPtr<SubresourceLoader> protect(this);
    209 
    210     if (m_client)
    211         m_client->didFail(this, error);
    212    
    213     m_handle = 0;
    214    
    215     if (cancelled())
    216         return;
    217     m_documentLoader->removeSubresourceLoader(this);
     245    if (m_state != Initialized)
     246        return;
     247    ASSERT(!reachedTerminalState());
     248    ASSERT(!m_resource->resourceToRevalidate());
     249    LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
     250
     251    RefPtr<SubresourceLoader> protect(this);
     252    m_state = Finishing;
     253    m_resource->error(CachedResource::LoadError);
     254    if (!m_resource->isPreloaded())
     255        memoryCache()->remove(m_resource);
    218256    ResourceLoader::didFail(error);
    219257}
    220258
    221 void SubresourceLoader::willCancel(const ResourceError& error)
    222 {
    223     if (m_client)
    224         m_client->didFail(this, error);
    225 }
    226 
    227 void SubresourceLoader::didCancel(const ResourceError&)
    228 {
    229     m_documentLoader->removeSubresourceLoader(this);
    230 }
    231 
    232 }
     259void SubresourceLoader::willCancel(const ResourceError&)
     260{
     261    if (m_state != Initialized)
     262        return;
     263    ASSERT(!reachedTerminalState());
     264    LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string().latin1().data());
     265
     266    RefPtr<SubresourceLoader> protect(this);
     267    m_state = Finishing;
     268    if (m_resource->resourceToRevalidate())
     269        memoryCache()->revalidationFailed(m_resource);
     270    memoryCache()->remove(m_resource);
     271}
     272
     273void SubresourceLoader::releaseResources()
     274{
     275    ASSERT(!reachedTerminalState());
     276    if (m_state != Uninitialized) {
     277        if (!m_loadingMultipartContent && m_state != Releasing)
     278            m_document->cachedResourceLoader()->decrementRequestCount(m_resource);
     279        m_state = Releasing;
     280        m_document->cachedResourceLoader()->loadDone();
     281        if (reachedTerminalState())
     282            return;
     283        m_resource->stopLoading();
     284        m_documentLoader->removeSubresourceLoader(this);
     285    }
     286    m_document = 0;
     287    ResourceLoader::releaseResources();
     288}
     289
     290}
  • trunk/Source/WebCore/loader/SubresourceLoader.h

    r96060 r100311  
    3737namespace WebCore {
    3838
    39     class ResourceRequest;
    40     class SubresourceLoaderClient;
    41    
    42     class SubresourceLoader : public ResourceLoader {
    43     public:
    44         static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, const ResourceRequest&, const ResourceLoaderOptions&);
     39class CachedResource;
     40class Document;
     41class ResourceRequest;
    4542
    46         void clearClient() { m_client = 0; }
     43class SubresourceLoader : public ResourceLoader {
     44public:
     45    static PassRefPtr<SubresourceLoader> create(Frame*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
    4746
    48     private:
    49         SubresourceLoader(Frame*, SubresourceLoaderClient*, const ResourceLoaderOptions&);
    50         virtual ~SubresourceLoader();
    51        
    52         virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
    53         virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
    54         virtual void didReceiveResponse(const ResourceResponse&);
    55         virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
    56         virtual void didReceiveCachedMetadata(const char*, int);
    57         virtual void didFinishLoading(double finishTime);
    58         virtual void didFail(const ResourceError&);
    59         virtual void willCancel(const ResourceError&);
    60         virtual void didCancel(const ResourceError&);
     47private:
     48    SubresourceLoader(Frame*, CachedResource*, const ResourceLoaderOptions&);
     49    virtual ~SubresourceLoader();
     50    virtual bool init(const ResourceRequest&);
     51
     52    virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse);
     53    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
     54    virtual void didReceiveResponse(const ResourceResponse&);
     55    virtual void didReceiveData(const char*, int, long long encodedDataLength, bool allAtOnce);
     56    virtual void didReceiveCachedMetadata(const char*, int);
     57    virtual void didFinishLoading(double finishTime);
     58    virtual void didFail(const ResourceError&);
     59    virtual void willCancel(const ResourceError&);
     60    virtual void didCancel(const ResourceError&) { }
    6161
    6262#if HAVE(NETWORK_CFDATA_ARRAY_CALLBACK)
    63         virtual bool supportsDataArray() { return true; }
    64         virtual void didReceiveDataArray(CFArrayRef);
     63    virtual bool supportsDataArray() { return true; }
     64    virtual void didReceiveDataArray(CFArrayRef);
    6565#endif
    6666#if PLATFORM(CHROMIUM)
    67         virtual void didDownloadData(int);
     67    virtual void didDownloadData(int);
    6868#endif
     69    virtual void releaseResources();
    6970
    70         SubresourceLoaderClient* m_client;
    71         bool m_loadingMultipartContent;
     71    enum SubresourceLoaderState {
     72        Uninitialized,
     73        Initialized,
     74        Finishing,
     75        Releasing
    7276    };
     77
     78    CachedResource* m_resource;
     79    RefPtr<Document> m_document;
     80    bool m_loadingMultipartContent;
     81    SubresourceLoaderState m_state;
     82};
    7383
    7484}
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r99539 r100311  
    3030#include "CachedResourceClientWalker.h"
    3131#include "CachedResourceLoader.h"
    32 #include "CachedResourceRequest.h"
    3332#include "Frame.h"
    3433#include "FrameLoaderClient.h"
     
    3837#include "Settings.h"
    3938#include "SharedBuffer.h"
     39#include "SubresourceLoader.h"
    4040#include <wtf/CurrentTime.h>
    4141#include <wtf/StdLibExtras.h>
     
    288288void CachedImage::checkShouldPaintBrokenImage()
    289289{
    290     Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
    291     if (!frame)
    292         return;
    293 
    294     m_shouldPaintBrokenImage = frame->loader()->client()->shouldPaintBrokenImage(m_resourceRequest.url());
     290    if (!m_loader || m_loader->reachedTerminalState())
     291        return;
     292
     293    m_shouldPaintBrokenImage = m_loader->frameLoader()->client()->shouldPaintBrokenImage(m_resourceRequest.url());
    295294}
    296295
     
    329328size_t CachedImage::maximumDecodedImageSize()
    330329{
    331     Frame* frame = m_request ? m_request->cachedResourceLoader()->frame() : 0;
    332     if (!frame)
     330    if (!m_loader || m_loader->reachedTerminalState())
    333331        return 0;
    334     Settings* settings = frame->settings();
     332    Settings* settings = m_loader->frameLoader()->frame()->settings();
    335333    return settings ? settings->maximumDecodedImageSize() : 0;
    336334}
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r98380 r100311  
    3030#include "CachedResourceClientWalker.h"
    3131#include "CachedResourceLoader.h"
    32 #include "CachedResourceRequest.h"
    3332#include "SharedBuffer.h"
     33#include "SubresourceLoader.h"
    3434#include <wtf/PassRefPtr.h>
    3535
     
    7979void CachedRawResource::allClientsRemoved()
    8080{
    81     if (m_request)
    82         m_request->cancel();
     81    if (m_loader)
     82        m_loader->cancel();
    8383}
    8484
     
    110110void CachedRawResource::setDefersLoading(bool defers)
    111111{
    112     if (m_request)
    113         m_request->setDefersLoading(defers);
     112    if (m_loader)
     113        m_loader->setDefersLoading(defers);
    114114}
    115115
    116116unsigned long CachedRawResource::identifier() const
    117117{
    118     return m_request ? m_request->identifier() : 0;
     118    return m_loader ? m_loader->identifier() : 0;
    119119}
    120120
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r99565 r100311  
    3131#include "CachedResourceHandle.h"
    3232#include "CachedResourceLoader.h"
    33 #include "CachedResourceRequest.h"
    3433#include "CrossOriginAccessControl.h"
     34#include "Document.h"
    3535#include "Frame.h"
    3636#include "FrameLoaderClient.h"
     
    3939#include "PurgeableBuffer.h"
    4040#include "ResourceHandle.h"
     41#include "ResourceLoadScheduler.h"
    4142#include "SharedBuffer.h"
     43#include "SubresourceLoader.h"
    4244#include <wtf/CurrentTime.h>
    4345#include <wtf/MathExtras.h>
     
    8082    return ResourceLoadPriorityLow;
    8183}
     84
     85#if PLATFORM(CHROMIUM)
     86static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
     87{
     88    switch (type) {
     89    case CachedResource::CSSStyleSheet:
     90#if ENABLE(XSLT)
     91    case CachedResource::XSLStyleSheet:
     92#endif
     93        return ResourceRequest::TargetIsStyleSheet;
     94    case CachedResource::Script:
     95        return ResourceRequest::TargetIsScript;
     96    case CachedResource::FontResource:
     97        return ResourceRequest::TargetIsFontResource;
     98    case CachedResource::ImageResource:
     99        return ResourceRequest::TargetIsImage;
     100    case CachedResource::RawResource:
     101        return ResourceRequest::TargetIsSubresource;   
     102#if ENABLE(LINK_PREFETCH)
     103    case CachedResource::LinkPrefetch:
     104        return ResourceRequest::TargetIsPrefetch;
     105    case CachedResource::LinkPrerender:
     106        return ResourceRequest::TargetIsPrerender;
     107    case CachedResource::LinkSubresource:
     108        return ResourceRequest::TargetIsSubresource;
     109#endif
     110#if ENABLE(VIDEO_TRACK)
     111    case CachedResource::TextTrackResource:
     112        return ResourceRequest::TargetIsTextTrack;
     113#endif
     114    }
     115    ASSERT_NOT_REACHED();
     116    return ResourceRequest::TargetIsSubresource;
     117}
     118#endif
    82119
    83120DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("CachedResource"));
     
    140177    m_options = options;
    141178    m_loading = true;
    142     m_request = CachedResourceRequest::load(cachedResourceLoader, this, options);
    143     if (m_request) {
    144         m_status = Pending;
    145         cachedResourceLoader->incrementRequestCount(this);
    146     }
     179
     180#if PLATFORM(CHROMIUM)
     181    if (m_resourceRequest.targetType() == ResourceRequest::TargetIsUnspecified)
     182        m_resourceRequest.setTargetType(cachedResourceTypeToTargetType(type()));
     183#endif
     184
     185    if (!accept().isEmpty())
     186        m_resourceRequest.setHTTPAccept(accept());
     187
     188    if (isCacheValidator()) {
     189        CachedResource* resourceToRevalidate = m_resourceToRevalidate;
     190        ASSERT(resourceToRevalidate->canUseCacheValidator());
     191        ASSERT(resourceToRevalidate->isLoaded());
     192        const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified");
     193        const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag");
     194        if (!lastModified.isEmpty() || !eTag.isEmpty()) {
     195            ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload);
     196            if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate)
     197                m_resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0");
     198            if (!lastModified.isEmpty())
     199                m_resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified);
     200            if (!eTag.isEmpty())
     201                m_resourceRequest.setHTTPHeaderField("If-None-Match", eTag);
     202        }
     203    }
     204
     205#if ENABLE(LINK_PREFETCH)
     206    if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkPrerender || type() == CachedResource::LinkSubresource)
     207        m_resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
     208#endif
     209    m_resourceRequest.setPriority(loadPriority());
     210   
     211    m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), this, m_resourceRequest, m_resourceRequest.priority(), options);
     212    if (!m_loader || m_loader->reachedTerminalState()) {
     213        // FIXME: What if resources in other frames were waiting for this revalidation?
     214        LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().data());
     215        if (m_resourceToRevalidate)
     216            memoryCache()->revalidationFailed(this);
     217        error(CachedResource::LoadError);
     218        return;
     219    }
     220
     221    m_status = Pending;
     222    cachedResourceLoader->incrementRequestCount(this);
    147223}
    148224
     
    178254void CachedResource::finish()
    179255{
    180     m_status = Cached;
     256    if (!errorOccurred())
     257        m_status = Cached;
    181258}
    182259
     
    233310    m_response = response;
    234311    m_responseTimestamp = currentTime();
     312    String encoding = response.textEncodingName();
     313    if (!encoding.isNull())
     314        setEncoding(encoding);
    235315}
    236316
     
    265345void CachedResource::stopLoading()
    266346{
    267     ASSERT(m_request);           
    268     m_request.clear();
     347    ASSERT(m_loader);           
     348    m_loader = 0;
    269349
    270350    CachedResourceHandle<CachedResource> protect(this);
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r99565 r100311  
    4545class CachedResourceHandleBase;
    4646class CachedResourceLoader;
    47 class CachedResourceRequest;
    4847class Frame;
    4948class InspectorResource;
    5049class PurgeableBuffer;
    5150class SecurityOrigin;
     51class SubresourceLoader;
    5252
    5353// A resource that is held in the cache. Classes who want to use this object should derive
     
    188188    CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
    189189
    190     bool canDelete() const { return !hasClients() && !m_request && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
     190    bool canDelete() const { return !hasClients() && !m_loader && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
    191191    bool hasOneHandle() const { return m_handleCount == 1; }
    192192
     
    254254    ResourceRequest m_resourceRequest;
    255255    String m_accept;
    256     OwnPtr<CachedResourceRequest> m_request;
     256    RefPtr<SubresourceLoader> m_loader;
    257257    ResourceLoaderOptions m_options;
    258258    ResourceLoadPriority m_loadPriority;
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r99329 r100311  
    3232#include "CachedImage.h"
    3333#include "CachedRawResource.h"
    34 #include "CachedResourceRequest.h"
    3534#include "CachedScript.h"
    3635#include "CachedXSLStyleSheet.h"
  • trunk/Source/WebCore/loader/cf/SubresourceLoaderCF.cpp

    r95901 r100311  
    2626#include "SubresourceLoader.h"
    2727
    28 #include "SubresourceLoaderClient.h"
    29 
    3028namespace WebCore {
    3129
     
    4745                break;
    4846            CFDataRef data = reinterpret_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, i));
    49             m_client->didReceiveData(this, reinterpret_cast<const char *>(CFDataGetBytePtr(data)), static_cast<int>(CFDataGetLength(data)));
     47            didReceiveData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), static_cast<int>(CFDataGetLength(data)), -1, false);
    5048        }
    5149    }
  • trunk/Source/WebCore/loader/chromium/SubresourceLoaderChromium.cpp

    r95901 r100311  
    3232#include "SubresourceLoader.h"
    3333
    34 #include "SubresourceLoaderClient.h"
     34#include "CachedResource.h"
    3535#include <wtf/RefCountedLeakCounter.h>
    3636
     
    4444   
    4545    ResourceLoader::didDownloadData(length);
    46 
    47     if (m_client)
    48         m_client->didDownloadData(this, length);
     46    m_resource->didDownloadData(length);
    4947}
    5048
Note: See TracChangeset for help on using the changeset viewer.