Show
Ignore:
Timestamp:
08/04/08 12:23:14 (5 months ago)
Author:
mbensi
Message:

merge with webkit revision 35534

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/WebCore/loader/appcache/ApplicationCacheStorage.cpp

    r243 r429  
    436436        return false; 
    437437     
     438    resource->setStorageID(resourceId); 
    438439    return true; 
    439440} 
     
    454455} 
    455456 
    456 void ApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group) 
     457bool ApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group) 
    457458{ 
    458459    openDatabase(true); 
     
    465466        // Store the group 
    466467        if (!store(group)) 
    467             return
     468            return false
    468469    } 
    469470     
     
    473474    // Store the newest cache 
    474475    if (!store(group->newestCache())) 
    475         return
     476        return false
    476477     
    477478    // Update the newest cache in the group. 
     
    479480    SQLiteStatement statement(m_database, "UPDATE CacheGroups SET newestCache=? WHERE id=?"); 
    480481    if (statement.prepare() != SQLResultOk) 
    481         return
     482        return false
    482483     
    483484    statement.bindInt64(1, group->newestCache()->storageID()); 
     
    485486     
    486487    if (!executeStatement(statement)) 
    487         return
     488        return false
    488489     
    489490    storeCacheTransaction.commit(); 
     491    return true; 
    490492} 
    491493 
     
    618620}     
    619621 
     622bool ApplicationCacheStorage::storeCopyOfCache(const String& cacheDirectory, ApplicationCache* cache) 
     623{ 
     624    // Create a new cache. 
     625    RefPtr<ApplicationCache> cacheCopy = ApplicationCache::create(); 
     626     
     627    // Set the online whitelist 
     628    cacheCopy->setOnlineWhitelist(cache->onlineWhitelist()); 
     629     
     630    // Traverse the cache and add copies of all resources. 
     631    ApplicationCache::ResourceMap::const_iterator end = cache->end(); 
     632    for (ApplicationCache::ResourceMap::const_iterator it = cache->begin(); it != end; ++it) { 
     633        ApplicationCacheResource* resource = it->second.get(); 
     634         
     635        RefPtr<ApplicationCacheResource> resourceCopy = ApplicationCacheResource::create(resource->url(), resource->response(), resource->type(), resource->data()); 
     636         
     637        cacheCopy->addResource(resourceCopy.release()); 
     638    } 
     639     
     640    // Now create a new cache group. 
     641    OwnPtr<ApplicationCacheGroup> groupCopy(new ApplicationCacheGroup(cache->group()->manifestURL(), true)); 
     642     
     643    groupCopy->setNewestCache(cacheCopy); 
     644     
     645    ApplicationCacheStorage copyStorage; 
     646    copyStorage.setCacheDirectory(cacheDirectory); 
     647     
     648    // Empty the cache in case something was there before. 
     649    copyStorage.empty(); 
     650     
     651    return copyStorage.storeNewestCache(groupCopy.get()); 
     652} 
     653     
    620654ApplicationCacheStorage& cacheStorage() 
    621655{