Add initiator to CachedResourceRequest.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 18:52:28 +0000 (18:52 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 18:52:28 +0000 (18:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101935

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

Motivation: Chromium needs to know which elements request a
resource (such as an image or a script) (bug 92761). In addition,
for exposing resource timing information (bug 84883) we need to
store the initiator, and this is the first step towards it.

No new tests: No visible change in behavior.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSCrossfadeValue.cpp:
(WebCore::cachedImageForCSSValue):
* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::cachedImage):
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::cachedFont):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::cachedImageSet):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* css/CSSImageValue.h:
(WebCore):
(CSSImageValue):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingImage):
* css/StyleRuleImport.cpp:
(WebCore::StyleRuleImport::requestStyleSheet):
* css/WebKitCSSSVGDocumentValue.cpp:
(WebCore::WebKitCSSSVGDocumentValue::load):
* css/WebKitCSSShaderValue.cpp:
(WebCore::WebKitCSSShaderValue::cachedShader):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/parser/CSSPreloadScanner.cpp:
(WebCore::CSSPreloadScanner::emitRule):
* html/parser/CSSPreloadScanner.h:
(CSSPreloadScanner):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::PreloadTask::preload):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
(WebCore):
(WebCore::CachedResourceLoader::preload):
* loader/cache/CachedResourceLoader.h:
(WebCore):
(CachedResourceLoader):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::CachedResourceRequest):
(WebCore):
(WebCore::CachedResourceRequest::~CachedResourceRequest):
(WebCore::CachedResourceRequest::setInitiator):
(WebCore::CachedResourceRequest::initiatorName):
(WebCore::CachedResourceRequest::initiatorDocument):
(WebCore::CachedResourceRequest::initiatorElement):
* loader/cache/CachedResourceRequest.h:
(WebCore):
(WebCore::CachedResourceRequest::setOptions):
(WebCore::CachedResourceRequest::defer):
(WebCore::CachedResourceRequest::setDefer):
(CachedResourceRequest):
* loader/cache/CachedResourceRequestInitiators.cpp: Copied from Source/WebCore/loader/cache/CachedResourceRequest.cpp.
(WebCore):
(WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
* loader/cache/CachedResourceRequestInitiators.h: Copied from Source/WebCore/loader/cache/CachedResourceRequest.cpp.
(WebCore):
(CachedResourceRequestInitiators):
(WebCore::cachedResourceRequestInitiators):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading):
* platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::ThreadGlobalData):
* platform/ThreadGlobalData.h:
(WebCore):
(WebCore::ThreadGlobalData::cachedResourceRequestInitiators):
(ThreadGlobalData):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::svgAttributeChanged):

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

34 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/CSSCursorImageValue.cpp
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSImageSetValue.cpp
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/css/CSSImageValue.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleRuleImport.cpp
Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
Source/WebCore/css/WebKitCSSShaderValue.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/parser/CSSPreloadScanner.cpp
Source/WebCore/html/parser/CSSPreloadScanner.h
Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Source/WebCore/loader/ImageLoader.cpp
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/CachedResourceRequestInitiators.cpp [new file with mode: 0644]
Source/WebCore/loader/cache/CachedResourceRequestInitiators.h [new file with mode: 0644]
Source/WebCore/loader/icon/IconLoader.cpp
Source/WebCore/platform/ThreadGlobalData.cpp
Source/WebCore/platform/ThreadGlobalData.h
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebCore/svg/SVGUseElement.cpp

