Changeset 429 for trunk/WebCore/loader/appcache/ApplicationCacheStorage.cpp
- Timestamp:
- 08/04/08 12:23:14 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/WebCore/loader/appcache/ApplicationCacheStorage.cpp
r243 r429 436 436 return false; 437 437 438 resource->setStorageID(resourceId); 438 439 return true; 439 440 } … … 454 455 } 455 456 456 voidApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group)457 bool ApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group) 457 458 { 458 459 openDatabase(true); … … 465 466 // Store the group 466 467 if (!store(group)) 467 return ;468 return false; 468 469 } 469 470 … … 473 474 // Store the newest cache 474 475 if (!store(group->newestCache())) 475 return ;476 return false; 476 477 477 478 // Update the newest cache in the group. … … 479 480 SQLiteStatement statement(m_database, "UPDATE CacheGroups SET newestCache=? WHERE id=?"); 480 481 if (statement.prepare() != SQLResultOk) 481 return ;482 return false; 482 483 483 484 statement.bindInt64(1, group->newestCache()->storageID()); … … 485 486 486 487 if (!executeStatement(statement)) 487 return ;488 return false; 488 489 489 490 storeCacheTransaction.commit(); 491 return true; 490 492 } 491 493 … … 618 620 } 619 621 622 bool 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 620 654 ApplicationCacheStorage& cacheStorage() 621 655 {
