Refactor CachedResourceLoader: add CachedResourceRequest
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 23:35:28 +0000 (23:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 23:35:28 +0000 (23:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99736

Patch by Marja Hölttä <marja@chromium.org> on 2012-10-22
Reviewed by Adam Barth.

For fixing bugs 84883 and 92761,
CachedResourceLoader::requestResource should take as parameter
information about who initiated the request. But the parameter
list was already long. This gathers all the parameters into a
separate class, CachedResourceRequest. The next step is to add
information about who initiated the request into
CachedResourceRequest.

No new tests because no changes in functionality, just moving code
around.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::cachedFont):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::cachedImageSet):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* css/StyleRuleImport.cpp:
(WebCore::StyleRuleImport::requestStyleSheet):
* css/WebKitCSSSVGDocumentValue.cpp:
(WebCore::WebKitCSSSVGDocumentValue::load):
* css/WebKitCSSShaderValue.cpp:
(WebCore::WebKitCSSShaderValue::cachedShader):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::loadLink):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::load):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::requestFont):
(WebCore::CachedResourceLoader::requestTextTrack):
(WebCore::CachedResourceLoader::requestShader):
(WebCore::CachedResourceLoader::requestCSSStyleSheet):
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestScript):
(WebCore::CachedResourceLoader::requestXSLStyleSheet):
(WebCore::CachedResourceLoader::requestSVGDocument):
(WebCore::CachedResourceLoader::requestLinkResource):
(WebCore::CachedResourceLoader::requestRawResource):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::requestPreload):
(WebCore::CachedResourceLoader::defaultCachedResourceOptions):
(WebCore):
* loader/cache/CachedResourceLoader.h:
(WebCore):
(CachedResourceLoader):
* loader/cache/CachedResourceRequest.cpp: Added.
(WebCore):
(WebCore::CachedResourceRequest::CachedResourceRequest):
* loader/cache/CachedResourceRequest.h: Added.
(WebCore):
(CachedResourceRequest):
(WebCore::CachedResourceRequest::mutableResourceRequest):
(WebCore::CachedResourceRequest::resourceRequest):
(WebCore::CachedResourceRequest::charset):
(WebCore::CachedResourceRequest::setCharset):
(WebCore::CachedResourceRequest::options):
(WebCore::CachedResourceRequest::priority):
(WebCore::CachedResourceRequest::forPreload):
(WebCore::CachedResourceRequest::setForPreload):
(WebCore::CachedResourceRequest::defer):
(WebCore::CachedResourceRequest::setDefer):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::svgAttributeChanged):
* xml/XSLImportRule.cpp:
(WebCore::XSLImportRule::loadSheet):

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

29 files changed:
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/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSImageSetValue.cpp
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/css/StyleRuleImport.cpp
Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
Source/WebCore/css/WebKitCSSShaderValue.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/LinkLoader.cpp
Source/WebCore/loader/TextTrackLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebCore/loader/cache/CachedResourceRequest.cpp [new file with mode: 0644]
Source/WebCore/loader/cache/CachedResourceRequest.h [new file with mode: 0644]
Source/WebCore/loader/icon/IconLoader.cpp
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/xml/XSLImportRule.cpp

index 78f9898..47b29e6 100644 (file)
@@ -1682,6 +1682,7 @@ 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/CachedShader.cpp
     loader/cache/CachedSVGDocument.cpp
index 240121e..b7f5c58 100644 (file)
@@ -1,3 +1,99 @@
+2012-10-22  Marja Hölttä  <marja@chromium.org>
+
+        Refactor CachedResourceLoader: add CachedResourceRequest
+        https://bugs.webkit.org/show_bug.cgi?id=99736
+
+        Reviewed by Adam Barth.
+
+        For fixing bugs 84883 and 92761,
+        CachedResourceLoader::requestResource should take as parameter
+        information about who initiated the request. But the parameter
+        list was already long. This gathers all the parameters into a
+        separate class, CachedResourceRequest. The next step is to add
+        information about who initiated the request into
+        CachedResourceRequest.
+
+        No new tests because no changes in functionality, just moving code
+        around.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::cachedFont):
+        * css/CSSImageSetValue.cpp:
+        (WebCore::CSSImageSetValue::cachedImageSet):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::cachedImage):
+        * css/StyleRuleImport.cpp:
+        (WebCore::StyleRuleImport::requestStyleSheet):
+        * css/WebKitCSSSVGDocumentValue.cpp:
+        (WebCore::WebKitCSSSVGDocumentValue::load):
+        * css/WebKitCSSShaderValue.cpp:
+        (WebCore::WebKitCSSShaderValue::cachedShader):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::requestScript):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::loadRequest):
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateFromElement):
+        * loader/LinkLoader.cpp:
+        (WebCore::LinkLoader::loadLink):
+        * loader/TextTrackLoader.cpp:
+        (WebCore::TextTrackLoader::load):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestImage):
+        (WebCore::CachedResourceLoader::requestFont):
+        (WebCore::CachedResourceLoader::requestTextTrack):
+        (WebCore::CachedResourceLoader::requestShader):
+        (WebCore::CachedResourceLoader::requestCSSStyleSheet):
+        (WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
+        (WebCore::CachedResourceLoader::requestScript):
+        (WebCore::CachedResourceLoader::requestXSLStyleSheet):
+        (WebCore::CachedResourceLoader::requestSVGDocument):
+        (WebCore::CachedResourceLoader::requestLinkResource):
+        (WebCore::CachedResourceLoader::requestRawResource):
+        (WebCore::CachedResourceLoader::requestResource):
+        (WebCore::CachedResourceLoader::requestPreload):
+        (WebCore::CachedResourceLoader::defaultCachedResourceOptions):
+        (WebCore):
+        * loader/cache/CachedResourceLoader.h:
+        (WebCore):
+        (CachedResourceLoader):
+        * loader/cache/CachedResourceRequest.cpp: Added.
+        (WebCore):
+        (WebCore::CachedResourceRequest::CachedResourceRequest):
+        * loader/cache/CachedResourceRequest.h: Added.
+        (WebCore):
+        (CachedResourceRequest):
+        (WebCore::CachedResourceRequest::mutableResourceRequest):
+        (WebCore::CachedResourceRequest::resourceRequest):
+        (WebCore::CachedResourceRequest::charset):
+        (WebCore::CachedResourceRequest::setCharset):
+        (WebCore::CachedResourceRequest::options):
+        (WebCore::CachedResourceRequest::priority):
+        (WebCore::CachedResourceRequest::forPreload):
+        (WebCore::CachedResourceRequest::setForPreload):
+        (WebCore::CachedResourceRequest::defer):
+        (WebCore::CachedResourceRequest::setDefer):
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading):
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::requestImageResource):
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::loadFont):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::svgAttributeChanged):
+        * xml/XSLImportRule.cpp:
+        (WebCore::XSLImportRule::loadSheet):
+
 2012-10-22  Adam Barth  <abarth@webkit.org>
 
         [V8] ASSERT that removeAllDOMObjects() is called only on worker threads