index db0fa49..307072b 100644 (file)
@@ -1681,6 +1681,7 @@ SET(WebCore_SOURCES
     loader/cache/CachedResourceHandle.cpp
     loader/cache/CachedResourceLoader.cpp
     loader/cache/CachedResourceRequest.cpp
+    loader/cache/CachedResourceRequestInitiators.cpp
     loader/cache/CachedScript.cpp
     loader/cache/CachedShader.cpp
     loader/cache/CachedSVGDocument.cpp
index 51e970b..675ddfe 100644 (file)
@@ -1,3 +1,101 @@
+2012-11-13  Marja Hölttä  <marja@chromium.org>
+
+        Add initiator to CachedResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=101935
+
+        Reviewed by Adam Barth.
+
+        Motivation: Chromium needs to know which elements request a
+        resource (such as an image or a script) (bug 92761). In addition,
+        for exposing resource timing information (bug 84883) we need to
+        store the initiator, and this is the first step towards it.
+
+        No new tests: No visible change in behavior.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSCrossfadeValue.cpp:
+        (WebCore::cachedImageForCSSValue):
+        * css/CSSCursorImageValue.cpp:
+        (WebCore::CSSCursorImageValue::cachedImage):
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::cachedFont):
+        * css/CSSImageSetValue.cpp:
+        (WebCore::CSSImageSetValue::cachedImageSet):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::cachedImage):
+        * css/CSSImageValue.h:
+        (WebCore):
+        (CSSImageValue):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::loadPendingImage):
+        * css/StyleRuleImport.cpp:
+        (WebCore::StyleRuleImport::requestStyleSheet):
+        * css/WebKitCSSSVGDocumentValue.cpp:
+        (WebCore::WebKitCSSSVGDocumentValue::load):
+        * css/WebKitCSSShaderValue.cpp:
+        (WebCore::WebKitCSSShaderValue::cachedShader):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::requestScript):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        * html/parser/CSSPreloadScanner.cpp:
+        (WebCore::CSSPreloadScanner::emitRule):
+        * html/parser/CSSPreloadScanner.h:
+        (CSSPreloadScanner):
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::PreloadTask::preload):
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateFromElement):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestImage):
+        (WebCore::CachedResourceLoader::requestResource):
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+        (WebCore):
+        (WebCore::CachedResourceLoader::preload):
+        * loader/cache/CachedResourceLoader.h:
+        (WebCore):
+        (CachedResourceLoader):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::CachedResourceRequest):
+        (WebCore):
+        (WebCore::CachedResourceRequest::~CachedResourceRequest):
+        (WebCore::CachedResourceRequest::setInitiator):
+        (WebCore::CachedResourceRequest::initiatorName):
+        (WebCore::CachedResourceRequest::initiatorDocument):
+        (WebCore::CachedResourceRequest::initiatorElement):
+        * loader/cache/CachedResourceRequest.h:
+        (WebCore):
+        (WebCore::CachedResourceRequest::setOptions):
+        (WebCore::CachedResourceRequest::defer):
+        (WebCore::CachedResourceRequest::setDefer):
+        (CachedResourceRequest):
+        * loader/cache/CachedResourceRequestInitiators.cpp: Copied from Source/WebCore/loader/cache/CachedResourceRequest.cpp.
+        (WebCore):
+        (WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
+        * loader/cache/CachedResourceRequestInitiators.h: Copied from Source/WebCore/loader/cache/CachedResourceRequest.cpp.
+        (WebCore):
+        (CachedResourceRequestInitiators):
+        (WebCore::cachedResourceRequestInitiators):
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading):
+        * platform/ThreadGlobalData.cpp:
+        (WebCore::ThreadGlobalData::ThreadGlobalData):
+        * platform/ThreadGlobalData.h:
+        (WebCore):
+        (WebCore::ThreadGlobalData::cachedResourceRequestInitiators):
+        (ThreadGlobalData):
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::requestImageResource):
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::loadFont):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::svgAttributeChanged):
+
 2012-11-13  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r134345.
index 244c0f7..edbb155 100644 (file)
@@ -3824,6 +3824,8 @@ webcore_sources += \
        Source/WebCore/loader/cache/CachedResourceLoader.h \
        Source/WebCore/loader/cache/CachedResourceRequest.cpp \
        Source/WebCore/loader/cache/CachedResourceRequest.h \
+       Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp \
+       Source/WebCore/loader/cache/CachedResourceRequestInitiators.h \
        Source/WebCore/loader/cache/CachedScript.cpp \
        Source/WebCore/loader/cache/CachedScript.h \
        Source/WebCore/loader/cache/CachedShader.cpp \
index 5dd81ed..098f0c2 100644 (file)
@@ -822,6 +822,7 @@ SOURCES += \
     loader/CrossOriginPreflightResultCache.cpp \
     loader/cache/CachedResourceLoader.cpp \
     loader/cache/CachedResourceRequest.cpp \
+    loader/cache/CachedResourceRequestInitiators.cpp \
     loader/DocumentLoadTiming.cpp \
     loader/DocumentLoader.cpp \
     loader/DocumentThreadableLoader.cpp \
@@ -1954,6 +1955,8 @@ HEADERS += \
     loader/CrossOriginAccessControl.h \
     loader/CrossOriginPreflightResultCache.h \
     loader/cache/CachedResourceLoader.h \
