Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (96960 => 96961)
--- trunk/Source/WebCore/CMakeLists.txt 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-10-07 18:16:03 UTC (rev 96961)
@@ -944,6 +944,7 @@
loader/cache/CachedCSSStyleSheet.cpp
loader/cache/CachedFont.cpp
loader/cache/CachedImage.cpp
+ loader/cache/CachedRawResource.cpp
loader/cache/CachedResource.cpp
loader/cache/CachedResourceClientWalker.cpp
loader/cache/CachedResourceHandle.cpp
Modified: trunk/Source/WebCore/ChangeLog (96960 => 96961)
--- trunk/Source/WebCore/ChangeLog 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/ChangeLog 2011-10-07 18:16:03 UTC (rev 96961)
@@ -1,3 +1,36 @@
+2011-10-07 Nate Chapin <[email protected]>
+
+ Make IconLoader a CachedResourceClient instead of a SubresourceLoaderClient.
+ This is one of the steps required to remove the SubresourceLoaderClient interface,
+ which will simplify the layering in the loader.
+ https://bugs.webkit.org/show_bug.cgi?id=69567
+
+ Reviewed by Adam Barth.
+
+ No new tests, no functionality change intended.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/cache/CachedRawResource.cpp: Added.
+ * loader/cache/CachedRawResource.h: Added.
+ * loader/cache/CachedResource.cpp:
+ * loader/cache/CachedResource.h:
+ (WebCore::CachedResource::ignoreForRequestCount): Renamed and generalized from isLinkResource(),
+ which was only used to decided whether the CachedResource should count toward
+ CachedResourceLoader::requestCount().
+ * loader/cache/CachedResourceLoader.cpp:
+ * loader/cache/CachedResourceLoader.h:
+ * loader/cache/CachedResourceRequest.cpp:
+ * loader/cache/CachedResourceRequest.h:
+ * loader/icon/IconLoader.cpp: Get a CachedResource instead of a SubresourceLoader.
+ (WebCore::IconLoader::notifyFinished): Merge in the status code check that was in didReceiveResponse(),
+ since we won't be checking any callbacks before the load completes.
+ * loader/icon/IconLoader.h:
+
2011-10-07 Adam Bergkvist <[email protected]>
Add WebCore platform interfaces needed by updated PeerConnection design
Modified: trunk/Source/WebCore/GNUmakefile.list.am (96960 => 96961)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-10-07 18:16:03 UTC (rev 96961)
@@ -2103,6 +2103,8 @@
Source/WebCore/loader/cache/CachedResourceClient.h \
Source/WebCore/loader/cache/CachedResourceClientWalker.cpp \
Source/WebCore/loader/cache/CachedResourceClientWalker.h \
+ Source/WebCore/loader/cache/CachedRawResource.cpp \
+ Source/WebCore/loader/cache/CachedRawResource.h \
Source/WebCore/loader/cache/CachedResource.cpp \
Source/WebCore/loader/cache/CachedResource.h \
Source/WebCore/loader/cache/CachedResourceHandle.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (96960 => 96961)
--- trunk/Source/WebCore/WebCore.gypi 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/WebCore.gypi 2011-10-07 18:16:03 UTC (rev 96961)
@@ -590,6 +590,7 @@
'loader/archive/mhtml/MHTMLParser.h',
'loader/cache/CachePolicy.h',
'loader/cache/CachedImage.h',
+ 'loader/cache/CachedRawResource.h',
'loader/cache/CachedResource.h',
'loader/cache/CachedResourceClient.h',
'loader/cache/CachedResourceHandle.h',
@@ -2827,6 +2828,7 @@
'loader/cache/CachedFont.cpp',
'loader/cache/CachedFont.h',
'loader/cache/CachedImage.cpp',
+ 'loader/cache/CachedRawResource.cpp',
'loader/cache/CachedResource.cpp',
'loader/cache/CachedResourceClientWalker.cpp',
'loader/cache/CachedResourceClientWalker.h',
Modified: trunk/Source/WebCore/WebCore.pro (96960 => 96961)
--- trunk/Source/WebCore/WebCore.pro 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/WebCore.pro 2011-10-07 18:16:03 UTC (rev 96961)
@@ -869,6 +869,7 @@
loader/cache/CachedCSSStyleSheet.cpp \
loader/cache/CachedFont.cpp \
loader/cache/CachedImage.cpp \
+ loader/cache/CachedRawResource.cpp \
loader/cache/CachedResourceClientWalker.cpp \
loader/cache/CachedResourceHandle.cpp \
loader/cache/CachedResourceRequest.cpp \
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (96960 => 96961)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-07 18:16:03 UTC (rev 96961)
@@ -26653,6 +26653,14 @@
>
</File>
<File
+ RelativePath="..\loader\cache\CachedRawResource.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\loader\cache\CachedRawResource.h"
+ >
+ </File>
+ <File
RelativePath="..\loader\cache\CachedResource.cpp"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (96960 => 96961)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-07 18:16:03 UTC (rev 96961)
@@ -5742,6 +5742,8 @@
D0CE58F9125E4CC200F3F199 /* ResourceLoadScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
D0D141B212B2BF5200E39620 /* CachedResourceRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */; };
D0D141B312B2BF5200E39620 /* CachedResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ D0EDA774143E303C0028E383 /* CachedRawResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0EDA772143E303C0028E383 /* CachedRawResource.cpp */; };
+ D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EDA773143E303C0028E383 /* CachedRawResource.h */; };
D0FF2A5D11F8C45A007E74E0 /* PingLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */; };
D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */; };
D23CA55D0AB0EAAE005108A5 /* JSRangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */; };
@@ -13026,6 +13028,8 @@
D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadScheduler.h; sourceTree = "<group>"; };
D0D141B012B2BF5200E39620 /* CachedResourceRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequest.cpp; sourceTree = "<group>"; };
D0D141B112B2BF5200E39620 /* CachedResourceRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequest.h; sourceTree = "<group>"; };
+ D0EDA772143E303C0028E383 /* CachedRawResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedRawResource.cpp; sourceTree = "<group>"; };
+ D0EDA773143E303C0028E383 /* CachedRawResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRawResource.h; sourceTree = "<group>"; };
D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoader.cpp; sourceTree = "<group>"; };
D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingLoader.h; sourceTree = "<group>"; };
D23CA5480AB0E983005108A5 /* RangeException.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = RangeException.idl; sourceTree = "<group>"; };
@@ -18390,6 +18394,8 @@
A8D2B2521287A56000AF4DDA /* cache */ = {
isa = PBXGroup;
children = (
+ D0EDA772143E303C0028E383 /* CachedRawResource.cpp */,
+ D0EDA773143E303C0028E383 /* CachedRawResource.h */,
BCB16C000979C3BD00467741 /* CachedCSSStyleSheet.cpp */,
BCB16C010979C3BD00467741 /* CachedCSSStyleSheet.h */,
BC64B4C90CB4295D005F2B62 /* CachedFont.cpp */,
@@ -21673,6 +21679,7 @@
51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */,
BCB16C1C0979C3BD00467741 /* CachedImage.h in Headers */,
510184690B08602A004A825F /* CachedPage.h in Headers */,
+ D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */,
BCB16C200979C3BD00467741 /* CachedResource.h in Headers */,
BCFB2E5E0979E46400BA703D /* CachedResourceClient.h in Headers */,
BCB16C220979C3BD00467741 /* CachedResourceClientWalker.h in Headers */,
@@ -25019,6 +25026,7 @@
51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */,
BCB16C1B0979C3BD00467741 /* CachedImage.cpp in Sources */,
5101846A0B08602A004A825F /* CachedPage.cpp in Sources */,
+ D0EDA774143E303C0028E383 /* CachedRawResource.cpp in Sources */,
BCB16C1F0979C3BD00467741 /* CachedResource.cpp in Sources */,
BCB16C210979C3BD00467741 /* CachedResourceClientWalker.cpp in Sources */,
E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */,
Copied: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (from rev 96960, trunk/Source/WebCore/loader/icon/IconLoader.h) (0 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (rev 0)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp 2011-10-07 18:16:03 UTC (rev 96961)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CachedRawResource.h"
+
+#include "CachedResourceClient.h"
+#include "CachedResourceClientWalker.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
+#include "SharedBuffer.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest)
+ : CachedResource(resourceRequest, RawResource)
+{
+}
+
+void CachedRawResource::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
+{
+ m_data = data;
+ CachedResource::data(m_data, allDataReceived);
+}
+
+void CachedRawResource::allClientsRemoved()
+{
+ if (m_request)
+ m_request->cancel();
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/loader/cache/CachedRawResource.h (0 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedRawResource.h (rev 0)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.h 2011-10-07 18:16:03 UTC (rev 96961)
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 1998 Lars Knoll ([email protected])
+ Copyright (C) 2001 Dirk Mueller <[email protected]>
+ Copyright (C) 2006 Samuel Weinig ([email protected])
+ Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CachedRawResource_h
+#define CachedRawResource_h
+
+#include "CachedResource.h"
+
+namespace WebCore {
+
+class CachedRawResource : public CachedResource {
+public:
+ CachedRawResource(ResourceRequest&);
+
+private:
+ virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
+
+ virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
+ virtual void allClientsRemoved();
+};
+
+}
+
+#endif // CachedRawResource_h
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2011-10-07 18:16:03 UTC (rev 96961)
@@ -61,6 +61,7 @@
case CachedResource::FontResource:
return ResourceLoadPriorityMedium;
case CachedResource::ImageResource:
+ case CachedResource::RawResource:
return ResourceLoadPriorityLow;
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2011-10-07 18:16:03 UTC (rev 96961)
@@ -63,7 +63,8 @@
ImageResource,
CSSStyleSheet,
Script,
- FontResource
+ FontResource,
+ RawResource
#if ENABLE(XSLT)
, XSLStyleSheet
#endif
@@ -135,13 +136,15 @@
void setLoading(bool b) { m_loading = b; }
virtual bool isImage() const { return false; }
- bool isLinkResource() const
+ bool ignoreForRequestCount() const
{
+ return false
#if ENABLE(LINK_PREFETCH)
- return type() == LinkPrefetch || type() == LinkPrerender || type() == LinkSubresource;
-#else
- return false;
+ || type() == LinkPrefetch
+ || type() == LinkPrerender
+ || type() == LinkSubresource
#endif
+ || type() == RawResource;
}
unsigned accessCount() const { return m_accessCount; }
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2011-10-07 18:16:03 UTC (rev 96961)
@@ -30,6 +30,7 @@
#include "CachedCSSStyleSheet.h"
#include "CachedFont.h"
#include "CachedImage.h"
+#include "CachedRawResource.h"
#include "CachedResourceRequest.h"
#include "CachedScript.h"
#include "CachedXSLStyleSheet.h"
@@ -66,6 +67,8 @@
return new CachedScript(request, charset);
case CachedResource::FontResource:
return new CachedFont(request);
+ case CachedResource::RawResource:
+ return new CachedRawResource(request);
#if ENABLE(XSLT)
case CachedResource::XSLStyleSheet:
return new CachedXSLStyleSheet(request);
@@ -202,6 +205,11 @@
}
#endif
+CachedRawResource* CachedResourceLoader::requestRawResource(ResourceRequest& request, const ResourceLoaderOptions& options)
+{
+ return static_cast<CachedRawResource*>(requestResource(CachedResource::RawResource, request, String(), options, ResourceLoadPriorityUnresolved, false));
+}
+
bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const KURL& url) const
{
switch (type) {
@@ -226,13 +234,14 @@
}
break;
}
+ case CachedResource::RawResource:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkPrerender:
case CachedResource::LinkSubresource:
// Prefetch cannot affect the current document.
+#endif
break;
-#endif
}
return true;
}
@@ -254,6 +263,7 @@
case CachedResource::CSSStyleSheet:
case CachedResource::Script:
case CachedResource::FontResource:
+ case CachedResource::RawResource:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkPrerender:
@@ -308,12 +318,13 @@
return false;
break;
}
+ case CachedResource::RawResource:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkPrerender:
case CachedResource::LinkSubresource:
+#endif
break;
-#endif
}
return true;
@@ -452,6 +463,10 @@
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to type mismatch.");
return Reload;
}
+
+ // FIXME: Currently, all CachedRawResources are always reloaded. Some of them should be cacheable.
+ if (existingResource->type() == CachedResource::RawResource)
+ return Reload;
// Don't reload resources while pasting.
if (m_allowStaleResources)
@@ -627,7 +642,7 @@
void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
{
- if (res->isLinkResource())
+ if (res->ignoreForRequestCount())
return;
++m_requestCount;
@@ -635,7 +650,7 @@
void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
{
- if (res->isLinkResource())
+ if (res->ignoreForRequestCount())
return;
--m_requestCount;
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2011-10-07 18:16:03 UTC (rev 96961)
@@ -42,6 +42,7 @@
class CachedCSSStyleSheet;
class CachedFont;
class CachedImage;
+class CachedRawResource;
class CachedScript;
class CachedXSLStyleSheet;
class Document;
@@ -64,6 +65,7 @@
CachedCSSStyleSheet* requestUserCSSStyleSheet(ResourceRequest&, const String& charset);
CachedScript* requestScript(ResourceRequest&, const String& charset);
CachedFont* requestFont(ResourceRequest&);
+ CachedRawResource* requestRawResource(ResourceRequest&, const ResourceLoaderOptions&);
#if ENABLE(XSLT)
CachedXSLStyleSheet* requestXSLStyleSheet(ResourceRequest&);
@@ -107,8 +109,6 @@
bool canRequest(CachedResource::Type, const KURL&, bool forPreload = false);
private:
- // FIXME: The default value for ResourceLoaderOptions will always be used currently.
- // It is plumbed for http://bugs.webkit.org/show_bug.cgi?id=61225 .
CachedResource* requestResource(CachedResource::Type, ResourceRequest&, const String& charset, const ResourceLoaderOptions&, ResourceLoadPriority = ResourceLoadPriorityUnresolved, bool isPreload = false);
CachedResource* revalidateResource(CachedResource*, ResourceLoadPriority, const ResourceLoaderOptions&);
CachedResource* loadResource(CachedResource::Type, ResourceRequest&, const String& charset, ResourceLoadPriority, const ResourceLoaderOptions&);
Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp 2011-10-07 18:16:03 UTC (rev 96961)
@@ -60,6 +60,8 @@
return ResourceRequest::TargetIsFontResource;
case CachedResource::ImageResource:
return ResourceRequest::TargetIsImage;
+ case CachedResource::RawResource:
+ return ResourceRequest::TargetIsSubresource;
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
return ResourceRequest::TargetIsPrefetch;
@@ -145,6 +147,13 @@
m_resource->setRequestedFromNetworkingLayer();
}
+void CachedResourceRequest::cancel()
+{
+ if (m_finishing)
+ return;
+ m_loader->cancel();
+}
+
void CachedResourceRequest::didFinishLoading(SubresourceLoader* loader, double)
{
if (m_finishing)
Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.h (96960 => 96961)
--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.h 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.h 2011-10-07 18:16:03 UTC (rev 96961)
@@ -47,6 +47,7 @@
~CachedResourceRequest();
CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; }
+ void cancel();
private:
CachedResourceRequest(CachedResourceLoader*, CachedResource*);
Modified: trunk/Source/WebCore/loader/icon/IconLoader.cpp (96960 => 96961)
--- trunk/Source/WebCore/loader/icon/IconLoader.cpp 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/icon/IconLoader.cpp 2011-10-07 18:16:03 UTC (rev 96961)
@@ -26,28 +26,22 @@
#include "config.h"
#include "IconLoader.h"
+#include "CachedRawResource.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
#include "IconDatabase.h"
#include "Logging.h"
-#include "ResourceHandle.h"
-#include "ResourceLoadScheduler.h"
-#include "ResourceResponse.h"
#include "ResourceRequest.h"
#include "SharedBuffer.h"
-#include "SubresourceLoader.h"
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
-using namespace std;
-
namespace WebCore {
IconLoader::IconLoader(Frame* frame)
: m_frame(frame)
- , m_loadIsInProgress(false)
{
}
@@ -61,110 +55,48 @@
}
void IconLoader::startLoading()
-{
- if (m_resourceLoader)
+{
+ if (m_resource || !m_frame->document())
return;
- // Set flag so we can detect the case where the load completes before
- // SubresourceLoader::create returns.
- m_loadIsInProgress = true;
-
ResourceRequest resourceRequest(m_frame->loader()->icon()->url());
resourceRequest.setPriority(ResourceLoadPriorityLow);
- RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_frame, this, resourceRequest, ResourceLoadPriorityLow, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
- if (!loader)
+ m_resource = m_frame->document()->cachedResourceLoader()->requestRawResource(resourceRequest,
+ ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
+ if (m_resource)
+ m_resource->addClient(this);
+ else
LOG_ERROR("Failed to start load for icon at url %s", m_frame->loader()->icon()->url().string().ascii().data());
-
- // Store the handle so we can cancel the load if stopLoading is called later.
- // But only do it if the load hasn't already completed.
- if (m_loadIsInProgress)
- m_resourceLoader = loader.release();
}
void IconLoader::stopLoading()
{
- clearLoadingState();
+ if (m_resource) {
+ m_resource->removeClient(this);
+ m_resource = 0;
+ }
}
-void IconLoader::didReceiveResponse(SubresourceLoader* resourceLoader, const ResourceResponse& response)
+void IconLoader::notifyFinished(CachedResource* resource)
{
+ ASSERT(resource == m_resource);
+
// If we got a status code indicating an invalid response, then lets
// ignore the data and not try to decode the error page as an icon.
- int status = response.httpStatusCode();
- LOG(IconDatabase, "IconLoader::didReceiveResponse() - Loader %p, response %i", resourceLoader, status);
+ RefPtr<SharedBuffer> data = ""
+ int status = resource->response().httpStatusCode();
+ if (status && (status < 200 || status > 299))
+ data = ""
- if (status && (status < 200 || status > 299)) {
- ResourceHandle* handle = resourceLoader->handle();
- finishLoading(handle ? handle->firstRequest().url() : KURL(), 0);
- }
+ LOG(IconDatabase, "IconLoader::finishLoading() - Committing iconURL %s to database", resource->url().string().ascii().data());
+ m_frame->loader()->icon()->commitToDatabase(resource->url());
+ // Setting the icon data only after committing to the database ensures that the data is
+ // kept in memory (so it does not have to be read from the database asynchronously), since
+ // there is a page URL referencing it.
+ iconDatabase().setIconDataForIconURL(data, resource->url().string());
+ m_frame->loader()->client()->dispatchDidReceiveIcon();
+ stopLoading();
}
-void IconLoader::didReceiveData(SubresourceLoader* unusedLoader, const char*, int unusedSize)
-{
-#if LOG_DISABLED
- UNUSED_PARAM(unusedLoader);
- UNUSED_PARAM(unusedSize);
-#endif
- LOG(IconDatabase, "IconLoader::didReceiveData() - Loader %p, number of bytes %i", unusedLoader, unusedSize);
}
-
-void IconLoader::didFail(SubresourceLoader* resourceLoader, const ResourceError&)
-{
- LOG(IconDatabase, "IconLoader::didFail() - Loader %p", resourceLoader);
-
- // Until <rdar://problem/5463392> is resolved and we can properly cancel SubresourceLoaders when they get an error response,
- // we need to be prepared to receive this call even after we've "finished loading" once.
- // After it is resolved, we can restore an assertion that the load is in progress if ::didFail() is called
-
- if (m_loadIsInProgress) {
- ASSERT(resourceLoader == m_resourceLoader);
- ResourceHandle* handle = resourceLoader->handle();
- finishLoading(handle ? handle->firstRequest().url() : KURL(), 0);
- }
-}
-
-void IconLoader::didFinishLoading(SubresourceLoader* resourceLoader, double)
-{
- LOG(IconDatabase, "IconLoader::didFinishLoading() - Loader %p", resourceLoader);
-
- // Until <rdar://problem/5463392> is resolved and we can properly cancel SubresourceLoaders when they get an error response,
- // we need to be prepared to receive this call even after we've "finished loading" once.
- // After it is resolved, we can restore an assertion that the load is in progress if ::didFail() is called
-
- if (m_loadIsInProgress) {
- ASSERT(resourceLoader == m_resourceLoader);
- ResourceHandle* handle = resourceLoader->handle();
- finishLoading(handle ? handle->firstRequest().url() : KURL(), m_resourceLoader->resourceData());
- }
-}
-
-void IconLoader::finishLoading(const KURL& iconURL, PassRefPtr<SharedBuffer> data)
-{
- // When an icon load results in a 404 we commit it to the database here and clear the loading state.
- // But the SubresourceLoader continues pulling in data in the background for the 404 page if the server sends one.
- // Once that data finishes loading or if the load is cancelled while that data is being read, finishLoading ends up being called a second time.
- // We need to change SubresourceLoader to have a mode where it will stop itself after receiving a 404 so this won't happen -
- // in the meantime, we'll only commit this data to the IconDatabase if it's the first time ::finishLoading() is called
- // <rdar://problem/5463392> tracks that enhancement
-
- if (!iconURL.isEmpty() && m_loadIsInProgress) {
- LOG(IconDatabase, "IconLoader::finishLoading() - Committing iconURL %s to database", iconURL.string().ascii().data());
- m_frame->loader()->icon()->commitToDatabase(iconURL);
- // Setting the icon data only after committing to the database ensures that the data is
- // kept in memory (so it does not have to be read from the database asynchronously), since
- // there is a page URL referencing it.
- iconDatabase().setIconDataForIconURL(data, iconURL.string());
- m_frame->loader()->client()->dispatchDidReceiveIcon();
- }
-
- clearLoadingState();
-}
-
-void IconLoader::clearLoadingState()
-{
- m_resourceLoader = 0;
- m_loadIsInProgress = false;
-}
-
-}
Modified: trunk/Source/WebCore/loader/icon/IconLoader.h (96960 => 96961)
--- trunk/Source/WebCore/loader/icon/IconLoader.h 2011-10-07 18:14:06 UTC (rev 96960)
+++ trunk/Source/WebCore/loader/icon/IconLoader.h 2011-10-07 18:16:03 UTC (rev 96961)
@@ -26,18 +26,18 @@
#ifndef IconLoader_h
#define IconLoader_h
-#include "SubresourceLoaderClient.h"
+#include "CachedResourceClient.h"
+#include "CachedResourceHandle.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
namespace WebCore {
+class CachedRawResource;
class Frame;
-class KURL;
-class SharedBuffer;
-class IconLoader : private SubresourceLoaderClient {
+class IconLoader : private CachedResourceClient {
WTF_MAKE_NONCOPYABLE(IconLoader); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<IconLoader> create(Frame*);
@@ -48,19 +48,10 @@
private:
explicit IconLoader(Frame*);
+ virtual void notifyFinished(CachedResource*);
- virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
- virtual void didReceiveData(SubresourceLoader*, const char*, int);
- virtual void didFinishLoading(SubresourceLoader*, double);
- virtual void didFail(SubresourceLoader*, const ResourceError&);
-
- void finishLoading(const KURL&, PassRefPtr<SharedBuffer> data);
- void clearLoadingState();
-
Frame* m_frame;
-
- RefPtr<SubresourceLoader> m_resourceLoader;
- bool m_loadIsInProgress;
+ CachedResourceHandle<CachedRawResource> m_resource;
};
} // namespace WebCore