index cff98c8..7b85ba4 100644 (file)
@@ -3845,6 +3845,8 @@ 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/CachedShader.cpp \
index 8afaaf5..f2c4d6d 100644 (file)
@@ -817,6 +817,7 @@ SOURCES += \
     loader/CrossOriginAccessControl.cpp \
     loader/CrossOriginPreflightResultCache.cpp \
     loader/cache/CachedResourceLoader.cpp \
+    loader/cache/CachedResourceRequest.cpp \
     loader/DocumentLoadTiming.cpp \
     loader/DocumentLoader.cpp \
     loader/DocumentThreadableLoader.cpp \
index b7073a3..aa9c33f 100644 (file)
             'loader/cache/CachedResourceClient.h',
             'loader/cache/CachedResourceHandle.h',
             'loader/cache/CachedResourceLoader.h',
+            'loader/cache/CachedResourceRequest.h',
             'loader/cache/CachedShader.h',
             'loader/cache/CachedStyleSheetClient.h',
             'loader/cache/MemoryCache.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/CachedShader.cpp',
index cb4fac7..44b470f 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\loader\cache\CachedResourceRequest.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\loader\cache\CachedResourceRequest.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\loader\cache\CachedScript.cpp"
                                        >
                                </File>
index 3689f46..6c15856 100644 (file)
                503D0CAB14B5B08700F32F57 /* CustomFilterProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CA814B5B08700F32F57 /* CustomFilterProgram.h */; settings = {ATTRIBUTES = (); }; };
                503D0CAC14B5B08700F32F57 /* CustomFilterProgramClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CA914B5B08700F32F57 /* CustomFilterProgramClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                503D0CAE14B5B0BA00F32F57 /* StyleCustomFilterProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CAD14B5B0BA00F32F57 /* StyleCustomFilterProgram.h */; settings = {ATTRIBUTES = (); }; };
+               5081E3C33CE580C16EF8B48B /* CachedResourceRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5081E3DF3CFC80C16EF8B48B /* CachedResourceRequest.cpp */; };
+               5081E3E03CFF80C16EF8B48B /* CachedResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
                508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */; };
                508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */; };
                50987C26157D676D00BDA835 /* CustomFilterGlobalContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50987C24157D676D00BDA835 /* CustomFilterGlobalContext.cpp */; };
                BCB16C0F0979C3BD00467741 /* CachedXSLStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedXSLStyleSheet.h; sourceTree = "<group>"; };
                BCB16C100979C3BD00467741 /* CachedResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceLoader.cpp; sourceTree = "<group>"; };
                BCB16C110979C3BD00467741 /* CachedResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceLoader.h; sourceTree = "<group>"; };
+               5081E3DF3CFC80C16EF8B48B /* CachedResourceRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequest.cpp; sourceTree = "<group>"; };
+               5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequest.h; sourceTree = "<group>"; };
                BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCondition.cpp; sourceTree = "<group>"; };
                BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilterCondition.h; sourceTree = "<group>"; };
                BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
                                E47B4BE60E71241600038854 /* CachedResourceHandle.h */,
                                BCB16C100979C3BD00467741 /* CachedResourceLoader.cpp */,
                                BCB16C110979C3BD00467741 /* CachedResourceLoader.h */,
+                               5081E3DF3CFC80C16EF8B48B /* CachedResourceRequest.cpp */,
+                               5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */,
                                BCB16C0A0979C3BD00467741 /* CachedScript.cpp */,
                                BCB16C0B0979C3BD00467741 /* CachedScript.h */,
                                5038BE3E1472AD980095E0D1 /* CachedShader.cpp */,
                                BCB16C220979C3BD00467741 /* CachedResourceClientWalker.h in Headers */,
                                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */,
                                BCB16C2A0979C3BD00467741 /* CachedResourceLoader.h in Headers */,
