2011-04-17 Gavin Peters <gavinp@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Apr 2011 21:30:32 +0000 (21:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Apr 2011 21:30:32 +0000 (21:30 +0000)
        Reviewed by Adam Barth.

        Add support for link rel type "subresource"
        https://bugs.webkit.org/show_bug.cgi?id=57842

        Link rel=prefetch is great for cache warming for resources on
        subsequent pages, but it launches requests at too low a priority
        to use for subresources of the current page.

        During testing, I was dissapointed to see the results for the http
        test below don't give the subresource priority ordering.  This is
        another instance of https://bugs.webkit.org/show_bug.cgi?id=49238
        which I'll be working on next, and thus fix the test.

        * fast/dom/HTMLLinkElement/subresource-expected.txt: Added.
        * fast/dom/HTMLLinkElement/subresource.html: Added.
        * http/tests/misc/link-rel-prefetch-and-subresource-expected.txt: Added.
        * http/tests/misc/link-rel-prefetch-and-subresource.html: Added.
        * platform/gtk/Skipped:
        * platform/mac/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:
2011-04-17  Gavin Peters  <gavinp@chromium.org>

        Reviewed by Adam Barth.

        Add support for link rel type "subresource"
        https://bugs.webkit.org/show_bug.cgi?id=57842

        Link rel=prefetch is great for cache warming for resources on
        subsequent pages, but it launches requests at too low a priority
        to use for subresources of the current page.

        Particularly after https://bugs.webkit.org/show_bug.cgi?id=51940
        is implemented, a rel type that launches requests at an higher
        priority is going to be very useful.  This rel type is in the
        HTML5 spec at http://wiki.whatwg.org/wiki/RelExtensions .  An
        expected use case will be for servers to provide subresource hints
        in link headers, which will allow servers to help make the web
        faster.

        This feature continues my implementation of the Link header, which
        we've talked about in WebKit-dev in
        https://lists.webkit.org/pipermail/webkit-dev/2011-February/016034.html.

        Tests: fast/dom/HTMLLinkElement/subresource.html
               http/tests/misc/link-rel-prefetch-and-subresource.html

        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::~HTMLLinkElement):
        (WebCore::HTMLLinkElement::tokenizeRelAttribute):
        (WebCore::HTMLLinkElement::process):
        (WebCore::HTMLLinkElement::onloadTimerFired):
        (WebCore::HTMLLinkElement::notifyFinished):
        * html/HTMLLinkElement.h:
        (WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
        * loader/cache/CachedResource.cpp:
        (WebCore::defaultPriorityForResourceType):
        * loader/cache/CachedResource.h:
        (WebCore::CachedResource::isLinkResource):
        * loader/cache/CachedResourceLoader.cpp:
        (WebCore::createResource):
        (WebCore::CachedResourceLoader::requestLinkResource):
        (WebCore::CachedResourceLoader::canRequest):
        (WebCore::CachedResourceLoader::incrementRequestCount):
        (WebCore::CachedResourceLoader::decrementRequestCount):
        * loader/cache/CachedResourceLoader.h:
        * loader/cache/CachedResourceRequest.cpp:
        (WebCore::cachedResourceTypeToTargetType):
        (WebCore::CachedResourceRequest::load):

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLLinkElement/subresource-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLLinkElement/subresource.html [new file with mode: 0644]
LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebCore/loader/cache/CachedResourceRequest.cpp

index a583918..fb9ccae 100644 (file)
@@ -1,3 +1,28 @@
+2011-04-17  Gavin Peters  <gavinp@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for link rel type "subresource"
+        https://bugs.webkit.org/show_bug.cgi?id=57842
+
+        Link rel=prefetch is great for cache warming for resources on
+        subsequent pages, but it launches requests at too low a priority
+        to use for subresources of the current page.
+
+        During testing, I was dissapointed to see the results for the http
+        test below don't give the subresource priority ordering.  This is
+        another instance of https://bugs.webkit.org/show_bug.cgi?id=49238
+        which I'll be working on next, and thus fix the test.
+
+        * fast/dom/HTMLLinkElement/subresource-expected.txt: Added.
+        * fast/dom/HTMLLinkElement/subresource.html: Added.
+        * http/tests/misc/link-rel-prefetch-and-subresource-expected.txt: Added.
+        * http/tests/misc/link-rel-prefetch-and-subresource.html: Added.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+
 2011-04-16  Dan Bernstein  <mitz@apple.com>
 
         Updated results for fast/block/float/032.html after r84096. Filed http://webkit.org/b/58736 to
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/subresource-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/subresource-expected.txt
new file mode 100644 (file)
index 0000000..b65bfe2
--- /dev/null
@@ -0,0 +1,3 @@
+prefetch.link has MIME type application/octet-stream
+PASS onload called!
+This test will only print "PASS" or "FAIL" if link prefetches are enabled, otherwise it will show nothing below.
diff --git a/LayoutTests/fast/dom/HTMLLinkElement/subresource.html b/LayoutTests/fast/dom/HTMLLinkElement/subresource.html
new file mode 100644 (file)
index 0000000..0477e03
--- /dev/null
@@ -0,0 +1,20 @@
+<body>
+<div id="console"></div>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+function prefetch_onload() {
+    testPassed('onload called!');
+    layoutTestController.notifyDone();
+}
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+    layoutTestController.dumpResourceResponseMIMETypes();
+}
+</script>
+<html>
+<p>This test will only print "PASS" or "FAIL" if link prefetches are
+enabled, otherwise it will show nothing below.</p>
+<link href="prefetch.link" rel="prefetch" onload="prefetch_onload()" onerror="testFailed('onerror')" />
+</html>
+
diff --git a/LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource-expected.txt b/LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource-expected.txt
new file mode 100644 (file)
index 0000000..5284788
--- /dev/null
@@ -0,0 +1,8 @@
+Resource requests:
+
+
+1st.jpg
+2nd.jpg
+3rd.jpg
+4th.jpg
+5th.jpg
diff --git a/LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource.html b/LayoutTests/http/tests/misc/link-rel-prefetch-and-subresource.html
new file mode 100644 (file)
index 0000000..19a2623
--- /dev/null
@@ -0,0 +1,73 @@
+<html>
+<head>
+  <script>
+function CallCommand(cmd)
+{
+ try {
+     var req = new XMLHttpRequest;
+     req.open("GET", "/resources/network-simulator.php?command=" + cmd, false);
+     req.send(null);
+     return req.responseText;
+ } catch (ex) {
+     return "";
+ }
+}
+
+function startTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+}
+
+function endTest()
+{
+    getResourceLog();
+    CallCommand("clear-resource-request-log");
+
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function getResourceLog()
+{
+    var log = CallCommand("get-resource-request-log");
+    var logLines = log.split('\n');
+    logLines.sort();
+    document.getElementById('result').innerText = logLines.join('\n');
+}
+
+CallCommand("start-resource-request-log");
+window.addEventListener('load', startTest, false);
+  </script>
+
+  <!-- link rel=subresource is very similar to link rel=prefetch, however it is
+       expected to have a higher network priority.  This test should confirm that the
+       priorities of the two types of prefetch are being observed -->
+
+  <script>
+  var linkLoadCount = 5;
+
+  function decrementLinkLoadCount()
+  {
+      linkLoadCount--;
+      if (linkLoadCount == 0) {
+          endTest();
+      }
+  }
+  </script>
+  <link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=1st.jpg">
+  <link rel=subresource onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=2nd.jpg">
+  <link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=3rd.jpg">
+  <link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=4th.jpg">
+  <link rel=subresource onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=5th.jpg">
+</head>
+<body>
+
+  <div class="box bordered"></div>
+
+  <h2>Resource requests:</h2>
+  <pre id="result">Request log goes here in DRT</pre>
+</body>
+</html>
index b19f6b5..95cbbab 100644 (file)
@@ -512,6 +512,7 @@ http/tests/media/video-seekable-stall.html
 http/tests/mime/standard-mode-loads-stylesheet-with-empty-content-type.html
 http/tests/mime/standard-mode-loads-stylesheet-with-text-css-and-invalid-type.html
 http/tests/misc/acid3.html
+http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/policy-delegate-called-twice.html
 http/tests/misc/prefetch-purpose.html
 http/tests/misc/redirect-to-external-url.html
@@ -924,6 +925,7 @@ fast/dom/HTMLLinkElement/prefetch.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
+fast/dom/HTMLLinkElement/subresource.html
 
 # Tests failing because the context menu is grabbing mouse events.
 # https://bugs.webkit.org/show_bug.cgi?id=40601
index 47b52fb..e47fdd2 100644 (file)
@@ -186,6 +186,8 @@ fast/dom/HTMLLinkElement/prefetch.html
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/subresource.html
+http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html
 
 # Filenames aren't filtered out from edit drags yet, see https://bugs.wekit.org/show_bug.cgi?id=38826
index 8316b73..5b706e2 100644 (file)
@@ -2958,6 +2958,8 @@ fast/dom/HTMLLinkElement/prefetch.html
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/subresource.html
+http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html
 
 # [Qt] fast/text/bidi-explicit-embedding-past-end.html fails
index d782363..638aa24 100644 (file)
@@ -995,6 +995,8 @@ fast/dom/HTMLLinkElement/prefetch.html
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/subresource.html
+http/tests/misc/link-rel-prefetch-and-subresource.html
 http/tests/misc/prefetch-purpose.html
 
 # LayoutTestController::pageProperty is not implemented for WIN yet.
index 90f720d..134b13c 100644 (file)
@@ -1,3 +1,52 @@
+2011-04-17  Gavin Peters  <gavinp@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for link rel type "subresource"
+        https://bugs.webkit.org/show_bug.cgi?id=57842
+
+        Link rel=prefetch is great for cache warming for resources on
+        subsequent pages, but it launches requests at too low a priority
+        to use for subresources of the current page.
+
+        Particularly after https://bugs.webkit.org/show_bug.cgi?id=51940
+        is implemented, a rel type that launches requests at an higher
+        priority is going to be very useful.  This rel type is in the
+        HTML5 spec at http://wiki.whatwg.org/wiki/RelExtensions .  An
+        expected use case will be for servers to provide subresource hints
+        in link headers, which will allow servers to help make the web
+        faster.
+
+        This feature continues my implementation of the Link header, which
+        we've talked about in WebKit-dev in
+        https://lists.webkit.org/pipermail/webkit-dev/2011-February/016034.html.
+
+        Tests: fast/dom/HTMLLinkElement/subresource.html
+               http/tests/misc/link-rel-prefetch-and-subresource.html
+
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::~HTMLLinkElement):
+        (WebCore::HTMLLinkElement::tokenizeRelAttribute):
+        (WebCore::HTMLLinkElement::process):
+        (WebCore::HTMLLinkElement::onloadTimerFired):
+        (WebCore::HTMLLinkElement::notifyFinished):
+        * html/HTMLLinkElement.h:
+        (WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::defaultPriorityForResourceType):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::isLinkResource):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::createResource):
+        (WebCore::CachedResourceLoader::requestLinkResource):
+        (WebCore::CachedResourceLoader::canRequest):
+        (WebCore::CachedResourceLoader::incrementRequestCount):
+        (WebCore::CachedResourceLoader::decrementRequestCount):
+        * loader/cache/CachedResourceLoader.h:
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::cachedResourceTypeToTargetType):
+        (WebCore::CachedResourceRequest::load):
+
 2011-04-17  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Joseph Pecoraro.