+    loader/cache/CachedResourceRequest.h \
+    loader/cache/CachedResourceRequestInitiators.h \
     loader/DocumentLoader.h \
     loader/DocumentThreadableLoader.h \
     loader/FormState.h \
index 694dfd0..ae906b0 100644 (file)
             'loader/cache/CachedResourceHandle.h',
             'loader/cache/CachedResourceLoader.h',
             'loader/cache/CachedResourceRequest.h',
+            'loader/cache/CachedResourceRequestInitiators.h',
             'loader/cache/CachedShader.h',
             'loader/cache/CachedStyleSheetClient.h',
             'loader/cache/MemoryCache.h',
             'loader/cache/CachedResourceHandle.cpp',
             'loader/cache/CachedResourceLoader.cpp',
             'loader/cache/CachedResourceRequest.cpp',
+            'loader/cache/CachedResourceRequestInitiators.cpp',
             'loader/cache/CachedScript.cpp',
             'loader/cache/CachedScript.h',
             'loader/cache/CachedShader.cpp',
index 77c85e5..4eac32c 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\loader\cache\CachedResourceRequestInitiators.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\loader\cache\CachedResourceRequestInitiators.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\loader\cache\CachedScript.cpp"
                                        >
                                </File>
index b501e9b..db4f70f 100644 (file)
                65E0E9441133C89F00B4CB10 /* JSDOMWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
                6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */; };
                6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
                6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */; };
                6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */; };
                65F80697054D9F86008BF776 /* BlockExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockExceptions.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
                6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };
+               6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CachedResourceRequestInitiators.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
+               6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CachedResourceRequestInitiators.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
                6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; };
                6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };
                                BCB16C110979C3BD00467741 /* CachedResourceLoader.h */,
                                5081E3DF3CFC80C16EF8B48B /* CachedResourceRequest.cpp */,
                                5081E3E13D0280C16EF8B48B /* CachedResourceRequest.h */,
+                               6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp /*,
+                               6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h /*,
                                BCB16C0A0979C3BD00467741 /* CachedScript.cpp */,
                                BCB16C0B0979C3BD00467741 /* CachedScript.h */,
                                5038BE3E1472AD980095E0D1 /* CachedShader.cpp */,
                                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */,
                                BCB16C2A0979C3BD00467741 /* CachedResourceLoader.h in Headers */,
                                5081E3E03CFF80C16EF8B48B /* CachedResourceRequest.h in Headers */,
+                               6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */,
                                BCB16C240979C3BD00467741 /* CachedScript.h in Headers */,
                                BCD533640ED6848900887468 /* CachedScriptSourceProvider.h in Headers */,
                                5038BE411472AD980095E0D1 /* CachedShader.h in Headers */,
                                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */,
                                BCB16C290979C3BD00467741 /* CachedResourceLoader.cpp in Sources */,
                                5081E3C33CE580C16EF8B48B /* CachedResourceRequest.cpp in Sources */,
+                               6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */,
                                BCB16C230979C3BD00467741 /* CachedScript.cpp in Sources */,
                                5038BE401472AD980095E0D1 /* CachedShader.cpp in Sources */,
                                A104F24314C71F7A009E2C23 /* CachedSVGDocument.cpp in Sources */,
index 0faa813..eef0a47 100644 (file)
@@ -135,7 +135,7 @@ StyleCachedImage* CSSCursorImageValue::cachedImage(CachedResourceLoader* loader)
     if (isSVGCursorIdentifier(url()) && loader && loader->document()) {
         // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
         if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url(), loader->document()))
-            return CSSImageValue::cachedImage(loader, cursorElement->href());
+            return CSSImageValue::cachedImage(loader, cursorElement->href(), cursorElement);
     }
 #endif
 
index 3690789..07782ac 100644 (file)
@@ -28,6 +28,7 @@
 #include "CachedFont.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "FontCustomPlatformData.h"
 #include "Node.h"
@@ -97,6 +98,7 @@ CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document)
 {
     if (!m_cachedFont) {
         CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)));
+        request.setInitiator(cachedResourceRequestInitiators().css, document);
         m_cachedFont = document->cachedResourceLoader()->requestFont(request);
     }
     return m_cachedFont.get();
index f7d401f..ebc74c7 100644 (file)
@@ -33,6 +33,7 @@
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "Page.h"
 #include "StyleCachedImageSet.h"