+                               5081E3E03CFF80C16EF8B48B /* CachedResourceRequest.h in Headers */,
                                BCB16C240979C3BD00467741 /* CachedScript.h in Headers */,
                                BCD533640ED6848900887468 /* CachedScriptSourceProvider.h in Headers */,
                                5038BE411472AD980095E0D1 /* CachedShader.h in Headers */,
                                BCB16C1F0979C3BD00467741 /* CachedResource.cpp in Sources */,
                                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */,
                                BCB16C290979C3BD00467741 /* CachedResourceLoader.cpp in Sources */,
+                               5081E3C33CE580C16EF8B48B /* CachedResourceRequest.cpp in Sources */,
                                BCB16C230979C3BD00467741 /* CachedScript.cpp in Sources */,
                                5038BE401472AD980095E0D1 /* CachedShader.cpp in Sources */,
                                A104F24314C71F7A009E2C23 /* CachedSVGDocument.cpp in Sources */,
index 2a1c047..3690789 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSFontFaceSrcValue.h"
 #include "CachedFont.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "FontCustomPlatformData.h"
 #include "Node.h"
@@ -95,7 +96,7 @@ bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const
 CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document)
 {
     if (!m_cachedFont) {
-        ResourceRequest request(document->completeURL(m_resource));
+        CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)));
         m_cachedFont = document->cachedResourceLoader()->requestFont(request);
     }
     return m_cachedFont.get();
@@ -113,4 +114,3 @@ void CSSFontFaceSrcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryOb
 }
 
 }
-
index 6e02a20..6dc76f5 100644 (file)
@@ -32,6 +32,7 @@
 #include "CSSPrimitiveValue.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "Page.h"
 #include "StyleCachedImageSet.h"
@@ -108,7 +109,7 @@ StyleCachedImageSet* CSSImageSetValue::cachedImageSet(CachedResourceLoader* load
         // All forms of scale should be included: Page::pageScaleFactor(), Frame::pageZoomFactor(),
         // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
         ImageWithScale image = bestImageForScaleFactor();
-        ResourceRequest request(loader->document()->completeURL(image.imageURL));
+        CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(image.imageURL)));
         if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request)) {
             m_imageSet = StyleCachedImageSet::create(cachedImage.get(), image.scaleFactor, this);
             m_accessedBestFitImage = true;
index 726c2c0..6b73d46 100644 (file)
@@ -26,6 +26,7 @@
 #include "CSSValueKeywords.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "MemoryCache.h"
 #include "StyleCachedImage.h"
@@ -82,7 +83,7 @@ StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const
     if (!m_accessedImage) {
         m_accessedImage = true;
 
-        ResourceRequest request(loader->document()->completeURL(url));
+        CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(url)));
         if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request))
             m_image = StyleCachedImage::create(cachedImage.get());
     }
index 26f29e8..eec3507 100644 (file)
@@ -25,6 +25,7 @@
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "SecurityOrigin.h"
 #include "StyleSheetContents.h"
@@ -115,11 +116,11 @@ void StyleRuleImport::requestStyleSheet()
         rootSheet = sheet;
     }
 
-    ResourceRequest request(absURL);
+    CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset());
     if (m_parentStyleSheet->isUserStyleSheet())
-        m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, m_parentStyleSheet->charset());
+        m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request);
     else
-        m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, m_parentStyleSheet->charset());
+        m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request);
     if (m_cachedSheet) {
         // if the import rule is issued dynamically, the sheet may be
         // removed from the pending sheet count, so let the doc know
index 44c8808..67e84e3 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "CSSParser.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "WebCoreMemoryInstrumentation.h"
 
@@ -52,7 +53,7 @@ CachedSVGDocument* WebKitCSSSVGDocumentValue::load(CachedResourceLoader* loader)
     if (!m_loadRequested) {
         m_loadRequested = true;
 
-        ResourceRequest request(loader->document()->completeURL(m_url));
+        CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
         m_document = loader->requestSVGDocument(request);
     }
 
index 6f9373e..fa04190 100644 (file)
@@ -32,8 +32,9 @@
 #if ENABLE(CSS_SHADERS)
 #include "WebKitCSSShaderValue.h"
 
-#include "CachedResourceLoader.h"
 #include "CSSParser.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "StyleCachedShader.h"
 #include "StylePendingShader.h"
@@ -59,7 +60,7 @@ StyleCachedShader* WebKitCSSShaderValue::cachedShader(CachedResourceLoader* load
     if (!m_accessedShader) {
         m_accessedShader = true;
 
-        ResourceRequest request(loader->document()->completeURL(m_url));
+        CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
         if (CachedResourceHandle<CachedShader> cachedShader = loader->requestShader(request))
             m_shader = StyleCachedShader::create(cachedShader.get());
     }
index 4bca1d1..ec1733c 100644 (file)
@@ -24,6 +24,7 @@
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "CachedXSLStyleSheet.h"
 #include "Document.h"
 #include "DocumentStyleSheetCollection.h"
@@ -163,7 +164,7 @@ void ProcessingInstruction::checkStyleSheet()
             m_loading = true;
             document()->styleSheetCollection()->addPendingSheet();
             
-            ResourceRequest request(document()->completeURL(href));
+            CachedResourceRequest request(ResourceRequest(document()->completeURL(href)));
 #if ENABLE(XSLT)
             if (m_isXSL)
                 m_cachedSheet = document()->cachedResourceLoader()->requestXSLStyleSheet(request);
@@ -173,8 +174,9 @@ void ProcessingInstruction::checkStyleSheet()
                 String charset = attrs.get("charset");
                 if (charset.isEmpty())
                     charset = document()->charset();
+                request.setCharset(charset);
 
-                m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request, charset);
+                m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request);
             }
             if (m_cachedSheet)
                 m_cachedSheet->addClient(this);
