WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
fix WebURLRequest::TargetType
bug-85005-20120426204029.patch (text/plain), 77.26 KB, created by
Gavin Peters
on 2012-04-26 17:40:30 PDT
(
hide
)
Description:
fix WebURLRequest::TargetType
Filename:
MIME Type:
Creator:
Gavin Peters
Created:
2012-04-26 17:40:30 PDT
Size:
77.26 KB
patch
obsolete
>Subversion Revision: 115181 >diff --git a/Source/Platform/ChangeLog b/Source/Platform/ChangeLog >index 7e938fb03deddea9391891159381e54b584572f8..1b31ace2ab6813284d07e4b5e054f066ee42593f 100644 >--- a/Source/Platform/ChangeLog >+++ b/Source/Platform/ChangeLog >@@ -1,3 +1,37 @@ >+2012-04-26 Gavin Peters <gavinp@chromium.org> >+ >+ Add Prerenderer, PrerenderHandle and a chromium interface for Prerendering. >+ https://bugs.webkit.org/show_bug.cgi?id=85005 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The prerender case isn't quite a resource load, and using resource loading to >+ retrieve them has constrained the API, and unnecessarily complicated the loader. >+ >+ The new Prerenderer and PrerenderHandle let <link rel=prerender...> elements signal >+ removal and unload to their platform. >+ >+ No new tests, as this interface requires a full platform for testing, and isn't part >+ of layout. >+ >+ * Platform.gypi: >+ * chromium/public/Platform.h: >+ (WebKit): >+ (Platform): >+ (WebKit::Platform::createPrerenderingPlatform): >+ * chromium/public/WebPrerender.h: >+ (WebKit): >+ (WebPrerender): >+ * chromium/public/WebPrerenderingPlatform.h: >+ (WebKit): >+ (WebKit::WebPrerenderingPlatform::~WebPrerenderingPlatform): >+ (WebPrerenderingPlatform): >+ * chromium/public/WebURLRequest.h: >+ * chromium/src/WebPrerenderingPlatform.cpp: Copied from Source/WebCore/html/LinkRelAttribute.h. >+ (WebKit): >+ (WebKit::WebPrerenderingPlatform::setPlatform): >+ (WebKit::WebPrerenderingPlatform::getPlatform): >+ > 2012-04-25 Gavin Peters <gavinp@chromium.org> > > [Chromium] Add thunk headers for staging Prerendering API. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b57025d7c84c31731452fadbd0ee1d33e095d06a..0ce0bb1e6c74f05e787bdd0ee7fe6568f67a1edc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,122 @@ >+2012-04-26 Gavin Peters <gavinp@chromium.org> >+ >+ Add Prerenderer, PrerenderHandle and a chromium interface for Prerendering. >+ https://bugs.webkit.org/show_bug.cgi?id=85005 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The prerender case isn't quite a resource load, and using resource loading to >+ retrieve them has constrained the API, and unnecessarily complicated the loader. >+ >+ The new Prerenderer and PrerenderHandle let <link rel=prerender...> elements signal >+ removal and unload to their platform. >+ >+ No new tests, as this interface requires a full platform to work, and doesn't affect layout. Test >+ it with your platform when implemented for it. >+ >+ * WebCore.gypi: >+ * dom/Document.cpp: >+ (WebCore::Document::Document): >+ * dom/Document.h: >+ (WebCore): >+ (Document): >+ (WebCore::Document::prerenderer): >+ * html/HTMLLinkElement.cpp: >+ (WebCore::HTMLLinkElement::removedFrom): >+ * html/LinkRelAttribute.cpp: >+ (WebCore::LinkRelAttribute::LinkRelAttribute): >+ * html/LinkRelAttribute.h: >+ (LinkRelAttribute): >+ * loader/LinkLoader.cpp: >+ (WebCore::LinkLoader::loadLink): >+ (WebCore::LinkLoader::released): >+ * loader/LinkLoader.h: >+ (WebCore): >+ (LinkLoader): >+ * loader/Prerenderer.cpp: Added. >+ (WebCore): >+ (WebCore::Prerenderer::create): >+ (WebCore::Prerenderer::Prerenderer): >+ (WebCore::Prerenderer::~Prerenderer): >+ (WebCore::Prerenderer::render): >+ (WebCore::Prerenderer::stop): >+ (WebCore::Prerenderer::suspend): >+ (WebCore::Prerenderer::resume): >+ (WebCore::Prerenderer::document): >+ (WebCore::Prerenderer::client): >+ * loader/Prerenderer.h: Copied from Source/Platform/chromium/public/WebPrerender.h. >+ (WebCore): >+ (Prerenderer): >+ * loader/PrerendererClient.cpp: Copied from Source/WebCore/html/LinkRelAttribute.h. >+ (WebCore): >+ (WebCore::PrerendererClient::supplementName): >+ (WebCore::PrerendererClient::from): >+ (WebCore::providePrerendererClientTo): >+ * loader/PrerendererClient.h: Copied from Source/WebCore/html/LinkRelAttribute.h. >+ (WebCore): >+ (PrerendererClient): >+ (WebCore::PrerendererClient::~PrerendererClient): >+ (WebCore::PrerendererClient::PrerendererClient): >+ * loader/cache/CachedResource.cpp: >+ (WebCore::defaultPriorityForResourceType): >+ (WebCore::cachedResourceTypeToTargetType): >+ (WebCore::CachedResource::load): >+ * loader/cache/CachedResource.h: >+ (WebCore::CachedResource::ignoreForRequestCount): >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::createResource): >+ (WebCore::CachedResourceLoader::requestLinkResource): >+ (WebCore::CachedResourceLoader::checkInsecureContent): >+ (WebCore::CachedResourceLoader::canRequest): >+ * platform/PrerenderHandle.h: Copied from Source/Platform/chromium/public/WebPrerender.h. >+ (WebCore): >+ (PrerenderHandle): >+ * platform/chromium/Prerender.cpp: Added. >+ (WebCore): >+ (WebCore::Prerender::Prerender): >+ (WebCore::Prerender::~Prerender): >+ (WebCore::Prerender::setState): >+ (WebCore::Prerender::add): >+ (WebCore::Prerender::cancel): >+ (WebCore::Prerender::abandon): >+ (WebCore::Prerender::suspend): >+ (WebCore::Prerender::resume): >+ * platform/chromium/Prerender.h: Copied from Source/Platform/chromium/public/WebPrerender.h. >+ (WebKit): >+ (WebCore): >+ (Prerender): >+ (ExtraData): >+ (WebCore::Prerender::ExtraData::~ExtraData): >+ (WebCore::Prerender::url): >+ (WebCore::Prerender::referrer): >+ (WebCore::Prerender::referrerPolicy): >+ (WebCore::Prerender::setExtraData): >+ (WebCore::Prerender::extraData): >+ * platform/chromium/PrerenderHandle.cpp: Copied from Source/Platform/chromium/public/WebPrerender.h. >+ (WebCore): >+ (WebCore::PrerenderHandle::create): >+ (WebCore::PrerenderHandle::PrerenderHandle): >+ (WebCore::PrerenderHandle::~PrerenderHandle): >+ (WebCore::PrerenderHandle::prerender): >+ (WebCore::PrerenderHandle::add): >+ (WebCore::PrerenderHandle::cancel): >+ (WebCore::PrerenderHandle::abandon): >+ (WebCore::PrerenderHandle::suspend): >+ (WebCore::PrerenderHandle::resume): >+ (WebCore::PrerenderHandle::url): >+ (WebCore::PrerenderHandle::referrer): >+ (WebCore::PrerenderHandle::referrerPolicy): >+ * platform/chromium/support/WebPrerender.cpp: Copied from Source/Platform/chromium/public/WebPrerender.h. >+ (WebKit::WebPrerender::WebPrerender): >+ (WebKit): >+ (WebKit::WebPrerender::~WebPrerender): >+ (WebKit::WebPrerender::url): >+ (WebKit::WebPrerender::referrer): >+ (WebKit::WebPrerender::referrerPolicy): >+ (WebKit::WebPrerender::setExtraData): >+ (WebKit::WebPrerender::extraData): >+ * platform/network/chromium/ResourceRequest.h: >+ > 2012-04-25 Gavin Peters <gavinp@chromium.org> > > Add new ENABLE_LINK_PRERENDER define to control the Prerendering API >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 2c8517c6976cc69ce88e8a74c8870ff154a0bca9..e91ce3775019484f7dba005c64ca91d40b63de0a 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,33 @@ >+2012-04-26 Gavin Peters <gavinp@chromium.org> >+ >+ Add Prerenderer, PrerenderHandle and a chromium interface for Prerendering. >+ https://bugs.webkit.org/show_bug.cgi?id=85005 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The prerender case isn't quite a resource load, and using resource loading to >+ retrieve them has constrained the API, and unnecessarily complicated the loader. >+ >+ The new Prerenderer and PrerenderHandle let <link rel=prerender...> elements signal >+ removal and unload to their platform. >+ >+ * WebKit.gyp: >+ * public/WebView.h: >+ * src/PrerendererClientImpl.cpp: Copied from Source/WebCore/html/LinkRelAttribute.h. >+ (WebKit): >+ (WebKit::PrerendererClientImpl::PrerendererClientImpl): >+ (WebKit::PrerendererClientImpl::willAddPrerender): >+ * src/PrerendererClientImpl.h: Copied from Source/WebCore/html/LinkRelAttribute.h. >+ (WebCore): >+ (WebKit): >+ (PrerendererClientImpl): >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::setPrerendererClient): >+ (WebKit): >+ * src/WebViewImpl.h: >+ (WebKit): >+ (WebViewImpl): >+ > 2012-04-25 Gavin Peters <gavinp@chromium.org> > > [Chromium] Add thunk headers for staging Prerendering API. >diff --git a/Source/Platform/Platform.gypi b/Source/Platform/Platform.gypi >index 62d6d6e0e5299b056b2ccb634e67a5ff8784adb2..e47fb2cf49d56107ffcf5fd2f0c629264fb26d60 100644 >--- a/Source/Platform/Platform.gypi >+++ b/Source/Platform/Platform.gypi >@@ -87,6 +87,7 @@ > 'chromium/public/WebString.h', > 'chromium/public/WebThread.h', > 'chromium/public/WebThreadSafeData.h', >+ 'chromium/public/WebPrerender.h', > 'chromium/public/WebURL.h', > 'chromium/public/WebURLError.h', > 'chromium/public/WebURLLoadTiming.h', >@@ -100,6 +101,7 @@ > 'chromium/src/Platform.cpp', > 'chromium/src/WebCString.cpp', > 'chromium/src/WebFloatQuad.cpp', >+ 'chromium/src/WebPrerenderingPlatform.cpp', > 'chromium/src/WebString.cpp', > 'chromium/src/WebVideoFrame.cpp', > ] >diff --git a/Source/Platform/chromium/public/Platform.h b/Source/Platform/chromium/public/Platform.h >index abf3d0901ed9ee05752a065c3ca93098c53b44e6..b15a15a13a7ba4ca63f6a04e395a2c4c1e23ebeb 100644 >--- a/Source/Platform/chromium/public/Platform.h >+++ b/Source/Platform/chromium/public/Platform.h >@@ -49,6 +49,7 @@ class WebPeerConnectionHandler; > class WebPeerConnectionHandlerClient; > class WebURL; > class WebURLLoader; >+class WebPrerenderingPlatform; > class WebSocketStreamHandle; > class WebThread; > >@@ -283,6 +284,8 @@ public: > // Enumeration histogram buckets are linear, boundaryValue should be larger than any possible sample value. > virtual void histogramEnumeration(const char* name, int sample, int boundaryValue) { } > >+ // Prerender >+ virtual WebPrerenderingPlatform* createPrerenderingPlatform() { return 0; } > > // WebRTC ---------------------------------------------------------- > >diff --git a/Source/Platform/chromium/public/WebPrerender.h b/Source/Platform/chromium/public/WebPrerender.h >index 08a715dd9870e657193fd50ade53f4056400bcab..c99a1453bdd948a5b0c08441fac02397f99f887f 100644 >--- a/Source/Platform/chromium/public/WebPrerender.h >+++ b/Source/Platform/chromium/public/WebPrerender.h >@@ -49,27 +49,29 @@ namespace WebKit { > > struct WebSize; > >-// This thunk implementation of WebPrerender exists only for staging; this will allow >-// the Chromium side of the Prerendering API to land, and then later we can atomicly >-// switch WebKit to prerender, and finally remove the old phantom-request prerender >-// implementation from Chromium. >-// FIXME: Put the actual implementation here after the Chromium side of this API >-// lands. > class WebPrerender { > public: > class ExtraData { > public: > virtual ~ExtraData() { } > }; >- WebURL url() const { return WebURL(); } >- WebString referrer() const { return ""; } >- WebReferrerPolicy referrerPolicy() const { return WebReferrerPolicy(); } >- void setExtraData(ExtraData*) { } >- const ExtraData* extraData() const { return 0; } >+ >+#if WEBKIT_IMPLEMENTATION >+ explicit WebPrerender(PassRefPtr<WebCore::Prerender>); >+ ~WebPrerender(); >+#endif >+ >+ WEBKIT_EXPORT WebURL url() const; >+ WEBKIT_EXPORT WebString referrer() const; >+ WEBKIT_EXPORT WebReferrerPolicy referrerPolicy() const; >+ >+ WEBKIT_EXPORT void setExtraData(ExtraData*); >+ WEBKIT_EXPORT const ExtraData* extraData() const; > > private: >- WebPrerender() { } >- ~WebPrerender() { } >+ WebPrerender(); >+ >+ WebPrivatePtr<WebCore::Prerender> m_private; > }; > > } // namespace WebKit >diff --git a/Source/Platform/chromium/public/WebPrerenderingPlatform.h b/Source/Platform/chromium/public/WebPrerenderingPlatform.h >index 17ffae832d12692e84494ff11400db4c2a68e6ea..200e86ce42326562c3804ea2fbc1fc9c67f9e4a8 100644 >--- a/Source/Platform/chromium/public/WebPrerenderingPlatform.h >+++ b/Source/Platform/chromium/public/WebPrerenderingPlatform.h >@@ -37,25 +37,31 @@ namespace WebKit { > > class WebPrerender; > >-// This thunk implementation of WebPrerenderingPlatform exists only for staging; this will >-// allow the Chromium side of the Prerendering API to land, and then later we can atomicly >-// switch WebKit to prerender, and finally remove the old phantom-request prerender >-// implementation from Chromium. >-// FIXME: Put the actual implementation here after the Chromium side of this API >-// lands. > class WebPrerenderingPlatform { > public: >- virtual void add(const WebPrerender&) { } >- virtual void cancel(const WebPrerender&) { } >- virtual void abandon(const WebPrerender&) { } >- static void setPlatform(WebPrerenderingPlatform*) { } >- static WebPrerenderingPlatform* getPlatform() { return 0; } >+ virtual ~WebPrerenderingPlatform() { } >+ >+ // A prerender link element is added when it is inserted into a document. >+ virtual void add(const WebPrerender&) = 0; >+ >+ // A prerender is abandoned when it's navigated away from or suspended in the page cache. This >+ // is a weaker signal than cancel(), since the launcher hasn't indicated that the prerender isn't >+ // wanted, and we may end up using it after, for instance, a short redirect chain. >+ virtual void cancel(const WebPrerender&) = 0; >+ >+ // A prerender is canceled when it is removed from a document. >+ virtual void abandon(const WebPrerender&) = 0; >+ >+ WEBKIT_EXPORT static void setPlatform(WebPrerenderingPlatform*); >+ WEBKIT_EXPORT static WebPrerenderingPlatform* getPlatform(); > > protected: > WebPrerenderingPlatform() { } >- virtual ~WebPrerenderingPlatform() { } >+ >+private: >+ static WebPrerenderingPlatform* s_platform; > }; > > } // namespace WebKit > >-#endif // WebPrerenderLoader_h >+#endif // WebPrerenderingPlatform_h >diff --git a/Source/Platform/chromium/public/WebURLRequest.h b/Source/Platform/chromium/public/WebURLRequest.h >index adf2f2e230ba55f778792594398ea8f52292c76b..5802da70f37321a8f6ae66e21ff39cf69ca9894c 100644 >--- a/Source/Platform/chromium/public/WebURLRequest.h >+++ b/Source/Platform/chromium/public/WebURLRequest.h >@@ -69,11 +69,13 @@ public: > TargetIsWorker = 9, > TargetIsSharedWorker = 10, > TargetIsPrefetch = 11, >- TargetIsPrerender = 12, >- TargetIsFavicon = 13, >- TargetIsXHR = 14, >- TargetIsTextTrack = 15, >- TargetIsUnspecified = 16, >+ TargetIsFavicon = 12, >+ TargetIsXHR = 13, >+ TargetIsTextTrack = 14, >+ TargetIsUnspecified = 15, >+ // FIXME: This old enum value is only being left in while prerendering is staging into chromium. After http://codereview.chromium.org/10244007/ >+ // lands, this should be removed. >+ TargetIsPrerender = TargetIsUnspecified, > }; > > class ExtraData { >diff --git a/Source/Platform/chromium/src/WebPrerenderingPlatform.cpp b/Source/Platform/chromium/src/WebPrerenderingPlatform.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..1919deba15b08f237c411b53f5ef9b29a1b61677 >--- /dev/null >+++ b/Source/Platform/chromium/src/WebPrerenderingPlatform.cpp >@@ -0,0 +1,47 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ */ >+ >+#include <public/WebPrerenderingPlatform.h> >+ >+namespace WebKit { >+ >+WebPrerenderingPlatform* WebPrerenderingPlatform::s_platform = 0; >+ >+void WebPrerenderingPlatform::setPlatform(WebPrerenderingPlatform* platform) >+{ >+ s_platform = platform; >+} >+ >+WebPrerenderingPlatform* WebPrerenderingPlatform::getPlatform() >+{ >+ return s_platform; >+} >+ >+} >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 5b288f887d4dde4640a01270890046bb886a75e2..030355403aa524b35a2f7adbca4991a1e9ecf519 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -2854,6 +2854,10 @@ > 'loader/PlaceholderDocument.h', > 'loader/PolicyCallback.cpp', > 'loader/PolicyChecker.cpp', >+ 'loader/Prerenderer.cpp', >+ 'loader/Prerenderer.h', >+ 'loader/PrerendererClient.cpp', >+ 'loader/PrerendererClient.h', > 'loader/ProgressTracker.cpp', > 'loader/ResourceLoadNotifier.cpp', > 'loader/ResourceLoadScheduler.cpp', >@@ -3133,6 +3137,7 @@ > 'platform/PlatformStrategies.cpp', > 'platform/PlatformTouchEvent.h', > 'platform/PlatformTouchPoint.h', >+ 'platform/PrerenderHandle.h', > 'platform/PurgeableBuffer.h', > 'platform/ReferrerPolicy.h', > 'platform/RunLoopTimer.h', >@@ -3311,6 +3316,9 @@ > 'platform/chromium/PopupListBox.cpp', > 'platform/chromium/PopupListBox.h', > 'platform/chromium/PopupMenuPrivate.h', >+ 'platform/chromium/Prerender.cpp', >+ 'platform/chromium/Prerender.h', >+ 'platform/chromium/PrerenderHandle.cpp', > 'platform/chromium/SSLKeyGeneratorChromium.cpp', > 'platform/chromium/ScrollbarThemeChromium.cpp', > 'platform/chromium/ScrollbarThemeChromium.h', >@@ -8244,6 +8252,7 @@ > 'platform/chromium/support/WebMediaStreamDescriptor.cpp', > 'platform/chromium/support/WebMediaStreamSource.cpp', > 'platform/chromium/support/WebMediaStreamSourcesRequest.cpp', >+ 'platform/chromium/support/WebPrerender.cpp', > 'platform/chromium/support/WebThreadSafeData.cpp', > 'platform/chromium/support/WebURL.cpp', > 'platform/chromium/support/WebURLError.cpp', >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index e1eb74b525eae0c1a8671784d8c19564829a85e0..1dbf6fb5c7a626ea5d6cd7bac6a64cc194ed7cca 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -206,6 +206,10 @@ > #include "NodeRareData.h" > #endif > >+#if ENABLE(LINK_PRERENDER) >+#include "Prerenderer.h" >+#endif >+ > using namespace std; > using namespace WTF; > using namespace Unicode; >@@ -506,7 +510,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) > m_markers = adoptPtr(new DocumentMarkerController); > > m_cachedResourceLoader = adoptPtr(new CachedResourceLoader(this)); >- >+#if ENABLE(LINK_PRERENDER) >+ m_prerenderer = Prerenderer::create(this); >+#endif > m_visuallyOrdered = false; > m_bParsing = false; > m_wellFormed = false; >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 35d4febbe8cd6bddd1bb1da5e5a3d1684e3070be..8e730d9fee7ef19e9dc8597bc1a09317f54002e7 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -166,6 +166,10 @@ class ScriptedAnimationController; > class MicroDataItemList; > #endif > >+#if ENABLE(LINK_PRERENDER) >+class Prerenderer; >+#endif >+ > typedef int ExceptionCode; > > class FormElementKey { >@@ -1146,6 +1150,10 @@ public: > > IntSize viewportSize() const; > >+#if ENABLE(LINK_PRERENDER) >+ Prerenderer* prerenderer() { return m_prerenderer.get(); } >+#endif >+ > protected: > Document(Frame*, const KURL&, bool isXHTML, bool isHTML); > >@@ -1487,6 +1495,11 @@ private: > > Timer<Document> m_pendingTasksTimer; > Vector<OwnPtr<Task> > m_pendingTasks; >+ >+#if ENABLE(LINK_PRERENDER) >+ OwnPtr<Prerenderer> m_prerenderer; >+#endif >+ > bool m_scheduledTasksAreSuspended; > > bool m_visualUpdatesAllowed; >diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp >index 069b93e2fec369bf44316a6370915434faddadc4..9819fc8db454984600c22295406359ed1eb3e26a 100644 >--- a/Source/WebCore/html/HTMLLinkElement.cpp >+++ b/Source/WebCore/html/HTMLLinkElement.cpp >@@ -265,6 +265,8 @@ void HTMLLinkElement::removedFrom(Node* insertionPoint) > if (!insertionPoint->inDocument()) > return; > >+ m_linkLoader.released(); >+ > if (m_isInShadowTree) { > ASSERT(!m_sheet); > return; >diff --git a/Source/WebCore/html/LinkRelAttribute.cpp b/Source/WebCore/html/LinkRelAttribute.cpp >index 5261df2d08ff26a03a5d81e2431fa63f4c65720c..87071b99b28d65d218f0abd2db8a57cd001f6a62 100644 >--- a/Source/WebCore/html/LinkRelAttribute.cpp >+++ b/Source/WebCore/html/LinkRelAttribute.cpp >@@ -41,9 +41,11 @@ LinkRelAttribute::LinkRelAttribute() > , m_isDNSPrefetch(false) > #if ENABLE(LINK_PREFETCH) > , m_isLinkPrefetch(false) >- , m_isLinkPrerender(false) > , m_isLinkSubresource(false) > #endif >+#if ENABLE(LINK_PRERENDER) >+ , m_isLinkPrerender(false) >+#endif > { > } > >@@ -54,9 +56,11 @@ LinkRelAttribute::LinkRelAttribute(const String& rel) > , m_isDNSPrefetch(false) > #if ENABLE(LINK_PREFETCH) > , m_isLinkPrefetch(false) >- , m_isLinkPrerender(false) > , m_isLinkSubresource(false) > #endif >+#if ENABLE(LINK_PRERENDER) >+ , m_isLinkPrerender(false) >+#endif > { > if (equalIgnoringCase(rel, "stylesheet")) > m_isStyleSheet = true; >@@ -96,11 +100,13 @@ LinkRelAttribute::LinkRelAttribute(const String& rel) > #if ENABLE(LINK_PREFETCH) > else if (equalIgnoringCase(*it, "prefetch")) > m_isLinkPrefetch = true; >- else if (equalIgnoringCase(*it, "prerender")) >- m_isLinkPrerender = true; > else if (equalIgnoringCase(*it, "subresource")) > m_isLinkSubresource = true; > #endif >+#if ENABLE(LINK_PRERENDER) >+ else if (equalIgnoringCase(*it, "prerender")) >+ m_isLinkPrerender = true; >+#endif > } > } > } >diff --git a/Source/WebCore/html/LinkRelAttribute.h b/Source/WebCore/html/LinkRelAttribute.h >index 3178194b49a1bd05b9b0c14441ebf5f862578acc..98dd48191c9f8373ef24b1d229b1223e2da27615 100644 >--- a/Source/WebCore/html/LinkRelAttribute.h >+++ b/Source/WebCore/html/LinkRelAttribute.h >@@ -44,9 +44,11 @@ public: > bool m_isDNSPrefetch; > #if ENABLE(LINK_PREFETCH) > bool m_isLinkPrefetch; >- bool m_isLinkPrerender; > bool m_isLinkSubresource; > #endif >+#if ENABLE(LINK_PRERENDER) >+ bool m_isLinkPrerender; >+#endif > > LinkRelAttribute(); > explicit LinkRelAttribute(const String&); >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index 7d6997886b9670c78881ec548ccf70d56a77a101..d96606f925fd45a7412dc5b6c0187dbe84638be3 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -44,6 +44,11 @@ > #include "LinkRelAttribute.h" > #include "Settings.h" > >+#if ENABLE(LINK_PRERENDER) >+#include "PrerenderHandle.h" >+#include "Prerenderer.h" >+#endif >+ > namespace WebCore { > > LinkLoader::LinkLoader(LinkLoaderClient* client) >@@ -103,7 +108,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty > } > > #if ENABLE(LINK_PREFETCH) >- if ((relAttribute.m_isLinkPrefetch || relAttribute.m_isLinkPrerender || relAttribute.m_isLinkSubresource) && href.isValid() && document->frame()) { >+ if ((relAttribute.m_isLinkPrefetch || relAttribute.m_isLinkSubresource) && href.isValid() && document->frame()) { > if (!m_client->shouldLoadLink()) > return false; > ResourceLoadPriority priority = ResourceLoadPriorityUnresolved; >@@ -113,9 +118,7 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty > if (relAttribute.m_isLinkSubresource) { > priority = ResourceLoadPriorityLow; > type = CachedResource::LinkSubresource; >- } else if (relAttribute.m_isLinkPrerender) >- type = CachedResource::LinkPrerender; >- >+ } > ResourceRequest linkRequest(document->completeURL(href)); > > if (m_cachedLinkResource) { >@@ -127,8 +130,26 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty > m_cachedLinkResource->addClient(this); > } > #endif >+ >+#if ENABLE(LINK_PRERENDER) >+ if (relAttribute.m_isLinkPrerender) { >+ ASSERT(!m_prerenderHandle); >+ m_prerenderHandle = document->prerenderer()->render(href); >+ } >+#endif > return true; > } > >+void LinkLoader::released() >+{ >+ // Only prerenders need treatment here; other links either use the CachedResource interface, or are notionally >+ // atomic (dns prefetch). >+#if ENABLE(LINK_PRERENDER) >+ if (m_prerenderHandle) { >+ m_prerenderHandle->cancel(); >+ m_prerenderHandle.clear(); >+ } >+#endif >+} > > } >diff --git a/Source/WebCore/loader/LinkLoader.h b/Source/WebCore/loader/LinkLoader.h >index 1fbc18d7c76eb6a6e7a4efd719111b63960e79db..58b29a774f78d1480f1846352acdd7d853c20fc6 100644 >--- a/Source/WebCore/loader/LinkLoader.h >+++ b/Source/WebCore/loader/LinkLoader.h >@@ -37,9 +37,14 @@ > #include "LinkLoaderClient.h" > #include "Timer.h" > >+#include <wtf/RefPtr.h> >+ > namespace WebCore { > > struct LinkRelAttribute; >+#if ENABLE(LINK_PRERENDER) >+class PrerenderHandle; >+#endif > > // The LinkLoader can load link rel types icon, dns-prefetch, subresource, prefetch and prerender. > class LinkLoader : public CachedResourceClient { >@@ -50,6 +55,7 @@ public: > // from CachedResourceClient > virtual void notifyFinished(CachedResource*); > >+ void released(); > bool loadLink(const LinkRelAttribute&, const String& type, const String& sizes, const KURL&, Document*); > > private: >@@ -61,6 +67,10 @@ private: > CachedResourceHandle<CachedResource> m_cachedLinkResource; > Timer<LinkLoader> m_linkLoadTimer; > Timer<LinkLoader> m_linkLoadingErrorTimer; >+ >+#if ENABLE(LINK_PRERENDER) >+ RefPtr<PrerenderHandle> m_prerenderHandle; >+#endif > }; > > } >diff --git a/Source/WebCore/loader/Prerenderer.cpp b/Source/WebCore/loader/Prerenderer.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..75fd8dd8b7d492bc706e826533835777f6f18bd7 >--- /dev/null >+++ b/Source/WebCore/loader/Prerenderer.cpp >@@ -0,0 +1,137 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ * >+ */ >+ >+#include "config.h" >+#include "Prerenderer.h" >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "Document.h" >+#include "Frame.h" >+#include "FrameLoader.h" >+#include "PrerenderHandle.h" >+#include "PrerendererClient.h" >+#include "ReferrerPolicy.h" >+#include "SecurityPolicy.h" >+ >+#include <wtf/PassOwnPtr.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+// static >+PassOwnPtr<Prerenderer> Prerenderer::create(Document* document) >+{ >+ Prerenderer* prerenderer = new Prerenderer(document); >+ prerenderer->suspendIfNeeded(); >+ return adoptPtr(prerenderer); >+} >+ >+Prerenderer::Prerenderer(Document* document) >+ : ActiveDOMObject(document, this) >+ , m_client(0) >+{ >+} >+ >+Prerenderer::~Prerenderer() >+{ >+} >+ >+PassRefPtr<PrerenderHandle> Prerenderer::render(const KURL& url) >+{ >+ // Prerenders are unlike requests in most ways (for instance, they pass down fragments, and they don't return data), >+ // but they do have referrers. >+ const ReferrerPolicy referrerPolicy = document()->referrerPolicy(); >+ const String referrer = SecurityPolicy::generateReferrerHeader(referrerPolicy, url, document()->frame()->loader()->outgoingReferrer()); >+ >+ RefPtr<PrerenderHandle> prerenderHandle = PrerenderHandle::create(url, referrer, referrerPolicy); >+ >+ client()->willAddPrerender(prerenderHandle.get()); >+ prerenderHandle->add(); >+ >+ m_activeHandles.append(prerenderHandle); >+ return prerenderHandle; >+} >+ >+void Prerenderer::stop() >+{ >+ while (!m_activeHandles.isEmpty()) { >+ RefPtr<PrerenderHandle> handle = m_activeHandles[0].release(); >+ m_activeHandles.remove(0); >+ handle->abandon(); >+ } >+ while (!m_suspendedHandles.isEmpty()) { >+ RefPtr<PrerenderHandle> handle = m_suspendedHandles[0].release(); >+ m_suspendedHandles.remove(0); >+ handle->abandon(); >+ } >+} >+ >+void Prerenderer::suspend(ReasonForSuspension reason) >+{ >+ if (reason == DocumentWillBecomeInactive || reason == PageWillBeSuspended) { >+ while (!m_activeHandles.isEmpty()) { >+ RefPtr<PrerenderHandle> handle = m_activeHandles[0].release(); >+ m_activeHandles.remove(0); >+ handle->suspend(); >+ m_suspendedHandles.append(handle); >+ } >+ } >+} >+ >+void Prerenderer::resume() >+{ >+ while (!m_suspendedHandles.isEmpty()) { >+ RefPtr<PrerenderHandle> handle = m_suspendedHandles[0].release(); >+ m_suspendedHandles.remove(0); >+ handle->resume(); >+ m_activeHandles.append(handle); >+ } >+} >+ >+Document* Prerenderer::document() >+{ >+ ASSERT(scriptExecutionContext()->isDocument()); >+ return static_cast<Document*>(scriptExecutionContext()); >+} >+ >+PrerendererClient* Prerenderer::client() >+{ >+ if (!m_client) >+ m_client = PrerendererClient::from(document()->page()); >+ return m_client; >+} >+ >+} >+ >+#endif // ENABLE(LINK_PRERENDER) >diff --git a/Source/WebCore/loader/Prerenderer.h b/Source/WebCore/loader/Prerenderer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..65481e69428fbf76a171dff9165d6c42b06a9b95 >--- /dev/null >+++ b/Source/WebCore/loader/Prerenderer.h >@@ -0,0 +1,85 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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 Prerenderer_h >+#define Prerenderer_h >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "ActiveDOMObject.h" >+#include "KURL.h" >+#include <wtf/OwnPtr.h> >+#include <wtf/PassOwnPtr.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefPtr.h> >+#include <wtf/SinglyLinkedList.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+class Document; >+class PrerenderHandle; >+class PrerendererClient; >+class Page; >+ >+class Prerenderer : public ActiveDOMObject { >+ WTF_MAKE_NONCOPYABLE(Prerenderer); >+public: >+ virtual ~Prerenderer(); >+ >+ PassRefPtr<PrerenderHandle> render(const KURL&); >+ >+ static PassOwnPtr<Prerenderer> create(Document*); >+ >+private: >+ typedef Vector<RefPtr<PrerenderHandle> > HandleVector; >+ typedef Vector<KURL> KURLVector; >+ >+ Prerenderer(Document*); >+ >+ virtual bool canSuspend() const OVERRIDE { return true; } >+ virtual void stop() OVERRIDE; >+ virtual void suspend(ReasonForSuspension) OVERRIDE; >+ virtual void resume() OVERRIDE; >+ >+ Document* document(); >+ PrerendererClient* client(); >+ >+ PrerendererClient* m_client; >+ HandleVector m_activeHandles; >+ HandleVector m_suspendedHandles; >+}; >+ >+} >+ >+#endif // ENABLE(LINK_PRERENDER) >+ >+#endif // Prerenderer_h >diff --git a/Source/WebCore/loader/PrerendererClient.cpp b/Source/WebCore/loader/PrerendererClient.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..78f2470e26164a4dd1593595c63f1271affe6c1f >--- /dev/null >+++ b/Source/WebCore/loader/PrerendererClient.cpp >@@ -0,0 +1,65 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ * >+ */ >+ >+#include "config.h" >+#include "PrerendererClient.h" >+ >+#include "Page.h" >+#include "Supplementable.h" >+#include <wtf/text/AtomicString.h> >+ >+#if ENABLE(LINK_PRERENDER) >+ >+namespace WebCore { >+ >+// static >+const AtomicString& PrerendererClient::supplementName() >+{ >+ DEFINE_STATIC_LOCAL(AtomicString, name, ("PrerendererClient")); >+ return name; >+} >+ >+// static >+PrerendererClient* PrerendererClient::from(Page* page) >+{ >+ PrerendererClient* supplement = static_cast<PrerendererClient*>(Supplement<Page>::from(page, supplementName())); >+ ASSERT(supplement); >+ return supplement; >+} >+ >+void providePrerendererClientTo(Page* page, PrerendererClient* client) >+{ >+ PrerendererClient::provideTo(page, PrerendererClient::supplementName(), adoptPtr(client)); >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/loader/PrerendererClient.h b/Source/WebCore/loader/PrerendererClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5a4ce946f638718067826c5d7e05aaf7f4cf15f5 >--- /dev/null >+++ b/Source/WebCore/loader/PrerendererClient.h >@@ -0,0 +1,65 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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 PrerendererClient_h >+#define PrerendererClient_h >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "Supplementable.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebCore { >+ >+class Document; >+class Page; >+class PrerenderHandle; >+ >+class PrerendererClient : public Supplement<Page> { >+public: >+ virtual ~PrerendererClient() { } >+ >+ virtual void willAddPrerender(PrerenderHandle*) = 0; >+ >+ static const AtomicString& supplementName(); >+ static PrerendererClient* from(Page*); >+ >+protected: >+ PrerendererClient() { } >+}; >+ >+void providePrerendererClientTo(Page*, PrerendererClient*); >+ >+} // namespace WebCore >+ >+#endif // ENABLED(LINK_PRERENDER) >+ >+#endif // PrerendererClient_h >diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp >index 0368a724525fafe6490587beb2b4f6e6e9fcc6e6..c95abedb4c908c597de435e2d5388db421443eab 100755 >--- a/Source/WebCore/loader/cache/CachedResource.cpp >+++ b/Source/WebCore/loader/cache/CachedResource.cpp >@@ -73,8 +73,6 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: > return ResourceLoadPriorityVeryLow; >- case CachedResource::LinkPrerender: >- return ResourceLoadPriorityVeryLow; > case CachedResource::LinkSubresource: > return ResourceLoadPriorityVeryLow; > #endif >@@ -114,8 +112,6 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: > return ResourceRequest::TargetIsPrefetch; >- case CachedResource::LinkPrerender: >- return ResourceRequest::TargetIsPrerender; > case CachedResource::LinkSubresource: > return ResourceRequest::TargetIsSubresource; > #endif >@@ -220,7 +216,7 @@ void CachedResource::load(CachedResourceLoader* cachedResourceLoader, const Reso > } > > #if ENABLE(LINK_PREFETCH) >- if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkPrerender || type() == CachedResource::LinkSubresource) >+ if (type() == CachedResource::LinkPrefetch || type() == CachedResource::LinkSubresource) > m_resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); > #endif > m_resourceRequest.setPriority(loadPriority()); >diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h >index c07b231d4d5985751ccca0621d3757a9566b4698..911f850e885ccff7f1d24cb68c56e40e5faf2f7e 100644 >--- a/Source/WebCore/loader/cache/CachedResource.h >+++ b/Source/WebCore/loader/cache/CachedResource.h >@@ -74,7 +74,6 @@ public: > #endif > #if ENABLE(LINK_PREFETCH) > , LinkPrefetch >- , LinkPrerender > , LinkSubresource > #endif > #if ENABLE(VIDEO_TRACK) >@@ -150,7 +149,6 @@ public: > return false > #if ENABLE(LINK_PREFETCH) > || type() == LinkPrefetch >- || type() == LinkPrerender > || type() == LinkSubresource > #endif > || type() == RawResource; >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >index 846f3a739f95d320098b29c30da384c7986d1a22..1a5a6fbd251fc4d645333bf08181394cf5dfd11b 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >@@ -88,8 +88,6 @@ static CachedResource* createResource(CachedResource::Type type, ResourceRequest > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: > return new CachedResource(request, CachedResource::LinkPrefetch); >- case CachedResource::LinkPrerender: >- return new CachedResource(request, CachedResource::LinkPrerender); > case CachedResource::LinkSubresource: > return new CachedResource(request, CachedResource::LinkSubresource); > #endif >@@ -240,7 +238,7 @@ CachedSVGDocument* CachedResourceLoader::requestSVGDocument(ResourceRequest& req > CachedResource* CachedResourceLoader::requestLinkResource(CachedResource::Type type, ResourceRequest& request, ResourceLoadPriority priority) > { > ASSERT(frame()); >- ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkPrerender || type == CachedResource::LinkSubresource); >+ ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkSubresource); > return requestResource(type, request, String(), defaultCachedResourceOptions(), priority); > } > #endif >@@ -286,7 +284,6 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const > case CachedResource::RawResource: > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: >- case CachedResource::LinkPrerender: > case CachedResource::LinkSubresource: > // Prefetch cannot affect the current document. > #endif >@@ -315,7 +312,6 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url > case CachedResource::RawResource: > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: >- case CachedResource::LinkPrerender: > case CachedResource::LinkSubresource: > #endif > #if ENABLE(VIDEO_TRACK) >@@ -385,7 +381,6 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url > case CachedResource::RawResource: > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: >- case CachedResource::LinkPrerender: > case CachedResource::LinkSubresource: > #endif > break; >diff --git a/Source/WebCore/platform/PrerenderHandle.h b/Source/WebCore/platform/PrerenderHandle.h >new file mode 100644 >index 0000000000000000000000000000000000000000..04fdafcf40f4eafe840b08bf960e71423df72a7a >--- /dev/null >+++ b/Source/WebCore/platform/PrerenderHandle.h >@@ -0,0 +1,86 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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 PrerenderHandle_h >+#define PrerenderHandle_h >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "ReferrerPolicy.h" >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+class KURL; >+class Prerender; >+ >+class PrerenderHandle : public RefCounted<PrerenderHandle> { >+ WTF_MAKE_NONCOPYABLE(PrerenderHandle); >+public: >+ static PassRefPtr<PrerenderHandle> create(const KURL&, const String& referrer, ReferrerPolicy); >+ ~PrerenderHandle(); >+ >+ Prerender* prerender(); >+ >+ // FIXME: one day there will be events here, and we will be a PrerenderClient. >+ >+ // A prerender link element is added when it is inserted into a document. >+ void add(); >+ >+ // A prerender is abandoned when it's navigated away from. This is is a weaker signal >+ // than cancel(), since the launcher hasn't indicated that the prerender isn't wanted, >+ // and we may end up using it after, for instance, a short redirect chain. >+ void abandon(); >+ >+ // A prerender is canceled when it is removed from a document. >+ void cancel(); >+ >+ // A prerender is suspended along with the DOM containing its linkloader & prerenderer. >+ void suspend(); >+ void resume(); >+ >+ const KURL& url() const; >+ const String& referrer() const; >+ ReferrerPolicy referrerPolicy() const; >+ >+private: >+ PrerenderHandle(const KURL&, const String& referrer, ReferrerPolicy); >+ RefPtr<Prerender> m_prerender; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(LINK_PRERENDER) >+ >+#endif // PrerenderHandle_h >diff --git a/Source/WebCore/platform/chromium/Prerender.cpp b/Source/WebCore/platform/chromium/Prerender.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..41b9cda965d8a1d96133273fc48302ed8055c9da >--- /dev/null >+++ b/Source/WebCore/platform/chromium/Prerender.cpp >@@ -0,0 +1,116 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ * >+ */ >+ >+#include "config.h" >+#include "Prerender.h" >+ >+#include <public/Platform.h> >+#include <public/WebPrerender.h> >+#include <public/WebPrerenderingPlatform.h> >+#include <public/WebReferrerPolicy.h> >+#include <public/WebString.h> >+#include <public/WebURL.h> >+ >+#if ENABLE(LINK_PRERENDER) >+ >+namespace WebCore { >+ >+Prerender::Prerender(const KURL& url, const String& referrer, ReferrerPolicy policy) >+ : m_url(url) >+ , m_referrer(referrer) >+ , m_referrerPolicy(policy) >+ , m_platform(0) >+#ifndef NDEBUG >+ , m_state(Inactive) >+#endif >+{ >+} >+ >+Prerender::~Prerender() >+{ >+} >+ >+void Prerender::setState(State state) >+{ >+#ifdef NDEBUG >+ UNUSED_PARAM(state); >+#else >+ m_state = state; >+#endif >+} >+ >+void Prerender::add() >+{ >+ ASSERT(m_state == Inactive); >+ if (!m_platform) >+ m_platform = WebKit::WebPrerenderingPlatform::getPlatform(); >+ if (!m_platform) >+ return; >+ WebKit::WebPrerender webPrerender(this); >+ m_platform->add(webPrerender); >+ setState(Active); >+} >+ >+void Prerender::cancel() >+{ >+ if (!m_platform) >+ return; >+ ASSERT(m_state == Active); >+ WebKit::WebPrerender webPrerender(this); >+ m_platform->cancel(webPrerender); >+ setState(Inactive); >+} >+ >+void Prerender::abandon() >+{ >+ if (!m_platform) >+ return; >+ // FIXME: Assert on the state as Inactive here. It is currently common to call abandon() on an Inactive >+ // prerender, as the Prerenderer doesn't keep track of which prerenders are active, and so any page that >+ // ever had a now-canceled Prerender will get this bogus stop() call. >+ WebKit::WebPrerender webPrerender(this); >+ m_platform->abandon(webPrerender); >+ setState(Inactive); >+} >+ >+void Prerender::suspend() >+{ >+ abandon(); >+} >+ >+void Prerender::resume() >+{ >+ add(); >+} >+ >+} >+ >+#endif // ENABLE(LINK_PRERENDER) >diff --git a/Source/WebCore/platform/chromium/Prerender.h b/Source/WebCore/platform/chromium/Prerender.h >new file mode 100644 >index 0000000000000000000000000000000000000000..67488e7c66012d99c409d019697cc4fadd3ebed0 >--- /dev/null >+++ b/Source/WebCore/platform/chromium/Prerender.h >@@ -0,0 +1,102 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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 Prerender_h >+#define Prerender_h >+ >+#include "KURL.h" >+#include "ReferrerPolicy.h" >+#include <public/WebSize.h> >+#include <wtf/OwnPtr.h> >+#include <wtf/PassOwnPtr.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+#if ENABLE(LINK_PRERENDER) >+ >+namespace WebKit { >+class WebPrerenderingPlatform; >+} >+ >+namespace WebCore { >+ >+class Prerender : public RefCounted<Prerender> { >+ WTF_MAKE_NONCOPYABLE(Prerender); >+public: >+ class ExtraData : public RefCounted<ExtraData> { >+ public: >+ virtual ~ExtraData() { } >+ }; >+ >+ Prerender(const KURL&, const String& referrer, ReferrerPolicy); >+ ~Prerender(); >+ >+ void add(); >+ void cancel(); >+ void abandon(); >+ void suspend(); >+ void resume(); >+ >+ const KURL& url() const { return m_url; } >+ const String& referrer() const { return m_referrer; } >+ ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; } >+ >+ void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; } >+ ExtraData* extraData() { return m_extraData.get(); } >+ >+private: >+ enum State { >+ Inactive, >+ Active, >+ }; >+ >+ void setState(State); >+ >+ const KURL m_url; >+ const String m_referrer; >+ const ReferrerPolicy m_referrerPolicy; >+ >+ RefPtr<ExtraData> m_extraData; >+ >+ WebKit::WebPrerenderingPlatform* m_platform; >+ >+#ifndef NDEBUG >+ State m_state; >+#endif >+}; >+ >+} >+ >+#endif // ENABLE(LINK_PRERENDER) >+ >+#endif // Prerender_h >diff --git a/Source/WebCore/platform/chromium/PrerenderHandle.cpp b/Source/WebCore/platform/chromium/PrerenderHandle.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..edf29f0c6b6a746d98b9c19b18978c45f09b49bc >--- /dev/null >+++ b/Source/WebCore/platform/chromium/PrerenderHandle.cpp >@@ -0,0 +1,106 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ * >+ */ >+ >+#include "config.h" >+#include "PrerenderHandle.h" >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "KURL.h" >+#include "Prerender.h" >+#include "ReferrerPolicy.h" >+#include <wtf/PassRefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+PassRefPtr<PrerenderHandle> PrerenderHandle::create(const KURL& url, const String& referrer, ReferrerPolicy policy) >+{ >+ return adoptRef(new PrerenderHandle(url, referrer, policy)); >+} >+ >+PrerenderHandle::PrerenderHandle(const KURL& url, const String& referrer, ReferrerPolicy policy) >+ : m_prerender(adoptRef(new Prerender(url, referrer, policy))) >+{ >+} >+ >+PrerenderHandle::~PrerenderHandle() >+{ >+} >+ >+Prerender* PrerenderHandle::prerender() >+{ >+ return m_prerender.get(); >+} >+ >+void PrerenderHandle::add() >+{ >+ prerender()->add(); >+} >+ >+void PrerenderHandle::cancel() >+{ >+ prerender()->cancel(); >+} >+ >+void PrerenderHandle::abandon() >+{ >+ prerender()->abandon(); >+} >+ >+void PrerenderHandle::suspend() >+{ >+ prerender()->suspend(); >+} >+ >+void PrerenderHandle::resume() >+{ >+ prerender()->resume(); >+} >+ >+const KURL& PrerenderHandle::url() const >+{ >+ return m_prerender->url(); >+} >+ >+const String& PrerenderHandle::referrer() const >+{ >+ return m_prerender->url(); >+} >+ >+ReferrerPolicy PrerenderHandle::referrerPolicy() const >+{ >+ return m_prerender->referrerPolicy(); >+} >+ >+} >+ >+#endif // ENABLE(LINK_PRERENDER) >diff --git a/Source/WebCore/platform/chromium/support/WebPrerender.cpp b/Source/WebCore/platform/chromium/support/WebPrerender.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..ba7baf5574a02bf54f028a2059524334f3ac9a36 >--- /dev/null >+++ b/Source/WebCore/platform/chromium/support/WebPrerender.cpp >@@ -0,0 +1,102 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ */ >+ >+#include "config.h" >+#include <public/WebPrerender.h> >+#include <wtf/PassRefPtr.h> >+ >+#if ENABLE(LINK_PRERENDER) >+ >+#include "Prerender.h" >+ >+namespace WebKit { >+ >+namespace { >+ >+class ExtraDataContainer : public WebCore::Prerender::ExtraData { >+public: >+ static PassRefPtr<ExtraDataContainer> create(WebPrerender::ExtraData* extraData) { return adoptRef(new ExtraDataContainer(extraData)); } >+ >+ virtual ~ExtraDataContainer() { } >+ >+ WebPrerender::ExtraData* extraData() const { return m_extraData.get(); } >+ >+private: >+ explicit ExtraDataContainer(WebPrerender::ExtraData* extraData) >+ : m_extraData(adoptPtr(extraData)) >+ { >+ } >+ >+ OwnPtr<WebPrerender::ExtraData> m_extraData; >+}; >+ >+} // anon namespace >+ >+WebPrerender::WebPrerender(PassRefPtr<WebCore::Prerender> prerender) >+ : m_private(prerender) >+{ >+} >+ >+WebPrerender::~WebPrerender() >+{ >+ m_private.reset(); >+} >+ >+WebURL WebPrerender::url() const >+{ >+ return WebURL(m_private->url()); >+} >+ >+WebString WebPrerender::referrer() const >+{ >+ return m_private->referrer(); >+} >+ >+WebReferrerPolicy WebPrerender::referrerPolicy() const >+{ >+ return static_cast<WebReferrerPolicy>(m_private->referrerPolicy()); >+} >+ >+void WebPrerender::setExtraData(WebPrerender::ExtraData* extraData) >+{ >+ m_private->setExtraData(ExtraDataContainer::create(extraData)); >+} >+ >+const WebPrerender::ExtraData* WebPrerender::extraData() const >+{ >+ RefPtr<WebCore::Prerender::ExtraData> webcoreExtraData = m_private->extraData(); >+ if (!webcoreExtraData) >+ return 0; >+ return static_cast<ExtraDataContainer*>(webcoreExtraData.get())->extraData(); >+} >+ >+} // namespace WebKit >+ >+#endif // ENABLED(LINK_PRERENDER) >diff --git a/Source/WebCore/platform/network/chromium/ResourceRequest.h b/Source/WebCore/platform/network/chromium/ResourceRequest.h >index fce1ebfd072399443419633dd1d7109ee8723432..7ea61a888bc9fb8aebb2413b841b3cc36e265ce2 100644 >--- a/Source/WebCore/platform/network/chromium/ResourceRequest.h >+++ b/Source/WebCore/platform/network/chromium/ResourceRequest.h >@@ -53,7 +53,6 @@ namespace WebCore { > TargetIsWorker, > TargetIsSharedWorker, > TargetIsPrefetch, >- TargetIsPrerender, > TargetIsFavicon, > TargetIsXHR, > TargetIsTextTrack, >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index 7bff9bc72e943c02b1f1a2018213def2a8c2538e..b85d756fbf1c124d688db04336d80d2eacf27fd1 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -437,6 +437,8 @@ > 'src/InspectorFrontendClientImpl.h', > 'src/NonCompositedContentHost.cpp', > 'src/NonCompositedContentHost.h', >+ 'src/PrerendererClientImpl.h', >+ 'src/PrerendererClientImpl.cpp', > 'src/android/WebInputEventFactory.cpp', > 'src/linux/WebFontInfo.cpp', > 'src/linux/WebFontRendering.cpp', >diff --git a/Source/WebKit/chromium/public/WebView.h b/Source/WebKit/chromium/public/WebView.h >index 561b1302455acf65a34b8c6263d936b2c2befe50..ae3c8ea2732b13f0a0ee45e4d3fe19fc7105889e 100644 >--- a/Source/WebKit/chromium/public/WebView.h >+++ b/Source/WebKit/chromium/public/WebView.h >@@ -106,9 +106,7 @@ public: > virtual void setAutofillClient(WebAutofillClient*) = 0; > virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) = 0; > virtual void setPermissionClient(WebPermissionClient*) = 0; >- // FIXME: After the Prerendering API lands in chrome, remove this staging thunk >- // for setPrerendererClient(). >- virtual void setPrerendererClient(WebPrerendererClient*) { } >+ virtual void setPrerendererClient(WebPrerendererClient*) = 0; > virtual void setSpellCheckClient(WebSpellCheckClient*) = 0; > virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) = 0; > >diff --git a/Source/WebKit/chromium/src/PrerendererClientImpl.cpp b/Source/WebKit/chromium/src/PrerendererClientImpl.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..4651d279de8451a8bba1db548645f9dc6d066327 >--- /dev/null >+++ b/Source/WebKit/chromium/src/PrerendererClientImpl.cpp >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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. >+ * >+ */ >+ >+#include "config.h" >+#include "PrerendererClientImpl.h" >+ >+#include "Document.h" >+#include "Frame.h" >+#include "Prerender.h" >+#include "PrerenderHandle.h" >+#include "WebPrerendererClient.h" >+#include "WebViewImpl.h" >+#include <public/WebPrerender.h> >+#include <wtf/PassRefPtr.h> >+ >+namespace WebKit { >+ >+PrerendererClientImpl::PrerendererClientImpl(WebPrerendererClient* client) >+ : m_client(client) >+{ >+} >+ >+void PrerendererClientImpl::willAddPrerender(WebCore::PrerenderHandle* prerenderHandle) >+{ >+ if (!m_client) >+ return; >+ WebPrerender webPrerender(prerenderHandle->prerender()); >+ m_client->willAddPrerender(&webPrerender); >+} >+ >+} >diff --git a/Source/WebKit/chromium/src/PrerendererClientImpl.h b/Source/WebKit/chromium/src/PrerendererClientImpl.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8517632aea45ccf6a5e360ceec18d4cd53931258 >--- /dev/null >+++ b/Source/WebKit/chromium/src/PrerendererClientImpl.h >@@ -0,0 +1,60 @@ >+/* >+ * 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: >+ * >+ * * 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. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "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 PrerendererClientImpl_h >+#define PrerendererClientImpl_h >+ >+#include "PrerendererClient.h" >+#include <wtf/Noncopyable.h> >+#include <wtf/PassRefPtr.h> >+ >+namespace WebCore { >+class PrerenderHandle; >+} >+ >+namespace WebKit { >+ >+class WebPrerendererClient; >+ >+class PrerendererClientImpl : public WebCore::PrerendererClient { >+ WTF_MAKE_NONCOPYABLE(PrerendererClientImpl); >+public: >+ explicit PrerendererClientImpl(WebPrerendererClient*); >+ >+ void willAddPrerender(WebCore::PrerenderHandle*) OVERRIDE; >+ >+private: >+ WebPrerendererClient* m_client; >+}; >+ >+} >+ >+#endif // PrerendererClientImpl_h >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index 88e4bd8c0c9ca1b47d02b4b236ca7adb18af68da..871cc20ac035b0c9497b1f2e30e315b74f08d001 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -100,6 +100,7 @@ > #include "PointerLockController.h" > #include "PopupContainer.h" > #include "PopupMenuClient.h" >+#include "PrerendererClientImpl.h" > #include "ProgressTracker.h" > #include "RenderLayerCompositor.h" > #include "RenderView.h" >@@ -322,6 +323,11 @@ void WebViewImpl::setPermissionClient(WebPermissionClient* permissionClient) > m_permissionClient = permissionClient; > } > >+void WebViewImpl::setPrerendererClient(WebPrerendererClient* prerendererClient) >+{ >+ providePrerendererClientTo(m_page.get(), new PrerendererClientImpl(prerendererClient)); >+} >+ > void WebViewImpl::setSpellCheckClient(WebSpellCheckClient* spellCheckClient) > { > m_spellCheckClient = spellCheckClient; >diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h >index 9383ba28d9608ba2dc5d0a7fd2417a8824e094d7..8b3bc2b13e4e9af443eeaf1fecab0a06ca52f923 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.h >+++ b/Source/WebKit/chromium/src/WebViewImpl.h >@@ -90,6 +90,7 @@ class DeviceOrientationClientProxy; > class DragScrollTimer; > class GeolocationClientProxy; > class NonCompositedContentHost; >+class PrerendererClientImpl; > class SpeechInputClientImpl; > class SpeechRecognitionClientProxy; > class UserMediaClientImpl; >@@ -100,6 +101,7 @@ class WebDevToolsAgentPrivate; > class WebFrameImpl; > class WebGestureEvent; > class WebPagePopupImpl; >+class WebPrerendererClient; > class WebImage; > class WebKeyboardEvent; > class WebMouseEvent; >@@ -160,6 +162,7 @@ public: > virtual void setAutofillClient(WebAutofillClient*); > virtual void setDevToolsAgentClient(WebDevToolsAgentClient*); > virtual void setPermissionClient(WebPermissionClient*); >+ virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE; > virtual void setSpellCheckClient(WebSpellCheckClient*); > virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) OVERRIDE; > virtual WebSettings* settings(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 4b253f4b26d0ed4954faa3b526464c580dca1a6d..d223ff6c0eaa2d8c5f7a3f1001b52f17df2ed017 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,28 @@ >+2012-04-26 Gavin Peters <gavinp@chromium.org> >+ >+ Add Prerenderer, PrerenderHandle and a chromium interface for Prerendering. >+ https://bugs.webkit.org/show_bug.cgi?id=85005 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The prerender case isn't quite a resource load, and using resource loading to >+ retrieve them has constrained the API, and unnecessarily complicated the loader. >+ >+ The new Prerenderer and PrerenderHandle let <link rel=prerender...> elements signal >+ removal and unload to their platform. >+ >+ These tests are being removed, and expectations updated, because the old phantom-load >+ prerendering interface was susceptible to layout testing, and the new interface requires >+ a full platform to test, so it can't really be a layout test. >+ >+ * fast/dom/HTMLLinkElement/prerender-expected.txt: Removed. >+ * fast/dom/HTMLLinkElement/prerender.html: Removed. >+ * platform/gtk/test_expectations.txt: >+ * platform/mac/Skipped: >+ * platform/qt/Skipped: >+ * platform/win/Skipped: >+ * platform/wincairo/Skipped: >+ > 2012-04-25 Mikhail Naganov <mnaganov@chromium.org> > > [Chromium] Unreviewed test expectations update >diff --git a/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt b/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt >deleted file mode 100644 >index b65bfe2645204d13257ecd246295c0a94d71cced..0000000000000000000000000000000000000000 >--- a/LayoutTests/fast/dom/HTMLLinkElement/prerender-expected.txt >+++ /dev/null >@@ -1,3 +0,0 @@ >-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/prerender.html b/LayoutTests/fast/dom/HTMLLinkElement/prerender.html >deleted file mode 100644 >index 6978f42ceec63753d067c24b28aed73fec634c66..0000000000000000000000000000000000000000 >--- a/LayoutTests/fast/dom/HTMLLinkElement/prerender.html >+++ /dev/null >@@ -1,20 +0,0 @@ >-<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="prerender" onload="prefetch_onload()" onerror="testFailed('onerror')" /> >-</html> >- >diff --git a/LayoutTests/platform/gtk/test_expectations.txt b/LayoutTests/platform/gtk/test_expectations.txt >index e896af5bce3ac27ee3d6f15a717b99d88021e02e..49fb85d267ee2c709548a740fb1ea4718238b79d 100644 >--- a/LayoutTests/platform/gtk/test_expectations.txt >+++ b/LayoutTests/platform/gtk/test_expectations.txt >@@ -898,7 +898,6 @@ BUGWKGTK : fast/dom/HTMLLinkElement/prefetch.html = FAIL > BUGWKGTK : fast/dom/HTMLLinkElement/prefetch-beforeload.html = FAIL > BUGWKGTK : fast/dom/HTMLLinkElement/prefetch-onerror.html = FAIL > BUGWKGTK : fast/dom/HTMLLinkElement/prefetch-onload.html = FAIL >-BUGWKGTK : fast/dom/HTMLLinkElement/prerender.html = FAIL > BUGWKGTK : fast/dom/HTMLLinkElement/subresource.html = FAIL > > // Tests failing because the context menu is grabbing mouse events. >diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped >index 9bfadd090d953066a173829c1b4fef0011de935e..a2298bcd09e71eceafafb796099fe1ea0d82c1db 100644 >--- a/LayoutTests/platform/mac/Skipped >+++ b/LayoutTests/platform/mac/Skipped >@@ -193,7 +193,6 @@ fast/dom/HTMLLinkElement/prefetch-beforeload.html > fast/dom/HTMLLinkElement/prefetch-onerror.html > fast/dom/HTMLLinkElement/prefetch-onload.html > fast/dom/HTMLLinkElement/prefetch-too-many-clients.html >-fast/dom/HTMLLinkElement/prerender.html > fast/dom/HTMLLinkElement/subresource.html > http/tests/misc/link-rel-prefetch-and-subresource.html > http/tests/misc/prefetch-purpose.html >diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped >index f98f395bb155075e7dc807a8908eb45c65992f23..a003545e793549a362c31332f1b3455266324ef6 100644 >--- a/LayoutTests/platform/qt/Skipped >+++ b/LayoutTests/platform/qt/Skipped >@@ -144,7 +144,6 @@ fast/dom/HTMLLinkElement/prefetch-beforeload.html > fast/dom/HTMLLinkElement/prefetch-onerror.html > fast/dom/HTMLLinkElement/prefetch-onload.html > fast/dom/HTMLLinkElement/prefetch-too-many-clients.html >-fast/dom/HTMLLinkElement/prerender.html > fast/dom/HTMLLinkElement/subresource.html > http/tests/misc/link-rel-prefetch-and-subresource.html > http/tests/misc/prefetch-purpose.html >diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped >index 99e25838535dfed7c7892231a28b57fec45449a7..1bb236eb8347c16cd4bb4bd2f9bfd6c1d530a14d 100644 >--- a/LayoutTests/platform/win/Skipped >+++ b/LayoutTests/platform/win/Skipped >@@ -1098,7 +1098,6 @@ fast/dom/HTMLLinkElement/prefetch-onerror.html > fast/dom/HTMLLinkElement/prefetch-onload.html > fast/dom/HTMLLinkElement/prefetch-too-many-clients.html > http/tests/misc/link-rel-prefetch-and-subresource.html >-fast/dom/HTMLLinkElement/prerender.html > fast/dom/HTMLLinkElement/subresource.html > http/tests/misc/prefetch-purpose.html > >diff --git a/LayoutTests/platform/wincairo/Skipped b/LayoutTests/platform/wincairo/Skipped >index e09139b2e39902eb5addb5a46480fde3ac497d7d..7ca9916e0b9100702e1a6c9246ea7ef425cb8ecb 100644 >--- a/LayoutTests/platform/wincairo/Skipped >+++ b/LayoutTests/platform/wincairo/Skipped >@@ -1613,7 +1613,6 @@ fast/dom/HTMLLinkElement/prefetch-onerror.html > fast/dom/HTMLLinkElement/prefetch-onload.html > fast/dom/HTMLLinkElement/prefetch-too-many-clients.html > http/tests/misc/link-rel-prefetch-and-subresource.html >-fast/dom/HTMLLinkElement/prerender.html > fast/dom/HTMLLinkElement/subresource.html > http/tests/misc/prefetch-purpose.html >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 85005
:
139072
|
139105
|
139182
|
139234
|
139533
|
141733