summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/cache
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/loader/cache')
-rw-r--r--WebCore/loader/cache/CachePolicy.h2
-rw-r--r--WebCore/loader/cache/CachedImage.cpp4
-rw-r--r--WebCore/loader/cache/CachedImage.h5
-rw-r--r--WebCore/loader/cache/CachedResource.cpp7
-rw-r--r--WebCore/loader/cache/CachedResource.h3
-rw-r--r--WebCore/loader/cache/CachedResourceLoader.cpp5
-rw-r--r--WebCore/loader/cache/MemoryCache.cpp26
-rw-r--r--WebCore/loader/cache/MemoryCache.h2
8 files changed, 33 insertions, 21 deletions
diff --git a/WebCore/loader/cache/CachePolicy.h b/WebCore/loader/cache/CachePolicy.h
index 2639caa..0b9010b 100644
--- a/WebCore/loader/cache/CachePolicy.h
+++ b/WebCore/loader/cache/CachePolicy.h
@@ -33,7 +33,7 @@ namespace WebCore {
CachePolicyVerify,
CachePolicyRevalidate,
CachePolicyReload,
- CachePolicyAllowStale
+ CachePolicyHistoryBuffer
};
}
diff --git a/WebCore/loader/cache/CachedImage.cpp b/WebCore/loader/cache/CachedImage.cpp
index c610b0b..eb5fb1c 100644
--- a/WebCore/loader/cache/CachedImage.cpp
+++ b/WebCore/loader/cache/CachedImage.cpp
@@ -55,7 +55,6 @@ CachedImage::CachedImage(const String& url)
: CachedResource(url, ImageResource)
, m_image(0)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
- , m_httpStatusCodeErrorOccurred(false)
{
setStatus(Unknown);
}
@@ -64,7 +63,6 @@ CachedImage::CachedImage(Image* image)
: CachedResource(String(), ImageResource)
, m_image(image)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
- , m_httpStatusCodeErrorOccurred(false)
{
setStatus(Cached);
setLoading(false);
@@ -314,7 +312,7 @@ void CachedImage::error(CachedResource::Status status)
{
clear();
setStatus(status);
- ASSERT(errorOccurred() || httpStatusCodeErrorOccurred());
+ ASSERT(errorOccurred());
m_data.clear();
notifyObservers();
setLoading(false);
diff --git a/WebCore/loader/cache/CachedImage.h b/WebCore/loader/cache/CachedImage.h
index af36534..e889ea0 100644
--- a/WebCore/loader/cache/CachedImage.h
+++ b/WebCore/loader/cache/CachedImage.h
@@ -67,8 +67,8 @@ public:
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
virtual void error(CachedResource::Status);
- virtual void httpStatusCodeError() { m_httpStatusCodeErrorOccurred = true; }
- bool httpStatusCodeErrorOccurred() const { return m_httpStatusCodeErrorOccurred; }
+ // For compatibility, images keep loading even if there are HTTP errors.
+ virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
void checkNotify();
@@ -97,7 +97,6 @@ private:
RefPtr<Image> m_image;
Timer<CachedImage> m_decodedDataDeletionTimer;
- bool m_httpStatusCodeErrorOccurred;
};
}
diff --git a/WebCore/loader/cache/CachedResource.cpp b/WebCore/loader/cache/CachedResource.cpp
index d4eac2e..844065d 100644
--- a/WebCore/loader/cache/CachedResource.cpp
+++ b/WebCore/loader/cache/CachedResource.cpp
@@ -252,8 +252,11 @@ void CachedResource::removeClient(CachedResourceClient* client)
allClientsRemoved();
if (response().cacheControlContainsNoStore()) {
// RFC2616 14.9.2:
- // "no-store: ...MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
- cache()->remove(this);
+ // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
+ // "... History buffers MAY store such responses as part of their normal operation."
+ // We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
+ if (protocolIs(url(), "https"))
+ cache()->remove(this);
} else
cache()->prune();
}
diff --git a/WebCore/loader/cache/CachedResource.h b/WebCore/loader/cache/CachedResource.h
index ed60f84..9a54c53 100644
--- a/WebCore/loader/cache/CachedResource.h
+++ b/WebCore/loader/cache/CachedResource.h
@@ -85,7 +85,8 @@ public:
virtual String encoding() const { return String(); }
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
virtual void error(CachedResource::Status) { }
- virtual void httpStatusCodeError() { error(LoadError); } // Images keep loading in spite of HTTP errors (for legacy compat with <img>, etc.).
+
+ virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; }
const String &url() const { return m_url; }
Type type() const { return static_cast<Type>(m_type); }
diff --git a/WebCore/loader/cache/CachedResourceLoader.cpp b/WebCore/loader/cache/CachedResourceLoader.cpp
index 3cca206..992e1b5 100644
--- a/WebCore/loader/cache/CachedResourceLoader.cpp
+++ b/WebCore/loader/cache/CachedResourceLoader.cpp
@@ -116,7 +116,7 @@ void CachedResourceLoader::checkForReload(const KURL& fullURL)
case CachePolicyRevalidate:
cache()->revalidateResource(existing, this);
break;
- case CachePolicyAllowStale:
+ case CachePolicyHistoryBuffer:
return;
}
@@ -271,7 +271,8 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type,
checkForReload(fullURL);
- CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload);
+ bool allowForHistoryOnlyResources = cachePolicy() == CachePolicyHistoryBuffer;
+ CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload, allowForHistoryOnlyResources);
if (resource) {
// Check final URL of resource to catch redirects.
// See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
diff --git a/WebCore/loader/cache/MemoryCache.cpp b/WebCore/loader/cache/MemoryCache.cpp
index bd42e5f..ae8e53a 100644
--- a/WebCore/loader/cache/MemoryCache.cpp
+++ b/WebCore/loader/cache/MemoryCache.cpp
@@ -95,9 +95,9 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url
return 0;
}
-CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
+CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload, bool forHistory)
{
- LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload);
+ LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u, forHistory=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload, forHistory);
// FIXME: Do we really need to special-case an empty URL?
// Would it be better to just go on with the cache code and let it fail later?
@@ -107,6 +107,15 @@ CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourc
// Look up the resource in our map.
CachedResource* resource = resourceForURL(url.string());
+ // Non https "no-store" resources are left in the cache to be used for back/forward navigation only.
+ // If this is not a request forHistory and the resource was served with "no-store" we should evict
+ // it here and make a fresh request.
+ if (!forHistory && resource && resource->response().cacheControlContainsNoStore()) {
+ LOG(ResourceLoading, "MemoryCache::requestResource cleared a for history only resource due to a non-history request for the resource");
+ evict(resource);
+ resource = 0;
+ }
+
if (resource && requestIsPreload && !resource->isPreloaded()) {
LOG(ResourceLoading, "MemoryCache::requestResource already has a preload request for this request, and it hasn't been preloaded yet");
return 0;
@@ -118,7 +127,13 @@ CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourc
FrameLoader::reportLocalLoadFailed(cachedResourceLoader->document()->frame(), url.string());
return 0;
}
-
+
+ if (resource && resource->type() != type) {
+ LOG(ResourceLoading, "Cache::requestResource found a cache resource with matching url but different type, evicting and loading with new type.");
+ evict(resource);
+ resource = 0;
+ }
+
if (!resource) {
LOG(ResourceLoading, "CachedResource for '%s' wasn't found in cache. Creating it", url.string().latin1().data());
// The resource does not exist. Create it.
@@ -149,11 +164,6 @@ CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourc
}
}
- if (resource->type() != type) {
- LOG(ResourceLoading, "MemoryCache::requestResource cannot use cached resource for '%s' due to type mismatch", url.string().latin1().data());
- return 0;
- }
-
if (!disabled()) {
// This will move the resource to the front of its LRU list and increase its access count.
resourceAccessed(resource);
diff --git a/WebCore/loader/cache/MemoryCache.h b/WebCore/loader/cache/MemoryCache.h
index a40f85e..6b94eda 100644
--- a/WebCore/loader/cache/MemoryCache.h
+++ b/WebCore/loader/cache/MemoryCache.h
@@ -109,7 +109,7 @@ public:
// Request resources from the cache. A load will be initiated and a cache object created if the object is not
// found in the cache.
- CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
+ CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false, bool forHistory = false);
CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);