@@ -110,6 +111,7 @@ StyleCachedImageSet* CSSImageSetValue::cachedImageSet(CachedResourceLoader* load
         // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
         ImageWithScale image = bestImageForScaleFactor();
         CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(image.imageURL)));
+        request.setInitiator(cachedResourceRequestInitiators().css, document);
         if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request)) {
             m_imageSet = StyleCachedImageSet::create(cachedImage.get(), image.scaleFactor, this);
             m_accessedBestFitImage = true;
index 6b73d46..957a221 100644 (file)
@@ -27,7 +27,9 @@
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
+#include "Element.h"
 #include "MemoryCache.h"
 #include "StyleCachedImage.h"
 #include "StylePendingImage.h"
@@ -69,14 +71,14 @@ StyleImage* CSSImageValue::cachedOrPendingImage()
     return m_image.get();
 }
 
-StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader)
+StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, Element* initiatorElement)
 {
     if (isCursorImageValue())
         return static_cast<CSSCursorImageValue*>(this)->cachedImage(loader);
-    return cachedImage(loader, m_url);
+    return cachedImage(loader, m_url, initiatorElement);
 }
 
-StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const String& url)
+StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const String& url, Element* initiatorElement)
 {
     ASSERT(loader);
 
@@ -84,6 +86,10 @@ StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const
         m_accessedImage = true;
 
         CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(url)));
+        if (initiatorElement)
+            request.setInitiator(initiatorElement);
+        else
+            request.setInitiator(cachedResourceRequestInitiators().css, loader->document());
         if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request))
             m_image = StyleCachedImage::create(cachedImage.get());
     }
index 8c82f2c..5cf5a1f 100644 (file)
@@ -27,6 +27,7 @@
 namespace WebCore {
 
 class CachedResourceLoader;
+class Element;
 class StyleCachedImage;
 class StyleImage;
 
@@ -36,7 +37,7 @@ public:
     static PassRefPtr<CSSImageValue> create(const String& url, StyleImage* image) { return adoptRef(new CSSImageValue(url, image)); }
     ~CSSImageValue();
 
-    StyleCachedImage* cachedImage(CachedResourceLoader*);
+    StyleCachedImage* cachedImage(CachedResourceLoader*, Element* initiatorElement = 0);
     // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
     StyleImage* cachedOrPendingImage();
 
@@ -53,7 +54,7 @@ public:
 protected:
     CSSImageValue(ClassType, const String& url);
 
-    StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url);
+    StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url, Element* initiatorElement = 0);
     String cachedImageURL();
     void clearCachedImage();
 
index ceb2eb8..ce4acd3 100644 (file)
@@ -5053,7 +5053,7 @@ PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendin
 
     if (pendingImage->cssImageValue()) {
         CSSImageValue* imageValue = pendingImage->cssImageValue();
-        return imageValue->cachedImage(cachedResourceLoader);
+        return imageValue->cachedImage(cachedResourceLoader, m_element);
     }
 
     if (pendingImage->cssImageGeneratorValue()) {
index eec3507..3146ec3 100644 (file)
@@ -26,6 +26,7 @@
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "SecurityOrigin.h"
 #include "StyleSheetContents.h"
@@ -117,6 +118,7 @@ void StyleRuleImport::requestStyleSheet()
     }
 
     CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset());
+    request.setInitiator(cachedResourceRequestInitiators().css, document);
     if (m_parentStyleSheet->isUserStyleSheet())
         m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request);
     else
index 67e84e3..6fe948d 100644 (file)
@@ -30,6 +30,7 @@
 #include "CSSParser.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "WebCoreMemoryInstrumentation.h"
 
@@ -54,6 +55,7 @@ CachedSVGDocument* WebKitCSSSVGDocumentValue::load(CachedResourceLoader* loader)
         m_loadRequested = true;
 
         CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
+        request.setInitiator(cachedResourceRequestInitiators().css, loader->document());
         m_document = loader->requestSVGDocument(request);
     }
 
index fa04190..35187f8 100644 (file)
@@ -35,6 +35,7 @@
 #include "CSSParser.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "StyleCachedShader.h"
 #include "StylePendingShader.h"