index bc608af..2508f9d 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "Attribute.h"
 #include "CachedCSSStyleSheet.h"
+#include "CachedResource.h"
 #include "CachedResourceLoader.h"
 #include "CSSStyleSelector.h"
 #include "Document.h"
@@ -78,8 +79,8 @@ HTMLLinkElement::~HTMLLinkElement()
     }
     
 #if ENABLE(LINK_PREFETCH)
-    if (m_cachedLinkPrefetch)
-        m_cachedLinkPrefetch->removeClient(this);
+    if (m_cachedLinkResource)
+        m_cachedLinkResource->removeClient(this);
 #endif
 }
 
@@ -163,6 +164,7 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
     relAttribute.m_isDNSPrefetch = false;
 #if ENABLE(LINK_PREFETCH)
     relAttribute.m_isLinkPrefetch = false;
+    relAttribute.m_isLinkSubresource = false;
 #endif
     if (equalIgnoringCase(rel, "stylesheet"))
         relAttribute.m_isStyleSheet = true;
@@ -170,10 +172,6 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
         relAttribute.m_isIcon = true;
     else if (equalIgnoringCase(rel, "dns-prefetch"))
         relAttribute.m_isDNSPrefetch = true;
-#if ENABLE(LINK_PREFETCH)
-    else if (equalIgnoringCase(rel, "prefetch"))
-        relAttribute.m_isLinkPrefetch = true;
-#endif
     else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) {
         relAttribute.m_isStyleSheet = true;
         relAttribute.m_isAlternate = true;
@@ -191,6 +189,12 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
                 relAttribute.m_isAlternate = true;
             else if (equalIgnoringCase(*it, "icon"))
                 relAttribute.m_isIcon = true;
+#if ENABLE(LINK_PREFETCH)
+            else if (equalIgnoringCase(*it, "prefetch"))
+              relAttribute.m_isLinkPrefetch = true;
+            else if (equalIgnoringCase(*it, "subresource"))
+              relAttribute.m_isLinkSubresource = true;
+#endif
         }
     }
 }