index 209fc79..cfdd1a4 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "CachedScript.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "ContentSecurityPolicy.h"
 #include "CrossOriginAccessControl.h"
 #include "Document.h"
@@ -256,16 +257,17 @@ bool ScriptElement::requestScript(const String& sourceUrl)
 
     ASSERT(!m_cachedScript);
     if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
-        ResourceRequest request = ResourceRequest(m_element->document()->completeURL(sourceUrl));
+        CachedResourceRequest request(ResourceRequest(m_element->document()->completeURL(sourceUrl)));
 
         String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr);
         if (!crossOriginMode.isNull()) {
             m_requestUsesAccessControl = true;
             StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
-            updateRequestForAccessControl(request, m_element->document()->securityOrigin(), allowCredentials);
+            updateRequestForAccessControl(request.mutableResourceRequest(), m_element->document()->securityOrigin(), allowCredentials);
         }
+        request.setCharset(scriptCharset());
 
-        m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(request, scriptCharset());
+        m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(request);
         m_isExternalScript = true;
     }
 
index fdc7a5c..7c96b19 100644 (file)
@@ -29,6 +29,7 @@
 #include "CachedCSSStyleSheet.h"
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "DocumentStyleSheetCollection.h"
 #include "EventSender.h"
@@ -220,8 +221,8 @@ void HTMLLinkElement::process()
 
         // Load stylesheets that are not needed for the rendering immediately with low priority.
         ResourceLoadPriority priority = blocking ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
-        ResourceRequest request(document()->completeURL(m_url));
-        m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request, charset, priority);
+        CachedResourceRequest request(ResourceRequest(document()->completeURL(m_url)), charset, priority);
+        m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request);
         
         if (m_cachedSheet)
             m_cachedSheet->addClient(this);
index 71a1ad3..9c889cd 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "CachedRawResource.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "CrossOriginAccessControl.h"
 #include "CrossOriginPreflightResultCache.h"
 #include "Document.h"
@@ -376,17 +377,17 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
             options.shouldBufferData = BufferData;
         }
 
-        ResourceRequest newRequest(request);
+        CachedResourceRequest newRequest(request, options);
 #if ENABLE(INSPECTOR)
         if (m_actualRequest) {
             // Because willSendRequest only gets called during redirects, we initialize the identifier and the first willSendRequest here.
             m_preflightRequestIdentifier = m_document->frame()->page()->progress()->createUniqueIdentifier();
             ResourceResponse redirectResponse = ResourceResponse();
-            InspectorInstrumentation::willSendRequest(m_document->frame(), m_preflightRequestIdentifier, m_document->frame()->loader()->documentLoader(), newRequest, redirectResponse);
+            InspectorInstrumentation::willSendRequest(m_document->frame(), m_preflightRequestIdentifier, m_document->frame()->loader()->documentLoader(), newRequest.mutableResourceRequest(), redirectResponse);
         }
 #endif
         ASSERT(!m_resource);
-        m_resource = m_document->cachedResourceLoader()->requestRawResource(newRequest, options);
+        m_resource = m_document->cachedResourceLoader()->requestRawResource(newRequest);
         if (m_resource) {
 #if ENABLE(INSPECTOR)
             if (m_resource->loader()) {
index a6da61e..c12be2f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "CrossOriginAccessControl.h"
 #include "Document.h"
 #include "Element.h"
@@ -177,18 +178,18 @@ void ImageLoader::updateFromElement()
     // an empty string.
     CachedResourceHandle<CachedImage> newImage = 0;
     if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
-        ResourceRequest request = ResourceRequest(document()->completeURL(sourceURI(attr)));
+        CachedResourceRequest request(ResourceRequest(document()->completeURL(sourceURI(attr))));
 
         String crossOriginMode = client()->sourceElement()->fastGetAttribute(HTMLNames::crossoriginAttr);
         if (!crossOriginMode.isNull()) {
             StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
-            updateRequestForAccessControl(request, document()->securityOrigin(), allowCredentials);
+            updateRequestForAccessControl(request.mutableResourceRequest(), document()->securityOrigin(), allowCredentials);
         }
 
         if (m_loadManually) {
             bool autoLoadOtherImages = document()->cachedResourceLoader()->autoLoadImages();
             document()->cachedResourceLoader()->setAutoLoadImages(false);
-            newImage = new CachedImage(request);
+            newImage = new CachedImage(request.resourceRequest());
             newImage->setLoading(true);
             newImage->setOwningCachedResourceLoader(document()->cachedResourceLoader());
             document()->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage.get());
index af25a86..e50b379 100644 (file)
@@ -35,6 +35,7 @@
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "ContainerNode.h"
 #include "DNS.h"
 #include "Document.h"
@@ -119,13 +120,13 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty
             priority = ResourceLoadPriorityLow;
             type = CachedResource::LinkSubresource;
         }
-        ResourceRequest linkRequest(document->completeURL(href));
+        CachedResourceRequest linkRequest(ResourceRequest(document->completeURL(href)), priority);
         
         if (m_cachedLinkResource) {
             m_cachedLinkResource->removeClient(this);
             m_cachedLinkResource = 0;
         }
-        m_cachedLinkResource = document->cachedResourceLoader()->requestLinkResource(type, linkRequest, priority);
+        m_cachedLinkResource = document->cachedResourceLoader()->requestLinkResource(type, linkRequest);
         if (m_cachedLinkResource)
             m_cachedLinkResource->addClient(this);
     }
