From 9e0c115f468fd538bf7f424e0c77438846c7f69c Mon Sep 17 00:00:00 2001 From: "marja@chromium.org" Date: Tue, 30 Aug 2011 12:46:56 +0000 Subject: Session-only appcache. BUG=47049 TEST=ChromeAppCacheServiceTest.* Review URL: http://codereview.chromium.org/7741040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98804 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/appcache/appcache_storage_impl.cc | 33 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'webkit') diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index 58a3720..63c0554 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -68,9 +68,17 @@ bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, return success; } -void ClearOnExit( +// Deletes all appcache data (if clear_all_data is true), or session-only +// appcache data. Also, schedules the database to be destroyed. +void CleanUpOnDatabaseThread( AppCacheDatabase* database, - scoped_refptr special_storage_policy) { + scoped_refptr special_storage_policy, + bool clear_all_appcaches) { + scoped_ptr database_to_delete(database); + + if (!clear_all_appcaches && !special_storage_policy) + return; + std::set origins; database->FindOriginsWithGroups(&origins); if (origins.empty()) @@ -84,6 +92,9 @@ void ClearOnExit( std::set::const_iterator origin; for (origin = origins.begin(); origin != origins.end(); ++origin) { + if (!clear_all_appcaches && + !special_storage_policy->IsStorageSessionOnly(*origin)) + continue; if (special_storage_policy && special_storage_policy->IsStorageProtected(*origin)) continue; @@ -1148,16 +1159,14 @@ AppCacheStorageImpl::~AppCacheStorageImpl() { std::mem_fun(&DatabaseTask::CancelCompletion)); if (database_) { - if (service()->clear_local_state_on_exit()) { - AppCacheThread::PostTask( - AppCacheThread::db(), - FROM_HERE, - NewRunnableFunction( - ClearOnExit, - database_, - make_scoped_refptr(service_->special_storage_policy()))); - } - AppCacheThread::DeleteSoon(AppCacheThread::db(), FROM_HERE, database_); + AppCacheThread::PostTask( + AppCacheThread::db(), + FROM_HERE, + NewRunnableFunction( + CleanUpOnDatabaseThread, + database_, + make_scoped_refptr(service_->special_storage_policy()), + service()->clear_local_state_on_exit())); } } -- cgit v1.1