@@ -232,12 +236,16 @@ void HTMLLinkElement::process()
     }
 
 #if ENABLE(LINK_PREFETCH)
-    if (m_relAttribute.m_isLinkPrefetch && m_url.isValid() && document()->frame()) {
+    if ((m_relAttribute.m_isLinkPrefetch || m_relAttribute.m_isLinkSubresource) && m_url.isValid() && document()->frame()) {
         if (!checkBeforeLoadEvent())
             return;
-        m_cachedLinkPrefetch = document()->cachedResourceLoader()->requestLinkPrefetch(m_url);
-        if (m_cachedLinkPrefetch)
-            m_cachedLinkPrefetch->addClient(this);
+        ResourceLoadPriority priority = ResourceLoadPriorityUnresolved;
+        if (m_relAttribute.m_isLinkSubresource)
+            priority = ResourceLoadPriorityLow;
+
+        m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(m_url, priority);
+        if (m_cachedLinkResource)
+            m_cachedLinkResource->addClient(this);
     }
 #endif
 
@@ -409,19 +417,19 @@ bool HTMLLinkElement::isLoading() const
 void HTMLLinkElement::onloadTimerFired(Timer<HTMLLinkElement>* timer)
 {
     ASSERT_UNUSED(timer, timer == &m_onloadTimer);
-    if (m_cachedLinkPrefetch->errorOccurred())
+    if (m_cachedLinkResource->errorOccurred())
         dispatchEvent(Event::create(eventNames().errorEvent, false, false));
     else
         dispatchEvent(Event::create(eventNames().loadEvent, false, false));
 
-    m_cachedLinkPrefetch->removeClient(this);
-    m_cachedLinkPrefetch = 0;
+    m_cachedLinkResource->removeClient(this);
+    m_cachedLinkResource = 0;
 }
 
 void HTMLLinkElement::notifyFinished(CachedResource* resource)
 {
     m_onloadTimer.startOneShot(0);
-    ASSERT(m_cachedLinkPrefetch.get() == resource);
+    ASSERT(m_cachedLinkResource.get() == resource);
 }
 #endif
 
index 2782e71..49ed68a 100644 (file)
@@ -44,6 +44,7 @@ public:
         bool m_isDNSPrefetch;
 #if ENABLE(LINK_PREFETCH)
         bool m_isLinkPrefetch;
+        bool m_isLinkSubresource;
 #endif
 
         RelAttribute()
@@ -53,6 +54,7 @@ public:
             , m_isDNSPrefetch(false)
 #if ENABLE(LINK_PREFETCH)
             , m_isLinkPrefetch(false)
+            , m_isLinkSubresource(false)
 #endif
             { 
             }
@@ -126,7 +128,7 @@ private:
     CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
     RefPtr<CSSStyleSheet> m_sheet;
 #if ENABLE(LINK_PREFETCH)
-    CachedResourceHandle<CachedResource> m_cachedLinkPrefetch;
+    CachedResourceHandle<CachedResource> m_cachedLinkResource;
     Timer<HTMLLinkElement> m_onloadTimer;
 #endif
     KURL m_url;
index 0df5bfa..95f5522 100644 (file)
@@ -62,7 +62,7 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type
         case CachedResource::ImageResource:
             return ResourceLoadPriorityLow;
 #if ENABLE(LINK_PREFETCH)
-        case CachedResource::LinkPrefetch:
+        case CachedResource::LinkResource:
             return ResourceLoadPriorityVeryLow;
 #endif
     }