index a9b7f96..7e14b43 100644 (file)
@@ -30,6 +30,7 @@
 #include "TextTrackLoader.h"
 
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "CachedTextTrack.h"
 #include "CrossOriginAccessControl.h"
 #include "Document.h"
@@ -153,12 +154,12 @@ bool TextTrackLoader::load(const KURL& url, const String& crossOriginMode)
 
     ASSERT(m_scriptExecutionContext->isDocument());
     Document* document = static_cast<Document*>(m_scriptExecutionContext);
-    ResourceRequest cueRequest(document->completeURL(url));
+    CachedResourceRequest cueRequest(ResourceRequest(document->completeURL(url)));
 
     if (!crossOriginMode.isNull()) {
         m_crossOriginMode = crossOriginMode;
         StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
-        updateRequestForAccessControl(cueRequest, document->securityOrigin(), allowCredentials);
+        updateRequestForAccessControl(cueRequest.mutableResourceRequest(), document->securityOrigin(), allowCredentials);
     } else {
         // Cross-origin resources that are not suitably CORS-enabled may not load.
         if (!document->securityOrigin()->canRequest(url)) {
index 1ffca4f..1ccaed9 100644 (file)
@@ -32,6 +32,7 @@
 #include "CachedFont.h"
 #include "CachedImage.h"
 #include "CachedRawResource.h"
+#include "CachedResourceRequest.h"
 #include "CachedScript.h"
 #include "CachedXSLStyleSheet.h"
 #include "Console.h"
@@ -107,12 +108,6 @@ static CachedResource* createResource(CachedResource::Type type, ResourceRequest
     return 0;
 }
 
-static const ResourceLoaderOptions& defaultCachedResourceOptions()
-{
-    static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck);
-    return options;
-}
-
 CachedResourceLoader::CachedResourceLoader(DocumentLoader* documentLoader)
     : m_document(0)
     , m_documentLoader(documentLoader)
@@ -155,56 +150,57 @@ Frame* CachedResourceLoader::frame() const
     return m_documentLoader ? m_documentLoader->frame() : 0;
 }
 
-CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(ResourceRequest& request)
+CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest& request)
 {
     if (Frame* f = frame()) {
         if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoDismissal) {
-            KURL requestURL = request.url();
+            KURL requestURL = request.resourceRequest().url();
             if (requestURL.isValid() && canRequest(CachedResource::ImageResource, requestURL))
                 PingLoader::loadImage(f, requestURL);
             return 0;
         }
     }
-    return static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, request, String(), defaultCachedResourceOptions(), ResourceLoadPriorityUnresolved, false, clientDefersImage(request.url()) ? DeferredByClient : NoDefer).get());
+    request.setDefer(clientDefersImage(request.resourceRequest().url()) ? DeferredByClient : NoDefer);
+    return static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, request).get());
 }
 
-CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(ResourceRequest& request)
+CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest& request)
 {
-    return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, request, String(), defaultCachedResourceOptions()).get());
+    return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, request).get());
 }
 
 #if ENABLE(VIDEO_TRACK)
-CachedResourceHandle<CachedTextTrack> CachedResourceLoader::requestTextTrack(ResourceRequest& request)
+CachedResourceHandle<CachedTextTrack> CachedResourceLoader::requestTextTrack(CachedResourceRequest& request)
 {
-    return static_cast<CachedTextTrack*>(requestResource(CachedResource::TextTrackResource, request, String(), defaultCachedResourceOptions()).get());
+    return static_cast<CachedTextTrack*>(requestResource(CachedResource::TextTrackResource, request).get());
 }
 #endif
 
 #if ENABLE(CSS_SHADERS)
-CachedResourceHandle<CachedShader> CachedResourceLoader::requestShader(ResourceRequest& request)
+CachedResourceHandle<CachedShader> CachedResourceLoader::requestShader(CachedResourceRequest& request)
 {
-    return static_cast<CachedShader*>(requestResource(CachedResource::ShaderResource, request, String(), defaultCachedResourceOptions()).get());
+    return static_cast<CachedShader*>(requestResource(CachedResource::ShaderResource, request).get());
 }
 #endif
 
-CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleSheet(ResourceRequest& request, const String& charset, ResourceLoadPriority priority)
+CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest& request)
 {
-    return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, request, charset, defaultCachedResourceOptions(), priority).get());
+    return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, request).get());
 }
 
-CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(ResourceRequest& request, const String& charset)
+CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest& request)
 {
-    KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(request.url());
+    KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(request.resourceRequest().url());
 
     if (CachedResource* existing = memoryCache()->resourceForURL(url)) {
         if (existing->type() == CachedResource::CSSStyleSheet)
             return static_cast<CachedCSSStyleSheet*>(existing);
         memoryCache()->remove(existing);
     }
-    if (url.string() != request.url())
-        request.setURL(url);
+    if (url.string() != request.resourceRequest().url())
+        request.mutableResourceRequest().setURL(url);
 
-    CachedResourceHandle<CachedCSSStyleSheet> userSheet = new CachedCSSStyleSheet(request, charset);
+    CachedResourceHandle<CachedCSSStyleSheet> userSheet = new CachedCSSStyleSheet(request.resourceRequest(), request.charset());
 
     memoryCache()->add(userSheet.get());
     // FIXME: loadResource calls setOwningCachedResourceLoader() if the resource couldn't be added to cache. Does this function need to call it, too?
@@ -214,37 +210,37 @@ CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSSt
     return userSheet;
 }
 
-CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(ResourceRequest& request, const String& charset)
+CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(CachedResourceRequest& request)
 {
-    return static_cast<CachedScript*>(requestResource(CachedResource::Script, request, charset, defaultCachedResourceOptions()).get());
+    return static_cast<CachedScript*>(requestResource(CachedResource::Script, request).get());
 }
 
 #if ENABLE(XSLT)
-CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(ResourceRequest& request)
+CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest& request)
 {
-    return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, request, String(), defaultCachedResourceOptions()).get());
+    return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, request).get());
 }
 #endif
 
 #if ENABLE(SVG)
-CachedResourceHandle<CachedSVGDocument> CachedResourceLoader::requestSVGDocument(ResourceRequest& request)
+CachedResourceHandle<CachedSVGDocument> CachedResourceLoader::requestSVGDocument(CachedResourceRequest& request)
 {
-    return static_cast<CachedSVGDocument*>(requestResource(CachedResource::SVGDocumentResource, request, String(), defaultCachedResourceOptions()).get());
+    return static_cast<CachedSVGDocument*>(requestResource(CachedResource::SVGDocumentResource, request).get());
 }
 #endif
 
 #if ENABLE(LINK_PREFETCH)
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestLinkResource(CachedResource::Type type, ResourceRequest& request, ResourceLoadPriority priority)
+CachedResourceHandle<CachedResource> CachedResourceLoader::requestLinkResource(CachedResource::Type type, CachedResourceRequest& request)
 {
     ASSERT(frame());
     ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkSubresource);
-    return requestResource(type, request, String(), defaultCachedResourceOptions(), priority);
+    return requestResource(type, request);
 }
 #endif
 
-CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource(ResourceRequest& request, const ResourceLoaderOptions& options)
+CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource(CachedResourceRequest& request)
 {
-    return static_cast<CachedRawResource*>(requestResource(CachedResource::RawResource, request, String(), options, ResourceLoadPriorityUnresolved, false).get());
+    return static_cast<CachedRawResource*>(requestResource(CachedResource::RawResource, request).get());
 }
 
 bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const KURL& url) const
@@ -402,11 +398,11 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
     return true;
 }
 
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, ResourceRequest& request, const String& charset, const ResourceLoaderOptions& options, ResourceLoadPriority priority, bool forPreload, DeferOption defer)
+CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request)
 {
-    KURL url = request.url();
+    KURL url = request.resourceRequest().url();
     
-    LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.string().latin1().data(), charset.latin1().data(), priority, forPreload);
+    LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.string().latin1().data(), request.charset().latin1().data(), request.priority(), request.forPreload());
     
     // If only the fragment identifiers differ, it is the same resource.
     url = MemoryCache::removeFragmentIdentifierIfNeeded(url);
@@ -414,7 +410,7 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
     if (!url.isValid())
         return 0;
 
-    if (!canRequest(type, url, forPreload))
+    if (!canRequest(type, url, request.forPreload()))
         return 0;
 
     if (memoryCache()->disabled()) {
@@ -428,16 +424,16 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
     // See if we can use an existing resource from the cache.
     CachedResourceHandle<CachedResource> resource = memoryCache()->resourceForURL(url);
 
-    if (request.url() != url)
-        request.setURL(url);
+    if (request.resourceRequest().url() != url)
+        request.mutableResourceRequest().setURL(url);
 
-    const RevalidationPolicy policy = determineRevalidationPolicy(type, request, forPreload, resource.get(), defer);
+    const RevalidationPolicy policy = determineRevalidationPolicy(type, request.mutableResourceRequest(), request.forPreload(), resource.get(), request.defer());
     switch (policy) {
     case Reload:
         memoryCache()->remove(resource.get());
         // Fall through
     case Load:
-        resource = loadResource(type, request, charset);
+        resource = loadResource(type, request.mutableResourceRequest(), request.charset());
         break;
     case Revalidate:
         resource = revalidateResource(resource.get());
@@ -451,9 +447,9 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
     if (!resource)
         return 0;
 
-    resource->setLoadPriority(priority);
-    if ((policy != Use || resource->stillNeedsLoad()) && NoDefer == defer) {
-        resource->load(this, options);
+    resource->setLoadPriority(request.priority());
+    if ((policy != Use || resource->stillNeedsLoad()) && NoDefer == request.defer()) {
+        resource->load(this, request.options());
 
         // We don't support immediate loads, but we do support immediate failure.
         if (resource->errorOccurred()) {
@@ -463,8 +459,8 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
         }
     }
 
-    if (!request.url().protocolIsData())
-        m_validatedURLs.add(request.url());
+    if (!request.resourceRequest().url().protocolIsData())
+        m_validatedURLs.add(request.resourceRequest().url());
 
     ASSERT(resource->url() == url.string());
     m_documentResources.set(resource->url(), resource);
@@ -793,7 +789,10 @@ void CachedResourceLoader::requestPreload(CachedResource::Type type, ResourceReq
     if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet)
         encoding = charset.isEmpty() ? m_document->charset() : charset;
 
-    CachedResourceHandle<CachedResource> resource = requestResource(type, request, encoding, defaultCachedResourceOptions(), ResourceLoadPriorityUnresolved, true);
+    CachedResourceRequest cachedResourceRequest(request, encoding);
+    cachedResourceRequest.setForPreload(true);
+
+    CachedResourceHandle<CachedResource> resource = requestResource(type, cachedResourceRequest);
     if (!resource || (m_preloads && m_preloads->contains(resource.get())))
         return;
     resource->increasePreloadCount();
@@ -912,4 +911,10 @@ void CachedResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
     info.addMember(m_pendingPreloads);
 }
 
+const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions()
+{
+    static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck);
+    return options;
+}
+
 }
