Example #1
0
void ApplicationCacheGroup::checkIfLoadIsComplete()
{
    ASSERT(m_cacheBeingUpdated);
    
    if (m_manifestHandle)
        return;
    
    if (!m_pendingEntries.isEmpty())
        return;
    
    // We're done    
    bool isUpgradeAttempt = m_newestCache;
    
    m_cacheBeingUpdated->setManifestResource(m_manifestResource.release());
    
    Vector<RefPtr<DocumentLoader> > documentLoaders;

    if (isUpgradeAttempt) {
        ASSERT(m_cacheCandidates.isEmpty());
        
        copyToVector(m_associatedDocumentLoaders, documentLoaders);
    } else {
        while (!m_cacheCandidates.isEmpty()) {
            HashSet<DocumentLoader*>::iterator it = m_cacheCandidates.begin();
            
            DocumentLoader* loader = *it;
            ASSERT(!loader->applicationCache());
            ASSERT(loader->candidateApplicationCacheGroup() == this);
            
            associateDocumentLoaderWithCache(loader, m_cacheBeingUpdated.get());
    
            documentLoaders.append(loader);

            m_cacheCandidates.remove(it);
        }
    }
    
    setNewestCache(m_cacheBeingUpdated.release());
        
    // Store the cache 
    cacheStorage().storeNewestCache(this);
    
    callListeners(isUpgradeAttempt ? &DOMApplicationCache::callUpdateReadyListener : &DOMApplicationCache::callCachedListener, 
                  documentLoaders);

    m_status = Idle;
    m_frame = 0;
}