index 16920a5..72b00e5 100644 (file)
@@ -65,7 +65,7 @@ public:
         , XSLStyleSheet
 #endif
 #if ENABLE(LINK_PREFETCH)
-        , LinkPrefetch
+        , LinkResource
 #endif
     };
 
@@ -129,10 +129,10 @@ public:
     void setLoading(bool b) { m_loading = b; }
 
     virtual bool isImage() const { return false; }
-    bool isPrefetch() const
+    bool isLinkResource() const
     {
 #if ENABLE(LINK_PREFETCH)
-        return type() == LinkPrefetch;
+        return type() == LinkResource;
 #else
         return false;
 #endif
index f780c6c..25de1dc 100644 (file)
@@ -71,8 +71,8 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
         return new CachedXSLStyleSheet(url.string());
 #endif
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkPrefetch:
-        return new CachedResource(url.string(), CachedResource::LinkPrefetch);
+    case CachedResource::LinkResource:
+        return new CachedResource(url.string(), CachedResource::LinkResource);
 #endif
     }
     ASSERT_NOT_REACHED();
@@ -188,10 +188,10 @@ CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(const String& ur
 #endif
 
 #if ENABLE(LINK_PREFETCH)
-CachedResource* CachedResourceLoader::requestLinkPrefetch(const String& url)
+CachedResource* CachedResourceLoader::requestLinkResource(const String& url, ResourceLoadPriority priority)
 {
     ASSERT(frame());
-    return requestResource(CachedResource::LinkPrefetch, url, String());
+    return requestResource(CachedResource::LinkResource, url, String(), priority);
 }
 #endif
 
@@ -206,7 +206,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
     case CachedResource::Script:
     case CachedResource::FontResource:
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkResource:
 #endif
         // These types of resources can be loaded from any origin.
         // FIXME: Are we sure about CachedResource::FontResource?
@@ -248,7 +248,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
         break;
     }
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkResource:
         // Prefetch cannot affect the current document.
         break;
 #endif