@@ -61,6 +62,7 @@ StyleCachedShader* WebKitCSSShaderValue::cachedShader(CachedResourceLoader* load
         m_accessedShader = true;
 
         CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
+        request.setInitiator(cachedResourceRequestInitiators().css, loader->document());
         if (CachedResourceHandle<CachedShader> cachedShader = loader->requestShader(request))
             m_shader = StyleCachedShader::create(cachedShader.get());
     }
index cfdd1a4..4fa559e 100644 (file)
@@ -266,6 +266,7 @@ bool ScriptElement::requestScript(const String& sourceUrl)
             updateRequestForAccessControl(request.mutableResourceRequest(), m_element->document()->securityOrigin(), allowCredentials);
         }
         request.setCharset(scriptCharset());
+        request.setInitiator(element());
 
         m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(request);
         m_isExternalScript = true;
index 7c96b19..4a3dcfc 100644 (file)
@@ -222,6 +222,7 @@ void HTMLLinkElement::process()
         // Load stylesheets that are not needed for the rendering immediately with low priority.
         ResourceLoadPriority priority = blocking ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
         CachedResourceRequest request(ResourceRequest(document()->completeURL(m_url)), charset, priority);
+        request.setInitiator(this);
         m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request);
         
         if (m_cachedSheet)
index 29f1ccd..150ce8a 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "HTMLParserIdioms.h"
 #include "HTMLToken.h"
@@ -196,7 +198,8 @@ void CSSPreloadScanner::emitRule()
     if (equalIgnoringCase("import", m_rule.characters(), m_rule.length())) {
         String value = parseCSSStringOrURL(m_ruleValue.characters(), m_ruleValue.length());
         if (!value.isEmpty()) {
-            ResourceRequest request(m_document->completeURL(value));
+            CachedResourceRequest request(ResourceRequest(m_document->completeURL(value)));
+            request.setInitiator(cachedResourceRequestInitiators().css, m_document);
             m_document->cachedResourceLoader()->preload(CachedResource::CSSStyleSheet, request, String(), m_scanningBody);
         }
         m_state = Initial;
index c3dbb80..b16a629 100644 (file)
@@ -37,7 +37,7 @@ class HTMLToken;
 class CSSPreloadScanner {
     WTF_MAKE_NONCOPYABLE(CSSPreloadScanner);
 public:
-    CSSPreloadScanner(Document*);
+    explicit CSSPreloadScanner(Document*);
 
     void reset();
     void scan(const HTMLToken&, bool scanningBody);
index 23038bd..9654c8d 100644 (file)
@@ -127,7 +127,8 @@ public:
             return;
 
         CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
-        ResourceRequest request = document->completeURL(m_urlToLoad, baseURL);
+        CachedResourceRequest request(ResourceRequest(document->completeURL(m_urlToLoad, baseURL)));
+        request.setInitiator(tagName(), document);
         if (m_tagName == scriptTag)
             cachedResourceLoader->preload(CachedResource::Script, request, m_charset, scanningBody);
         else if (m_tagName == imgTag || (m_tagName == inputTag && m_inputIsImage))
index c12be2f..e2247d2 100644 (file)
@@ -179,6 +179,7 @@ void ImageLoader::updateFromElement()
     CachedResourceHandle<CachedImage> newImage = 0;
     if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
         CachedResourceRequest request(ResourceRequest(document()->completeURL(sourceURI(attr))));
+        request.setInitiator(client()->sourceElement());
 
         String crossOriginMode = client()->sourceElement()->fastGetAttribute(HTMLNames::crossoriginAttr);
         if (!crossOriginMode.isNull()) {
index d4cba05..83a5a1c 100644 (file)
@@ -164,7 +164,7 @@ CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou
             return 0;
         }
     }
-    request.setDefer(clientDefersImage(request.resourceRequest().url()) ? DeferredByClient : NoDefer);
+    request.setDefer(clientDefersImage(request.resourceRequest().url()) ? CachedResourceRequest::DeferredByClient : CachedResourceRequest::NoDefer);
     return static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, request).get());
 }
 
@@ -458,7 +458,7 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
         return 0;
 
     resource->setLoadPriority(request.priority());
