in the middle of successful revalidation.
It's more reliable to enforce this in CachedResource than in
SubresourceLoader.
https://bugs.webkit.org/show_bug.cgi?id=75713
Reviewed by Adam Barth.
No new test, the buggy case requires a non-stubbed window.print().
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveResponse):
(WebCore::SubresourceLoader::didFinishLoading):
* loader/SubresourceLoader.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::clearResourceToRevalidate):
(WebCore::CachedResource::switchClientsToRevalidatedResource):
* loader/cache/CachedResource.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105226
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-17 Nate Chapin <japhet@chromium.org>
+
+ Ensure we don't cancel revalidation of a CachedResource
+ in the middle of successful revalidation.
+ It's more reliable to enforce this in CachedResource than in
+ SubresourceLoader.
+ https://bugs.webkit.org/show_bug.cgi?id=75713
+
+ Reviewed by Adam Barth.
+
+ No new test, the buggy case requires a non-stubbed window.print().
+
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::didReceiveResponse):
+ (WebCore::SubresourceLoader::didFinishLoading):
+ * loader/SubresourceLoader.h:
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::CachedResource):
+ (WebCore::CachedResource::clearResourceToRevalidate):
+ (WebCore::CachedResource::switchClientsToRevalidatedResource):
+ * loader/cache/CachedResource.h:
+
2012-01-17 Stephen Chenney <schenney@chromium.org>
NULL ptr in WebCore::RenderSVGInlineText::localCaretRect
if (response.httpStatusCode() == 304) {
// 304 Not modified / Use local copy
// Existing resource is ok, just use it updating the expiration time.
- m_state = Revalidating;
memoryCache()->revalidationSucceeded(m_resource, response);
- if (!reachedTerminalState()) {
+ if (!reachedTerminalState())
ResourceLoader::didReceiveResponse(response);
- didFinishLoading(monotonicallyIncreasingTime());
- }
return;
}
// Did not get 304 response, continue as a regular resource load.
void SubresourceLoader::didFinishLoading(double finishTime)
{
- if (m_state != Initialized && m_state != Revalidating)
+ if (m_state != Initialized)
return;
ASSERT(!reachedTerminalState());
ASSERT(!m_resource->resourceToRevalidate());
enum SubresourceLoaderState {
Uninitialized,
Initialized,
- Revalidating,
Finishing
};
, m_requestedFromNetworkingLayer(false)
, m_inCache(false)
, m_loading(false)
+ , m_switchingClientsToRevalidatedResource(false)
, m_type(type)
, m_status(Pending)
#ifndef NDEBUG
void CachedResource::clearResourceToRevalidate()
{
ASSERT(m_resourceToRevalidate);
+ if (m_switchingClientsToRevalidatedResource)
+ return;
+
// A resource may start revalidation before this method has been called, so check that this resource is still the proxy resource before clearing it out.
if (m_resourceToRevalidate->m_proxyResource == this) {
m_resourceToRevalidate->m_proxyResource = 0;
LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource %p", this, m_resourceToRevalidate);
+ m_switchingClientsToRevalidatedResource = true;
HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end();
for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) {
CachedResourceHandleBase* handle = *it;
for (unsigned n = 0; n < moveCount; ++n)
m_resourceToRevalidate->addClientToSet(clientsToMove[n]);
for (unsigned n = 0; n < moveCount; ++n) {
+ // Calling didAddClient may do anything, including trying to cancel revalidation.
+ // Assert that it didn't succeed.
+ ASSERT(m_resourceToRevalidate);
// Calling didAddClient for a client may end up removing another client. In that case it won't be in the set anymore.
if (m_resourceToRevalidate->m_clients.contains(clientsToMove[n]))
m_resourceToRevalidate->didAddClient(clientsToMove[n]);
}
+ m_switchingClientsToRevalidatedResource = false;
}
void CachedResource::updateResponseAfterRevalidation(const ResourceResponse& validatingResponse)
bool m_inCache : 1;
bool m_loading : 1;
+ bool m_switchingClientsToRevalidatedResource : 1;
+
unsigned m_type : 4; // Type
unsigned m_status : 3; // Status
adjustSize(resource->hasClients(), delta);
revalidatingResource->switchClientsToRevalidatedResource();
+ ASSERT(!revalidatingResource->m_deleted);
// this deletes the revalidating resource
revalidatingResource->clearResourceToRevalidate();
}