@@ -593,7 +593,7 @@ void CachedResourceLoader::notifyLoadedFromMemoryCache(CachedResource* resource)
 
 void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
 {
-    if (res->isPrefetch())
+    if (res->isLinkResource())
         return;
 
     ++m_requestCount;
@@ -601,7 +601,7 @@ void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
 
 void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
 {
-    if (res->isPrefetch())
+    if (res->isLinkResource())
         return;
 
     --m_requestCount;
index 2d6b1d2..b19573c 100644 (file)
@@ -69,7 +69,7 @@ public:
     CachedXSLStyleSheet* requestXSLStyleSheet(const String& url);
 #endif
 #if ENABLE(LINK_PREFETCH)
-    CachedResource* requestLinkPrefetch(const String &url);
+    CachedResource* requestLinkResource(const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved);
 #endif
 
     // Logs an access denied message to the console for the specified URL.
index 02cf13e..9e7fe8f 100644 (file)
 
 namespace WebCore {
     
-static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
+static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type, ResourceLoadPriority priority)
 {
+#if !ENABLE(LINK_PREFETCH)
+    UNUSED_PARAM(priority);
+#endif
     switch (type) {
     case CachedResource::CSSStyleSheet:
 #if ENABLE(XSLT)
@@ -57,8 +60,10 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource
     case CachedResource::ImageResource:
         return ResourceRequest::TargetIsImage;
 #if ENABLE(LINK_PREFETCH)
-    case CachedResource::LinkPrefetch:
-        return ResourceRequest::TargetIsPrefetch;
+    case CachedResource::LinkResource:
+        if (priority == ResourceLoadPriorityLowest)
+            return ResourceRequest::TargetIsPrefetch;
+        return ResourceRequest::TargetIsSubresource;
 #endif
     }
     ASSERT_NOT_REACHED();
@@ -85,7 +90,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
     RefPtr<CachedResourceRequest> request = adoptRef(new CachedResourceRequest(cachedResourceLoader, resource, incremental));
 
     ResourceRequest resourceRequest(resource->url());
-    resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type()));
+    resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type(), resource->loadPriority()));
 
     if (!resource->accept().isEmpty())
         resourceRequest.setHTTPAccept(resource->accept());
@@ -108,7 +113,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
     }
     
 #if ENABLE(LINK_PREFETCH)
-    if (resource->type() == CachedResource::LinkPrefetch)
+    if (resource->type() == CachedResource::LinkResource)
         resourceRequest.setHTTPHeaderField("Purpose", "prefetch");
 #endif