-    if ((policy != Use || resource->stillNeedsLoad()) && NoDefer == request.defer()) {
+    if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) {
         resource->load(this, request.options());
 
         // We don't support immediate loads, but we do support immediate failure.
@@ -510,7 +510,7 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::loadResource(CachedRe
     return resource;
 }
 
-CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalidationPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, DeferOption defer) const
+CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalidationPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) const
 {
     if (!existingResource)
         return Load;
@@ -539,7 +539,7 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida
 
     // Do not load from cache if images are not enabled. The load for this image will be blocked
     // in CachedImage::load.
-    if (DeferredByClient == defer)
+    if (CachedResourceRequest::DeferredByClient == defer)
         return Reload;
     
     // Don't reload resources while pasting.
@@ -764,8 +764,8 @@ void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
     --m_requestCount;
     ASSERT(m_requestCount > -1);
 }
-    
-void CachedResourceLoader::preload(CachedResource::Type type, ResourceRequest& request, const String& charset, bool referencedFromBody)
+
+void CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequest& request, const String& charset, bool referencedFromBody)
 {
     // FIXME: Rip this out when we are sure it is no longer necessary (even for mobile).
     UNUSED_PARAM(referencedFromBody);
@@ -780,12 +780,12 @@ void CachedResourceLoader::preload(CachedResource::Type type, ResourceRequest& r
         if (!hasRendering && !canBlockParser) {
             // Don't preload subresources that can't block the parser before we have something to draw.
             // This helps prevent preloads from delaying first display when bandwidth is limited.
-            PendingPreload pendingPreload = { type, request, charset };
+            PendingPreload pendingPreload = { type, request.resourceRequest(), charset };
             m_pendingPreloads.append(pendingPreload);
             return;
         }
     }
-    requestPreload(type, request, charset);
+    requestPreload(type, request.mutableResourceRequest(), charset);
 }
 
 void CachedResourceLoader::checkForPendingPreloads() 
index e2e2ae4..c5b2365 100644 (file)
 #ifndef CachedResourceLoader_h
 #define CachedResourceLoader_h
 
+#include "CachePolicy.h"
 #include "CachedResource.h"
 #include "CachedResourceHandle.h"
-#include "CachePolicy.h"
+#include "CachedResourceRequest.h"
 #include "ResourceLoadPriority.h"
 #include "Timer.h"
 #include <wtf/Deque.h>
@@ -44,7 +45,6 @@ class CachedSVGDocument;
 class CachedFont;
 class CachedImage;
 class CachedRawResource;
-class CachedResourceRequest;
 class CachedScript;
 class CachedShader;
 class CachedTextTrack;
@@ -69,7 +69,6 @@ friend class ImageLoader;
 friend class ResourceCacheValidationSuppressor;
 
 public:
-    enum DeferOption { NoDefer, DeferredByClient };
     static PassRefPtr<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(new CachedResourceLoader(documentLoader)); }
     ~CachedResourceLoader();
 
@@ -131,7 +130,7 @@ public:
     bool isPreloaded(const String& urlString) const;
     void clearPreloads();
     void clearPendingPreloads();
-    void preload(CachedResource::Type, ResourceRequest&, const String& charset, bool referencedFromBody);
+    void preload(CachedResource::Type, CachedResourceRequest&, const String& charset, bool referencedFromBody);
     void checkForPendingPreloads();
     void printPreloadStats();
     bool canRequest(CachedResource::Type, const KURL&, bool forPreload = false);
@@ -149,7 +148,7 @@ private:
     void requestPreload(CachedResource::Type, ResourceRequest&, const String& charset);
 
     enum RevalidationPolicy { Use, Revalidate, Reload, Load };
-    RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, ResourceRequest&, bool forPreload, CachedResource* existingResource, DeferOption) const;
+    RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, ResourceRequest&, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption) const;
     
     void notifyLoadedFromMemoryCache(CachedResource*);
     bool checkInsecureContent(CachedResource::Type, const KURL&) const;
index 6add39b..7be7349 100644 (file)
 #include "config.h"
 #include "CachedResourceRequest.h"
 
+#include "CachedResourceLoader.h"
+#include "Document.h"
+#include "Element.h"
+
 namespace WebCore {
 
 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequest, const String& charset, ResourceLoadPriority priority)
@@ -34,7 +38,7 @@ CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ
     , m_options(CachedResourceLoader::defaultCachedResourceOptions())
     , m_priority(priority)
     , m_forPreload(false)
-    , m_defer(CachedResourceLoader::NoDefer)
+    , m_defer(NoDefer)
 {
 }
 
@@ -43,7 +47,7 @@ CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ
     , m_options(options)
     , m_priority(ResourceLoadPriorityUnresolved)
     , m_forPreload(false)
