summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/CachedResource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/loader/CachedResource.cpp')
-rw-r--r--WebCore/loader/CachedResource.cpp48
1 files changed, 43 insertions, 5 deletions
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp
index a6ff0ff..e519c29 100644
--- a/WebCore/loader/CachedResource.cpp
+++ b/WebCore/loader/CachedResource.cpp
@@ -33,6 +33,7 @@
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "KURL.h"
+#include "Logging.h"
#include "PurgeableBuffer.h"
#include "Request.h"
#include "ResourceHandle.h"
@@ -350,6 +351,8 @@ void CachedResource::setResourceToRevalidate(CachedResource* resource)
ASSERT(m_handlesToRevalidate.isEmpty());
ASSERT(resource->type() == type());
+ LOG(ResourceLoading, "CachedResource %p setResourceToRevalidate %p", this, resource);
+
// The following assert should be investigated whenever it occurs. Although it should never fire, it currently does in rare circumstances.
// https://bugs.webkit.org/show_bug.cgi?id=28604.
// So the code needs to be robust to this assert failing thus the "if (m_resourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToRevalidate.
@@ -378,6 +381,8 @@ void CachedResource::switchClientsToRevalidatedResource()
ASSERT(m_resourceToRevalidate->inCache());
ASSERT(!inCache());
+ LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource %p", this, m_resourceToRevalidate);
+
HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end();
for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) {
CachedResourceHandleBase* handle = *it;
@@ -428,6 +433,25 @@ void CachedResource::updateResponseAfterRevalidation(const ResourceResponse& val
}
}
+void CachedResource::registerHandle(CachedResourceHandleBase* h)
+{
+ ++m_handleCount;
+ if (m_resourceToRevalidate)
+ m_handlesToRevalidate.add(h);
+}
+
+void CachedResource::unregisterHandle(CachedResourceHandleBase* h)
+{
+ ASSERT(m_handleCount > 0);
+ --m_handleCount;
+
+ if (m_resourceToRevalidate)
+ m_handlesToRevalidate.remove(h);
+
+ if (!m_handleCount)
+ deleteIfPossible();
+}
+
bool CachedResource::canUseCacheValidator() const
{
if (m_loading || m_errorOccurred)
@@ -443,19 +467,33 @@ bool CachedResource::canUseCacheValidator() const
bool CachedResource::mustRevalidate(CachePolicy cachePolicy) const
{
- if (m_errorOccurred)
+ if (m_errorOccurred) {
+ LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_errorOccurred\n", this);
return true;
+ }
if (m_loading)
return false;
- if (m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore())
+ if (m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()) {
+ LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()\n", this);
return true;
+ }
- if (cachePolicy == CachePolicyCache)
- return m_response.cacheControlContainsMustRevalidate() && isExpired();
+ if (cachePolicy == CachePolicyCache) {
+ if (m_response.cacheControlContainsMustRevalidate() && isExpired()) {
+ LOG(ResourceLoading, "CachedResource %p mustRevalidate because of cachePolicy == CachePolicyCache and m_response.cacheControlContainsMustRevalidate() && isExpired()\n", this);
+ return true;
+ }
+ return false;
+ }
+
+ if (isExpired()) {
+ LOG(ResourceLoading, "CachedResource %p mustRevalidate because of isExpired()\n", this);
+ return true;
+ }
- return isExpired();
+ return false;
}
bool CachedResource::isSafeToMakePurgeable() const