summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-07-13 04:14:52 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-07-13 04:14:52 -0700
commitb72d3304e698fa5ca4ca89009283250d89a72268 (patch)
tree3afa22f71b3041f833533d623b55ad3524ce4df1
parent23e9dd818a876304304944c844be7625f63383c4 (diff)
parent5d6f8ef31d11ee66598999b1b749ba9ff767e4d5 (diff)
downloadexternal_webkit-b72d3304e698fa5ca4ca89009283250d89a72268.zip
external_webkit-b72d3304e698fa5ca4ca89009283250d89a72268.tar.gz
external_webkit-b72d3304e698fa5ca4ca89009283250d89a72268.tar.bz2
Merge "Copy back the upstreamed version of prefetch https://bugs.webkit.org/show_bug.cgi?id=3652"
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement10-expected.txt2
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement10-link.file12
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement10.html18
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement10.js51
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement11-expected.txt2
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement11.css1
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement11.html15
-rw-r--r--LayoutTests/dom/html/level2/html/HTMLLinkElement11.js51
-rw-r--r--WebCore/html/HTMLLinkElement.cpp38
-rw-r--r--WebCore/html/HTMLLinkElement.h31
-rw-r--r--WebCore/loader/Cache.cpp5
-rw-r--r--WebCore/loader/CachedCSSStyleSheet.cpp8
-rw-r--r--WebCore/loader/CachedLinkPrefetch.h68
-rw-r--r--WebCore/loader/CachedResource.cpp18
-rw-r--r--WebCore/loader/CachedResource.h12
-rw-r--r--WebCore/loader/CachedScript.cpp6
-rw-r--r--WebCore/loader/CachedScript.h1
-rw-r--r--WebCore/loader/DocLoader.cpp16
-rw-r--r--WebCore/loader/DocLoader.h5
-rw-r--r--WebCore/loader/loader.cpp8
-rw-r--r--WebCore/platform/network/ResourceRequestBase.h3
21 files changed, 51 insertions, 320 deletions
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement10-expected.txt b/LayoutTests/dom/html/level2/html/HTMLLinkElement10-expected.txt
deleted file mode 100644
index 6f009e8..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement10-expected.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLLinkElement10
-Status: Success
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement10-link.file b/LayoutTests/dom/html/level2/html/HTMLLinkElement10-link.file
deleted file mode 100644
index 4a94b89..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement10-link.file
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<HTML>
-<HEAD>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
-<TITLE>NIST DOM HTML Test - LINK</TITLE>
-<BODY>
-<P>
-This is the test link that's pre-fetched by the prefetch test.
-</P>
-</BODY>
-</HTML>
-
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement10.html b/LayoutTests/dom/html/level2/html/HTMLLinkElement10.html
deleted file mode 100644
index dcf20e1..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement10.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<HTML>
-<HEAD>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
-<TITLE>NIST DOM HTML Test - LINK</TITLE>
-<script charset='UTF-8' type='text/javascript' src='selfhtml.js'></script>
-<script charset='UTF-8' type='text/javascript' src='HTMLLinkElement10.js'></script>
-<LINK CHARSET="Latin-1" HREF="HTMLLinkElement10-link.file" HREFLANG="en" MEDIA="screen" REL="prefetch" TYPE="text/html" onload="prefetchComplete()">
-<LINK CHARSET="Latin-1" HREF="./files/style1.css" HREFLANG="en" MEDIA="screen" REV="stylesheet" TYPE="text/css">
-<script type='text/javascript'>startTest10();
-</script></HEAD>
-<BODY onload="loadComplete()">
-<P>
-<BR>
-</P>
-</BODY>
-</HTML>
-
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement10.js b/LayoutTests/dom/html/level2/html/HTMLLinkElement10.js
deleted file mode 100644
index c0ac4a7..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement10.js
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
- /**
- * Gets URI that identifies the test.
- * @return uri identifier of test
- */
-function getTargetURI() {
- return "http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLLinkElement10";
- }
-
-var docsLoaded = 0;
-var mainLoaded = false;
-var prefetchLoaded = false;
-
-function finishTest() {
- if (mainLoaded && prefetchLoaded) {
- setResult(null, null);
- } else {
- if (!prefetchLoaded) {
- setResult("fail", "No prefetch onload fired");
- } else {
- setResult("fail", "Prefetch fired, but maybe the document onload didn't");
- }
- }
- if (window.layoutTestController) {
- layoutTestController.notifyDone();
- }
-}
-
-function loadComplete() {
- mainLoaded = true;
- if (++docsLoaded == 2) {
- finishTest();
- }
-}
-
-function prefetchComplete() {
- prefetchLoaded = true;
- if (++docsLoaded == 2) {
- finishTest();
- }
-}
-
-
-
-function startTest10() {
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-}
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement11-expected.txt b/LayoutTests/dom/html/level2/html/HTMLLinkElement11-expected.txt
deleted file mode 100644
index d53710a..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement11-expected.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Test: http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLLinkElement11
-Status: Success
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.css b/LayoutTests/dom/html/level2/html/HTMLLinkElement11.css
deleted file mode 100644
index 6a5dab8..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.css
+++ /dev/null
@@ -1 +0,0 @@
-div { font-family: Arial, Helvetica, sans-serif; color: red; }
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.html b/LayoutTests/dom/html/level2/html/HTMLLinkElement11.html
deleted file mode 100644
index 9b9a5e4..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<HTML>
-<HEAD>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
-<TITLE>NIST DOM HTML Test - LINK</TITLE>
-<script charset='UTF-8' type='text/javascript' src='selfhtml.js'></script>
-<script charset='UTF-8' type='text/javascript' src='HTMLLinkElement11.js'></script><script type='text/javascript'>startTest11();</script></HEAD>
-<LINK CHARSET="Latin-1" HREF="HTMLLinkElement11.css" HREFLANG="en" MEDIA="screen" REL="stylesheet" TYPE="text/css" onload="cssComplete()">
-<BODY onload="loadComplete()">
-<P>
-<BR>
-</P>
-</BODY>
-</HTML>
-
diff --git a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.js b/LayoutTests/dom/html/level2/html/HTMLLinkElement11.js
deleted file mode 100644
index b8bf1cb..0000000
--- a/LayoutTests/dom/html/level2/html/HTMLLinkElement11.js
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
- /**
- * Gets URI that identifies the test.
- * @return uri identifier of test
- */
-function getTargetURI() {
- return "http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLLinkElement11";
- }
-
-var docsLoaded = 0;
-var mainLoaded = false;
-var cssLoaded = false;
-
-function finishTest() {
- if (mainLoaded && cssLoaded) {
- setResult(null, null);
- } else {
- if (!cssLoaded) {
- setResult("fail", "No css onload fired");
- } else {
- setResult("fail", "Css fired, but maybe the document onload didn't");
- }
- }
- if (window.layoutTestController) {
- layoutTestController.notifyDone();
- }
-}
-
-function loadComplete() {
- mainLoaded = true;
- if (++docsLoaded == 2) {
- finishTest();
- }
-}
-
-function cssComplete() {
- cssLoaded = true;
- if (++docsLoaded == 2) {
- finishTest();
- }
-}
-
-
-
-function startTest11() {
- if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
- }
-}
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index 64a52cc..eff250a 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -41,9 +41,6 @@
#include "ScriptEventListener.h"
#include "Settings.h"
#include <wtf/StdLibExtras.h>
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
-#include "CachedLinkPrefetch.h"
-#endif
namespace WebCore {
@@ -55,9 +52,6 @@ inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document*
, m_loading(false)
, m_createdByParser(createdByParser)
, m_shouldProcessAfterAttach(false)
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- , m_timer(this, &HTMLLinkElement::timerFired)
-#endif
{
ASSERT(hasTagName(linkTag));
}
@@ -137,10 +131,6 @@ void HTMLLinkElement::parseMappedAttribute(Attribute* attr)
setDisabledState(!attr->isNull());
else if (attr->name() == onbeforeloadAttr)
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- else if (attr->name() == onloadAttr)
- setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
-#endif
else {
if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
@@ -154,7 +144,7 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
relAttribute.m_isIcon = false;
relAttribute.m_isAlternate = false;
relAttribute.m_isDNSPrefetch = false;
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
+#if ENABLE(LINK_PREFETCH)
relAttribute.m_isLinkPrefetch = false;
#endif
#ifdef ANDROID_APPLE_TOUCH_ICON
@@ -173,7 +163,7 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
#endif
else if (equalIgnoringCase(rel, "dns-prefetch"))
relAttribute.m_isDNSPrefetch = true;
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
+#if ENABLE(LINK_PREFETCH)
else if (equalIgnoringCase(rel, "prefetch"))
relAttribute.m_isLinkPrefetch = true;
#endif
@@ -221,14 +211,9 @@ void HTMLLinkElement::process()
if (m_relAttribute.m_isDNSPrefetch && m_url.isValid() && !m_url.isEmpty())
ResourceHandle::prepareForURL(m_url);
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- if (m_relAttribute.m_isLinkPrefetch && m_url.isValid()) {
- m_cachedLinkPrefetch = document()->docLoader()->requestLinkPrefetch(m_url);
- m_loading = true;
-
- if (m_cachedLinkPrefetch)
- m_cachedLinkPrefetch->addClient(this);
- }
+#if ENABLE(LINK_PREFETCH)
+ if (m_relAttribute.m_isLinkPrefetch && m_url.isValid())
+ document()->docLoader()->requestLinkPrefetch(m_url);
#endif
bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet();
@@ -393,19 +378,6 @@ bool HTMLLinkElement::isLoading() const
return static_cast<CSSStyleSheet *>(m_sheet.get())->isLoading();
}
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
-void HTMLLinkElement::notifyFinished(CachedResource*)
-{
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
-}
-
-void HTMLLinkElement::timerFired(Timer<HTMLLinkElement>*)
-{
- dispatchEvent(Event::create(eventNames().loadEvent, false, false));
-}
-#endif
-
bool HTMLLinkElement::sheetLoaded()
{
if (!isLoading() && !isDisabled() && !isAlternate()) {
diff --git a/WebCore/html/HTMLLinkElement.h b/WebCore/html/HTMLLinkElement.h
index a2d88c2..8fb93ba 100644
--- a/WebCore/html/HTMLLinkElement.h
+++ b/WebCore/html/HTMLLinkElement.h
@@ -27,16 +27,11 @@
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
#include "HTMLElement.h"
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
-#include "Timer.h"
-#endif
namespace WebCore {
class CachedCSSStyleSheet;
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
class CachedLinkPrefetch;
-#endif
class KURL;
class HTMLLinkElement : public HTMLElement, public CachedResourceClient {
@@ -50,15 +45,16 @@ public:
bool m_isTouchIcon;
bool m_isPrecomposedTouchIcon;
#endif
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
+#if ENABLE(LINK_PREFETCH)
bool m_isLinkPrefetch;
#endif
- RelAttribute() : m_isStyleSheet(false), m_isIcon(false), m_isAlternate(false), m_isDNSPrefetch(false)
-#ifdef ANDROID_APPLE_TOUCH_ICON
- , m_isTouchIcon(false), m_isPrecomposedTouchIcon(false)
-#endif
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
+ RelAttribute()
+ : m_isStyleSheet(false)
+ , m_isIcon(false)
+ , m_isAlternate(false)
+ , m_isDNSPrefetch(false)
+#if ENABLE(LINK_PREFETCH)
, m_isLinkPrefetch(false)
#endif
{ };
@@ -99,10 +95,6 @@ private:
// from CachedResourceClient
virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- virtual void notifyFinished(CachedResource*);
-#endif
-
virtual bool sheetLoaded();
bool isAlternate() const { return m_disabledState == Unset && m_relAttribute.m_isAlternate; }
@@ -128,9 +120,6 @@ private:
#endif
private:
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- void timerFired(Timer<HTMLLinkElement>*);
-#endif
HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
enum DisabledState {
@@ -141,9 +130,6 @@ private:
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
RefPtr<CSSStyleSheet> m_sheet;
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- CachedResourceHandle<CachedLinkPrefetch> m_cachedLinkPrefetch;
-#endif
KURL m_url;
String m_type;
String m_media;
@@ -152,9 +138,6 @@ private:
bool m_loading;
bool m_createdByParser;
bool m_shouldProcessAfterAttach;
-#if PLATFORM(ANDROID) && ENABLE(LINK_PREFETCH)
- Timer<HTMLLinkElement> m_timer;
-#endif
};
} //namespace
diff --git a/WebCore/loader/Cache.cpp b/WebCore/loader/Cache.cpp
index 5f4d0e7..521d075 100644
--- a/WebCore/loader/Cache.cpp
+++ b/WebCore/loader/Cache.cpp
@@ -38,9 +38,6 @@
#include "SecurityOrigin.h"
#include <stdio.h>
#include <wtf/CurrentTime.h>
-#if ENABLE(LINK_PREFETCH)
-#include "CachedLinkPrefetch.h"
-#endif
using namespace std;
@@ -91,7 +88,7 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
#endif
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
- return new CachedLinkPrefetch(url.string());
+ return new CachedResource(url.string(), CachedResource::LinkPrefetch);
#endif
default:
break;
diff --git a/WebCore/loader/CachedCSSStyleSheet.cpp b/WebCore/loader/CachedCSSStyleSheet.cpp
index 08f3712..7866efd 100644
--- a/WebCore/loader/CachedCSSStyleSheet.cpp
+++ b/WebCore/loader/CachedCSSStyleSheet.cpp
@@ -52,10 +52,8 @@ CachedCSSStyleSheet::~CachedCSSStyleSheet()
void CachedCSSStyleSheet::didAddClient(CachedResourceClient *c)
{
- if (!isLoading()) {
+ if (!isLoading())
c->setCSSStyleSheet(m_url, m_response.url(), m_decoder->encoding().name(), this);
- c->notifyFinished(this);
- }
}
void CachedCSSStyleSheet::allClientsRemoved()
@@ -106,10 +104,6 @@ void CachedCSSStyleSheet::data(PassRefPtr<SharedBuffer> data, bool allDataReceiv
checkNotify();
// Clear the decoded text as it is unlikely to be needed immediately again and is cheap to regenerate.
m_decodedSheetText = String();
-
- CachedResourceClientWalker w(m_clients);
- while (CachedResourceClient* c = w.next())
- c->notifyFinished(this);
}
void CachedCSSStyleSheet::checkNotify()
diff --git a/WebCore/loader/CachedLinkPrefetch.h b/WebCore/loader/CachedLinkPrefetch.h
deleted file mode 100644
index 1afed76..0000000
--- a/WebCore/loader/CachedLinkPrefetch.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*/
-
-#ifndef CachedLinkPrefetch_h
-#define CachedLinkPrefetch_h
-
-#include "CachedResource.h"
-#include "CachedResourceClient.h"
-#include "CachedResourceClientWalker.h"
-#include "PassRefPtr.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-class DocLoader;
-
-class CachedLinkPrefetch : public CachedResource {
-public:
- CachedLinkPrefetch(const String& URL) : CachedResource(URL, LinkPrefetch) { };
- virtual ~CachedLinkPrefetch() { };
-
- virtual void didAddClient(CachedResourceClient* c) {
- if (!isLoading())
- c->notifyFinished(this);
- };
-
- virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived) {
- if (!allDataReceived)
- return;
-
- m_data = data;
-
- CachedResourceClientWalker w(m_clients);
- while (CachedResourceClient* c = w.next())
- c->notifyFinished(this);
- };
- virtual void error() { };
-
- virtual bool schedule() const { return true; }
-
- virtual bool isPrefetch() const { return true; }
-};
-}
-
-#endif
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp
index 67b5c9e..75037ba 100644
--- a/WebCore/loader/CachedResource.cpp
+++ b/WebCore/loader/CachedResource.cpp
@@ -26,6 +26,8 @@
#include "Cache.h"
#include "CachedMetadata.h"
+#include "CachedResourceClient.h"
+#include "CachedResourceClientWalker.h"
#include "CachedResourceHandle.h"
#include "DocLoader.h"
#include "Frame.h"
@@ -108,6 +110,16 @@ void CachedResource::load(DocLoader* docLoader, bool incremental, SecurityCheckP
m_loading = true;
}
+void CachedResource::data(PassRefPtr<SharedBuffer>, bool allDataReceived)
+{
+ if (!allDataReceived)
+ return;
+
+ CachedResourceClientWalker w(m_clients);
+ while (CachedResourceClient* c = w.next())
+ c->notifyFinished(this);
+}
+
void CachedResource::finish()
{
m_status = Cached;
@@ -204,6 +216,12 @@ void CachedResource::addClient(CachedResourceClient* client)
didAddClient(client);
}
+void CachedResource::didAddClient(CachedResourceClient* c)
+{
+ if (!isLoading())
+ c->notifyFinished(this);
+}
+
void CachedResource::addClientToSet(CachedResourceClient* client)
{
ASSERT(!isPurgeable());
diff --git a/WebCore/loader/CachedResource.h b/WebCore/loader/CachedResource.h
index 7e99da4..d5bb97e 100644
--- a/WebCore/loader/CachedResource.h
+++ b/WebCore/loader/CachedResource.h
@@ -85,8 +85,8 @@ public:
virtual void setEncoding(const String&) { }
virtual String encoding() const { return String(); }
- virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived) = 0;
- virtual void error() = 0;
+ virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
+ virtual void error() { }
virtual void httpStatusCodeError() { error(); } // Images keep loading in spite of HTTP errors (for legacy compat with <img>, etc.).
const String &url() const { return m_url; }
@@ -106,7 +106,7 @@ public:
PreloadResult preloadResult() const { return static_cast<PreloadResult>(m_preloadResult); }
void setRequestedFromNetworkingLayer() { m_requestedFromNetworkingLayer = true; }
- virtual void didAddClient(CachedResourceClient*) = 0;
+ virtual void didAddClient(CachedResourceClient*);
virtual void allClientsRemoved() { }
unsigned count() const { return m_clients.size(); }
@@ -125,7 +125,11 @@ public:
void setLoading(bool b) { m_loading = b; }
virtual bool isImage() const { return false; }
+#if ENABLE(LINK_PREFETCH)
+ virtual bool isPrefetch() const { return type() != LinkPrefetch; }
+#else
virtual bool isPrefetch() const { return false; }
+#endif
unsigned accessCount() const { return m_accessCount; }
void increaseAccessCount() { m_accessCount++; }
@@ -166,7 +170,7 @@ public:
bool isExpired() const;
- virtual bool schedule() const { return false; }
+ virtual bool schedule() const { return isPrefetch(); }
// List of acceptable MIME types separated by ",".
// A MIME type may contain a wildcard, e.g. "text/*".
diff --git a/WebCore/loader/CachedScript.cpp b/WebCore/loader/CachedScript.cpp
index c96427c..e3d618a 100644
--- a/WebCore/loader/CachedScript.cpp
+++ b/WebCore/loader/CachedScript.cpp
@@ -51,12 +51,6 @@ CachedScript::~CachedScript()
{
}
-void CachedScript::didAddClient(CachedResourceClient* c)
-{
- if (!isLoading())
- c->notifyFinished(this);
-}
-
void CachedScript::allClientsRemoved()
{
m_decodedDataDeletionTimer.startOneShot(0);
diff --git a/WebCore/loader/CachedScript.h b/WebCore/loader/CachedScript.h
index 2374409..dff49c3 100644
--- a/WebCore/loader/CachedScript.h
+++ b/WebCore/loader/CachedScript.h
@@ -41,7 +41,6 @@ namespace WebCore {
const String& script();
- virtual void didAddClient(CachedResourceClient*);
virtual void allClientsRemoved();
virtual void setEncoding(const String&);
diff --git a/WebCore/loader/DocLoader.cpp b/WebCore/loader/DocLoader.cpp
index c0ba2f3..f6588c7 100644
--- a/WebCore/loader/DocLoader.cpp
+++ b/WebCore/loader/DocLoader.cpp
@@ -45,10 +45,6 @@
#include "Settings.h"
#include <wtf/text/CString.h>
-#if ENABLE(LINK_PREFETCH)
-#include "CachedLinkPrefetch.h"
-#endif
-
#define PRELOAD_DEBUG 0
namespace WebCore {
@@ -181,9 +177,9 @@ CachedXBLDocument* DocLoader::requestXBLDocument(const String& url)
#endif
#if ENABLE(LINK_PREFETCH)
-CachedLinkPrefetch* DocLoader::requestLinkPrefetch(const String& url)
+CachedResource* DocLoader::requestLinkPrefetch(const String& url)
{
- return static_cast<CachedLinkPrefetch*>(requestResource(CachedResource::LinkPrefetch, url, String()));
+ return requestResource(CachedResource::LinkPrefetch, url, String());
}
#endif
@@ -242,9 +238,6 @@ bool DocLoader::canRequest(CachedResource::Type type, const KURL& url)
break;
case CachedResource::ImageResource:
case CachedResource::CSSStyleSheet:
-#if ENABLE(LINK_PREFETCH)
- case CachedResource::LinkPrefetch:
-#endif
case CachedResource::FontResource: {
// These resources can corrupt only the frame's pixels.
if (Frame* f = frame()) {
@@ -253,6 +246,11 @@ bool DocLoader::canRequest(CachedResource::Type type, const KURL& url)
}
break;
}
+#if ENABLE(LINK_PREFETCH)
+ case CachedResource::LinkPrefetch:
+ // Prefetch cannot affect the current document.
+ break;
+#endif
default:
ASSERT_NOT_REACHED();
break;
diff --git a/WebCore/loader/DocLoader.h b/WebCore/loader/DocLoader.h
index ec3e619..2b43bb3 100644
--- a/WebCore/loader/DocLoader.h
+++ b/WebCore/loader/DocLoader.h
@@ -45,9 +45,6 @@ class Document;
class Frame;
class ImageLoader;
class KURL;
-#if ENABLE(LINK_PREFETCH)
-class CachedLinkPrefetch;
-#endif
// The DocLoader manages the loading of scripts/images/stylesheets for a single document.
class DocLoader : public Noncopyable {
@@ -71,7 +68,7 @@ public:
CachedXBLDocument* requestXBLDocument(const String &url);
#endif
#if ENABLE(LINK_PREFETCH)
- CachedLinkPrefetch* requestLinkPrefetch(const String &url);
+ CachedResource* requestLinkPrefetch(const String &url);
#endif
// Logs an access denied message to the console for the specified URL.
diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp
index 897130b..e137a5f 100644
--- a/WebCore/loader/loader.cpp
+++ b/WebCore/loader/loader.cpp
@@ -91,7 +91,7 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource
return ResourceRequest::TargetIsImage;
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
- return ResourceRequest::TargetIsSubresource;
+ return ResourceRequest::TargetIsPrefetch;
#endif
}
ASSERT_NOT_REACHED();
@@ -370,12 +370,6 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser
}
}
-#if ENABLE(LINK_PREFETCH)
- if (request->cachedResource()->type() == CachedResource::LinkPrefetch) {
- resourceRequest.setHTTPHeaderField("X-Moz", "prefetch");
- }
-#endif
-
RefPtr<SubresourceLoader> loader = SubresourceLoader::create(docLoader->doc()->frame(),
this, resourceRequest, request->shouldDoSecurityCheck(), request->sendResourceLoadCallbacks());
if (loader) {
diff --git a/WebCore/platform/network/ResourceRequestBase.h b/WebCore/platform/network/ResourceRequestBase.h
index 0b634cb..2cec4ec 100644
--- a/WebCore/platform/network/ResourceRequestBase.h
+++ b/WebCore/platform/network/ResourceRequestBase.h
@@ -63,7 +63,8 @@ namespace WebCore {
TargetIsObject,
TargetIsMedia,
TargetIsWorker,
- TargetIsSharedWorker
+ TargetIsSharedWorker,
+ TargetIsPrefetch,
};
static PassOwnPtr<ResourceRequest> adopt(PassOwnPtr<CrossThreadResourceRequestData>);