-    , m_defer(CachedResourceLoader::NoDefer)
+    , m_defer(NoDefer)
 {
 }
 
@@ -52,8 +56,48 @@ CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ
     , m_options(CachedResourceLoader::defaultCachedResourceOptions())
     , m_priority(priority)
     , m_forPreload(false)
-    , m_defer(CachedResourceLoader::NoDefer)
+    , m_defer(NoDefer)
+{
+}
+
+CachedResourceRequest::~CachedResourceRequest()
+{
+}
+
+void CachedResourceRequest::setInitiator(PassRefPtr<Element> element)
 {
+    ASSERT(!m_initiatorElement && !m_initiatorDocument);
+    m_initiatorElement = element;
 }
 
+void CachedResourceRequest::setInitiator(const AtomicString& name, PassRefPtr<Document> document)
+{
+    ASSERT(!m_initiatorElement && !m_initiatorDocument);
+    m_initiatorName = name;
+    m_initiatorDocument = document;
 }
+
+const AtomicString& CachedResourceRequest::initiatorName() const
+{
+    if (m_initiatorElement)
+        return m_initiatorElement->localName();
+    if (!m_initiatorName.isEmpty())
+        return m_initiatorName;
+
+    DEFINE_STATIC_LOCAL(AtomicString, defaultName, ("resource", AtomicString::ConstructFromLiteral));
+    return defaultName;
+}
+
+PassRefPtr<Document> CachedResourceRequest::initiatorDocument()
+{
+    if (m_initiatorElement)
+        return m_initiatorElement->document();
+    return m_initiatorDocument;
+}
+
+PassRefPtr<Element> CachedResourceRequest::initiatorElement()
+{
+    return m_initiatorElement;
+}
+
+} // namespace WebCore
index cb043df..4aa30d4 100644 (file)
 #ifndef CachedResourceRequest_h
 #define CachedResourceRequest_h
 
-#include "CachedResourceLoader.h"
 #include "ResourceLoadPriority.h"