index 2a7985e..0fcb1e3 100644 (file)
@@ -44,6 +44,7 @@ class CachedSVGDocument;
 class CachedFont;
 class CachedImage;
 class CachedRawResource;
+class CachedResourceRequest;
 class CachedScript;
 class CachedShader;
 class CachedTextTrack;
@@ -68,30 +69,31 @@ friend class ImageLoader;
 friend class ResourceCacheValidationSuppressor;
 
 public:
+    enum DeferOption { NoDefer, DeferredByClient };
     static PassRefPtr<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(new CachedResourceLoader(documentLoader)); }
     ~CachedResourceLoader();
 
-    CachedResourceHandle<CachedImage> requestImage(ResourceRequest&);
-    CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(ResourceRequest&, const String& charset, ResourceLoadPriority = ResourceLoadPriorityUnresolved);
-    CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(ResourceRequest&, const String& charset);
-    CachedResourceHandle<CachedScript> requestScript(ResourceRequest&, const String& charset);
-    CachedResourceHandle<CachedFont> requestFont(ResourceRequest&);
-    CachedResourceHandle<CachedRawResource> requestRawResource(ResourceRequest&, const ResourceLoaderOptions&);
+    CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&);
+    CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&);
+    CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&);
+    CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&);
+    CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&);
+    CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&);
 
 #if ENABLE(SVG)
-    CachedResourceHandle<CachedSVGDocument> requestSVGDocument(ResourceRequest&);
+    CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&);
 #endif
 #if ENABLE(XSLT)
-    CachedResourceHandle<CachedXSLStyleSheet> requestXSLStyleSheet(ResourceRequest&);
+    CachedResourceHandle<CachedXSLStyleSheet> requestXSLStyleSheet(CachedResourceRequest&);
 #endif
 #if ENABLE(LINK_PREFETCH)
-    CachedResourceHandle<CachedResource> requestLinkResource(CachedResource::Type, ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityUnresolved);
+    CachedResourceHandle<CachedResource> requestLinkResource(CachedResource::Type, CachedResourceRequest&);
 #endif
 #if ENABLE(VIDEO_TRACK)
-    CachedResourceHandle<CachedTextTrack> requestTextTrack(ResourceRequest&);
+    CachedResourceHandle<CachedTextTrack> requestTextTrack(CachedResourceRequest&);
 #endif
 #if ENABLE(CSS_SHADERS)
-    CachedResourceHandle<CachedShader> requestShader(ResourceRequest&);
+    CachedResourceHandle<CachedShader> requestShader(CachedResourceRequest&);
 #endif
 
     // Logs an access denied message to the console for the specified URL.
@@ -135,11 +137,12 @@ public:
     
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
+    static const ResourceLoaderOptions& defaultCachedResourceOptions();
+
 private:
     explicit CachedResourceLoader(DocumentLoader*);
 
-    enum DeferOption { NoDefer, DeferredByClient };
-    CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, ResourceRequest&, const String& charset, const ResourceLoaderOptions&, ResourceLoadPriority = ResourceLoadPriorityUnresolved, bool isPreload = false, DeferOption = NoDefer);
+    CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&);
     CachedResourceHandle<CachedResource> revalidateResource(CachedResource*);
     CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, ResourceRequest&, const String& charset);
     void requestPreload(CachedResource::Type, ResourceRequest&, const String& charset);
diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.cpp b/Source/WebCore/loader/cache/CachedResourceRequest.cpp
new file mode 100644 (file)
index 0000000..6add39b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CachedResourceRequest.h"
+
+namespace WebCore {
+
+CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequest, const String& charset, ResourceLoadPriority priority)
+    : m_resourceRequest(resourceRequest)
+    , m_charset(charset)
+    , m_options(CachedResourceLoader::defaultCachedResourceOptions())
+    , m_priority(priority)
+    , m_forPreload(false)
+    , m_defer(CachedResourceLoader::NoDefer)
+{
+}
+
+CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequest, const ResourceLoaderOptions& options)
+    : m_resourceRequest(resourceRequest)
+    , m_options(options)
+    , m_priority(ResourceLoadPriorityUnresolved)
+    , m_forPreload(false)
+    , m_defer(CachedResourceLoader::NoDefer)
+{
+}
+
+CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequest, ResourceLoadPriority priority)
+    : m_resourceRequest(resourceRequest)
+    , m_options(CachedResourceLoader::defaultCachedResourceOptions())
+    , m_priority(priority)
+    , m_forPreload(false)
+    , m_defer(CachedResourceLoader::NoDefer)
+{
+}
+
+}
diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.h b/Source/WebCore/loader/cache/CachedResourceRequest.h
new file mode 100644 (file)
index 0000000..cb043df
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CachedResourceRequest_h
+#define CachedResourceRequest_h
+
+#include "CachedResourceLoader.h"
+#include "ResourceLoadPriority.h"
+
+namespace WebCore {
+
+class CachedResourceRequest {
+public:
+    explicit CachedResourceRequest(const ResourceRequest&, const String& charset = String(), ResourceLoadPriority = ResourceLoadPriorityUnresolved);
+    CachedResourceRequest(const ResourceRequest&, const ResourceLoaderOptions&);
+    CachedResourceRequest(const ResourceRequest&, ResourceLoadPriority);
+
+    ResourceRequest& mutableResourceRequest() { return m_resourceRequest; }
+    const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
+    const String& charset() const { return m_charset; }
+    void setCharset(const String& charset) { m_charset = charset; }
+    const ResourceLoaderOptions& options() const { return m_options; }
+    ResourceLoadPriority priority() const { return m_priority; }
+    bool forPreload() const { return m_forPreload; }
+    void setForPreload(bool forPreload) { m_forPreload = forPreload; }
+    CachedResourceLoader::DeferOption defer() const { return m_defer; }
+    void setDefer(CachedResourceLoader::DeferOption defer) { m_defer = defer; }
+
+private:
+    ResourceRequest m_resourceRequest;
+    String m_charset;
+    ResourceLoaderOptions m_options;
+    ResourceLoadPriority m_priority;
+    bool m_forPreload;
+    CachedResourceLoader::DeferOption m_defer;
+};
+
+} // namespace WebCore
+
+#endif
index 63bc0ea..8c9d0ce 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "CachedRawResource.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "Frame.h"
 #include "FrameLoader.h"
@@ -59,14 +60,14 @@ void IconLoader::startLoading()
     if (m_resource || !m_frame->document())
         return;
 
-    ResourceRequest resourceRequest(m_frame->loader()->icon()->url());
+    CachedResourceRequest request(ResourceRequest(m_frame->loader()->icon()->url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
+
 #if PLATFORM(BLACKBERRY)
-    resourceRequest.setTargetType(ResourceRequest::TargetIsFavicon);
+    request.mutableResourceRequest().setTargetType(ResourceRequest::TargetIsFavicon);
 #endif
-    resourceRequest.setPriority(ResourceLoadPriorityLow);
+    request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
 
-    m_resource = m_frame->document()->cachedResourceLoader()->requestRawResource(resourceRequest,
-        ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
+    m_resource = m_frame->document()->cachedResourceLoader()->requestRawResource(request);
     if (m_resource)
         m_resource->addClient(this);
     else
index 7635738..87ff0d6 100644 (file)
@@ -27,6 +27,7 @@
 #include "Attr.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "ColorSpace.h"
 #include "Document.h"
 #include "Image.h"
@@ -80,7 +81,7 @@ void SVGFEImageElement::clearResourceReferences()
 
 void SVGFEImageElement::requestImageResource()
 {
-    ResourceRequest request(ownerDocument()->completeURL(href()));
+    CachedResourceRequest request(ResourceRequest(ownerDocument()->completeURL(href())));
     m_cachedImage = document()->cachedResourceLoader()->requestImage(request);
 
     if (m_cachedImage)
index f610537..c34fed8 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSFontFaceSrcValue.h"
 #include "CachedFont.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "SVGFontFaceElement.h"
 #include "SVGNames.h"
@@ -96,7 +97,7 @@ void SVGFontFaceUriElement::loadFont()
     const AtomicString& href = getAttribute(XLinkNames::hrefAttr);
     if (!href.isNull()) {
         CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader();
-        ResourceRequest request(document()->completeURL(href));
+        CachedResourceRequest request(ResourceRequest(document()->completeURL(href)));
         m_cachedFont = cachedResourceLoader->requestFont(request);
         if (m_cachedFont) {
             m_cachedFont->addClient(this);
index d19ea19..6046ec6 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "Attribute.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "ElementShadow.h"
 #include "Event.h"
@@ -254,7 +255,7 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
         if (isExternalReference) {
             KURL url = document()->completeURL(href());
             if (url.hasFragmentIdentifier()) {
-                ResourceRequest request(url.string());
+                CachedResourceRequest request(ResourceRequest(url.string()));
                 m_cachedDocument = document()->cachedResourceLoader()->requestSVGDocument(request);
                 if (m_cachedDocument)
                     m_cachedDocument->addClient(this);
index 0a1770d..e62959e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "CachedXSLStyleSheet.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
 #include "Document.h"
 #include "XSLStyleSheet.h"
 
@@ -98,7 +99,7 @@ void XSLImportRule::loadSheet()
             return;
     }
     
-    ResourceRequest request(cachedResourceLoader->document()->completeURL(absHref));
+    CachedResourceRequest request(ResourceRequest(cachedResourceLoader->document()->completeURL(absHref)));
     m_cachedSheet = cachedResourceLoader->requestXSLStyleSheet(request);
     
     if (m_cachedSheet) {