1. 本次不生效,但是会写入db
2. 本次的旧cache如果存在,将替换其内存中的manifest resource,否则每个打开的页面将导致每次都会重复下载更新db。
m_cacheBeingUpdated->setGroup(this);
//
if (cacheStorage().storeUpdatedCache(this))
{
// New cache stored, now remove the old cache.
// if (oldNewestCache)
// cacheStorage().remove(oldNewestCache.get());
// Fire the success events.
if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
// 由于清单已经发生了变化,所要把清单的变化apply到旧的
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}
postListenerTask(isUpgradeAttempt ? ApplicationCacheHost::UPDATEREADY_EVENT : ApplicationCacheHost::CACHED_EVENT, m_associatedDocumentLoaders);
}
else
{
if (cacheStorage().isMaximumSizeReached() && !m_calledReachedMaxAppCacheSize)
{
// We ran out of space. All the changes in the cache storage have
// been rolled back. We roll back to the previous state in here,
// as well, call the chrome client asynchronously and retry to
// save the new cache.
// Save a reference to the new cache.
//m_cacheBeingUpdated = m_newestCache.release();
//if (oldNewestCache) {
// Reinstate the oldNewestCache.
// setNewestCache(oldNewestCache.release());
//}
if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}
scheduleReachedMaxAppCacheSizeCallback();
return;
}
else
{
// Run the "cache failure steps"
// Fire the error events to all pending master entries, as well any other cache hosts
// currently associated with a cache in this group.
postListenerTask(ApplicationCacheHost::ERROR_EVENT, m_associatedDocumentLoaders);
// Disassociate the pending master entries from the failed new cache. Note that
// all other loaders in the m_associatedDocumentLoaders are still associated with
// some other cache in this group. They are not associated with the failed new cache.
// Need to copy loaders, because the cache group may be destroyed at the end of iteration.
Vector loaders;
copyToVector(m_pendingMasterResourceLoaders, loaders);
size_t count = loaders.size();
for (size_t i = 0; i != count; ++i)
disassociateDocumentLoader(loaders[i]); // This can delete this group.
// Reinstate the oldNewestCache, if there was one.
//if (oldNewestCache) {
// This will discard the failed new cache.
// setNewestCache(oldNewestCache.release());
//} else {
// We must have been deleted by the last call to disassociateDocumentLoader().
// return;
//}
if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}
}
}