+#include "ResourceLoaderOptions.h"
+#include "ResourceRequest.h"
+#include <wtf/RefPtr.h>
+#include <wtf/text/AtomicString.h>
 
 namespace WebCore {
+class Document;
+class Element;
 
 class CachedResourceRequest {
 public:
+    enum DeferOption { NoDefer, DeferredByClient };
+
     explicit CachedResourceRequest(const ResourceRequest&, const String& charset = String(), ResourceLoadPriority = ResourceLoadPriorityUnresolved);
     CachedResourceRequest(const ResourceRequest&, const ResourceLoaderOptions&);
     CachedResourceRequest(const ResourceRequest&, ResourceLoadPriority);
+    ~CachedResourceRequest();
 
     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; }
+    void setOptions(const ResourceLoaderOptions& options) { m_options = 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; }
+    DeferOption defer() const { return m_defer; }
+    void setDefer(DeferOption defer) { m_defer = defer; }
+    void setInitiator(PassRefPtr<Element>);
+    void setInitiator(const AtomicString& name, PassRefPtr<Document>);
+    const AtomicString& initiatorName() const;
+    PassRefPtr<Document> initiatorDocument();
+    PassRefPtr<Element> initiatorElement();
 
 private:
     ResourceRequest m_resourceRequest;
@@ -54,7 +68,10 @@ private:
     ResourceLoaderOptions m_options;
     ResourceLoadPriority m_priority;
     bool m_forPreload;
-    CachedResourceLoader::DeferOption m_defer;
+    DeferOption m_defer;
+    RefPtr<Element> m_initiatorElement;
+    RefPtr<Document> m_initiatorDocument;
+    AtomicString m_initiatorName;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp b/Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp
new file mode 100644 (file)
index 0000000..463145c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 "CachedResourceRequestInitiators.h"
+
+namespace WebCore {
+
+CachedResourceRequestInitiators::CachedResourceRequestInitiators()
+    : css("css", AtomicString::ConstructFromLiteral)
+    , icon("icon", AtomicString::ConstructFromLiteral)
+{
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h b/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h
new file mode 100644 (file)
index 0000000..3354d68
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 CachedResourceRequestInitiators_h
+#define CachedResourceRequestInitiators_h
+
+#include "ThreadGlobalData.h"
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class CachedResourceRequestInitiators {
+    WTF_MAKE_NONCOPYABLE(CachedResourceRequestInitiators); WTF_MAKE_FAST_ALLOCATED;
+public:
+    AtomicString css;
+    AtomicString icon;
+private:
+    CachedResourceRequestInitiators();
+    friend class ThreadGlobalData;
+};
+
+inline CachedResourceRequestInitiators& cachedResourceRequestInitiators()
+{
+    return threadGlobalData().cachedResourceRequestInitiators();
+}
+
+} // namespace WebCore
+
+#endif
index 8c9d0ce..e07108e 100644 (file)
@@ -29,6 +29,7 @@
 #include "CachedRawResource.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "Document.h"
 #include "Frame.h"
 #include "FrameLoader.h"
@@ -66,6 +67,7 @@ void IconLoader::startLoading()
     request.mutableResourceRequest().setTargetType(ResourceRequest::TargetIsFavicon);
 #endif
     request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
+    request.setInitiator(cachedResourceRequestInitiators().icon, m_frame->document());
 
     m_resource = m_frame->document()->cachedResourceLoader()->requestRawResource(request);
     if (m_resource)
index da846f8..bc1d65e 100644 (file)
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "ThreadGlobalData.h"
 
+#include "CachedResourceRequestInitiators.h"
 #include "DOMImplementation.h"
 #include "EventNames.h"
 #include "InspectorCounters.h"
@@ -59,7 +60,8 @@ ThreadGlobalData* ThreadGlobalData::staticData;
 #endif
 
 ThreadGlobalData::ThreadGlobalData()
-    : m_eventNames(adoptPtr(new EventNames))
+    : m_cachedResourceRequestInitiators(adoptPtr(new CachedResourceRequestInitiators))
+    , m_eventNames(adoptPtr(new EventNames))
     , m_threadTimers(adoptPtr(new ThreadTimers))
     , m_xmlTypeRegExp(adoptPtr(new XMLMIMETypeRegExp))
 #ifndef NDEBUG
index 42f05af..7e05425 100644 (file)
@@ -41,6 +41,7 @@ using WTF::ThreadSpecific;
 
 namespace WebCore {
 
+class CachedResourceRequestInitiators;
     class EventNames;
     class ThreadLocalInspectorCounters;
     class ThreadTimers;
@@ -56,6 +57,7 @@ namespace WebCore {
         ~ThreadGlobalData();
         void destroy(); // called on workers to clean up the ThreadGlobalData before the thread exits.
 
+        CachedResourceRequestInitiators& cachedResourceRequestInitiators() { return *m_cachedResourceRequestInitiators; }
         EventNames& eventNames() { return *m_eventNames; }
         ThreadTimers& threadTimers() { return *m_threadTimers; }
         XMLMIMETypeRegExp& xmlTypeRegExp() { return *m_xmlTypeRegExp; }
@@ -73,6 +75,7 @@ namespace WebCore {
 #endif
 
     private:
+        OwnPtr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
         OwnPtr<EventNames> m_eventNames;
         OwnPtr<ThreadTimers> m_threadTimers;
         OwnPtr<XMLMIMETypeRegExp> m_xmlTypeRegExp;
index 87ff0d6..eafea1a 100644 (file)
@@ -82,6 +82,7 @@ void SVGFEImageElement::clearResourceReferences()
 void SVGFEImageElement::requestImageResource()
 {
     CachedResourceRequest request(ResourceRequest(ownerDocument()->completeURL(href())));
+    request.setInitiator(this);
     m_cachedImage = document()->cachedResourceLoader()->requestImage(request);
 
     if (m_cachedImage)
index c34fed8..3b2d495 100644 (file)
@@ -98,6 +98,7 @@ void SVGFontFaceUriElement::loadFont()
     if (!href.isNull()) {
         CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader();
         CachedResourceRequest request(ResourceRequest(document()->completeURL(href)));
+        request.setInitiator(this);
         m_cachedFont = cachedResourceLoader->requestFont(request);
         if (m_cachedFont) {
             m_cachedFont->addClient(this);
index 6046ec6..f1e1c03 100644 (file)
@@ -256,6 +256,7 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName)
             KURL url = document()->completeURL(href());
             if (url.hasFragmentIdentifier()) {
                 CachedResourceRequest request(ResourceRequest(url.string()));
+                request.setInitiator(this);
                 m_cachedDocument = document()->cachedResourceLoader()->requestSVGDocument(request);
                 if (m_cachedDocument)
                     m_cachedDocument->addClient(this);