Commit ec2dd2c3 authored by andersca@apple.com's avatar andersca@apple.com

WebCore:

2008-05-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Darin.

        Don't crash when a document loader is destroyed while an initial caching attempt
        is in progress.

        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::~ApplicationCacheGroup):
        Stop loading.
        
        (WebCore::ApplicationCacheGroup::stopLoading):
        New method that stops a cache update.
        
        (WebCore::ApplicationCacheGroup::documentLoaderDestroyed):
        Delete ourselves here.
        
        * loader/appcache/ApplicationCacheGroup.h:

LayoutTests:

2008-05-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Darin.

        Add testcase.
        
        * http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt: Added.
        * http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html: Added.
        * http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest: Added.
        * http/tests/appcache/resources/slow-resource.php: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33378 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6e8259dd
2008-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Darin.
Add testcase.
* http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt: Added.
* http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html: Added.
* http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest: Added.
* http/tests/appcache/resources/slow-resource.php: Added.
2008-05-13 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
This tests that navigating away while a cache is loading does not crash.
SUCCESS - did not crash
<html manifest="resources/navigating-away-while-cache-attempt-in-progress.manifest">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText()
layoutTestController.waitUntilDone();
}
function navigateAway() {
if (layoutTestController)
layoutTestController.notifyDone();
else
window.location.href = "about:blank"
}
setTimeout(navigateAway, 1000);
</script>
<div>This tests that navigating away while a cache is loading does not crash.</div>
<div>SUCCESS - did not crash</div>
</html>
2008-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Darin.
Don't crash when a document loader is destroyed while an initial caching attempt
is in progress.
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::~ApplicationCacheGroup):
Stop loading.
(WebCore::ApplicationCacheGroup::stopLoading):
New method that stops a cache update.
(WebCore::ApplicationCacheGroup::documentLoaderDestroyed):
Delete ourselves here.
* loader/appcache/ApplicationCacheGroup.h:
2008-05-13 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
......@@ -58,6 +58,9 @@ ApplicationCacheGroup::~ApplicationCacheGroup()
ASSERT(!m_newestCache);
ASSERT(m_caches.isEmpty());
if (m_cacheBeingUpdated)
stopLoading();
cacheStorage().cacheGroupDestroyed(this);
}
......@@ -220,6 +223,29 @@ void ApplicationCacheGroup::finishedLoadingMainResource(DocumentLoader* loader)
checkIfLoadIsComplete();
}
void ApplicationCacheGroup::stopLoading()
{
ASSERT(m_cacheBeingUpdated);
if (m_manifestHandle) {
ASSERT(!m_currentHandle);
m_manifestHandle->setClient(0);
m_manifestHandle->cancel();
m_manifestHandle = 0;
}
if (m_currentHandle) {
ASSERT(!m_manifestHandle);
m_currentHandle->setClient(0);
m_currentHandle->cancel();
m_currentHandle = 0;
}
m_cacheBeingUpdated = 0;
}
void ApplicationCacheGroup::documentLoaderDestroyed(DocumentLoader* loader)
{
HashSet<DocumentLoader*>::iterator it = m_associatedDocumentLoaders.find(loader);
......@@ -233,9 +259,14 @@ void ApplicationCacheGroup::documentLoaderDestroyed(DocumentLoader* loader)
m_cacheCandidates.remove(loader);
}
if (m_associatedDocumentLoaders.isEmpty() && m_cacheCandidates.isEmpty()) {
// We should only have the newest cache remaining.
ASSERT(m_caches.size() == 1);
if (!m_associatedDocumentLoaders.isEmpty() || !m_cacheCandidates.isEmpty())
return;
// We should only have the newest cache remaining, or there is an initial cache attempt in progress.
ASSERT(m_caches.size() == 1 || m_cacheBeingUpdated);
// If a cache update is in progress, stop it.
if (m_caches.size() == 1) {
ASSERT(m_caches.contains(m_newestCache.get()));
// Release our reference to the newest cache.
......@@ -243,7 +274,16 @@ void ApplicationCacheGroup::documentLoaderDestroyed(DocumentLoader* loader)
// This could cause us to be deleted.
m_newestCache = 0;
}
return;
}
// There is an initial cache attempt in progress
ASSERT(m_cacheBeingUpdated);
ASSERT(m_caches.size() == 0);
// Delete ourselves, causing the cache attempt to be stopped.
delete this;
}
void ApplicationCacheGroup::cacheDestroyed(ApplicationCache* cache)
......
......@@ -99,6 +99,8 @@ private:
void associateDocumentLoaderWithCache(DocumentLoader*, ApplicationCache*);
void stopLoading();
KURL m_manifestURL;
Status m_status;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment