Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2240)

Unified Diff: webkit/appcache/appcache_storage_impl.cc

Issue 7741040: Session-only appcache. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review comments. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/appcache/chrome_appcache_service_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_storage_impl.cc
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc
index 58a3720e2331218a94c616d4e849ef410d20ca82..be87c307b7d174e6a40da752171cf92b238bfa9e 100644
--- a/webkit/appcache/appcache_storage_impl.cc
+++ b/webkit/appcache/appcache_storage_impl.cc
@@ -68,9 +68,16 @@ 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.
michaeln 2011/08/29 17:43:15 This doc comment is pretty clear, consider removin
marja 2011/08/30 09:45:09 Done.
+void CleanUpOnDatabaseThread(
AppCacheDatabase* database,
- scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) {
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
+ bool clear_all_appcaches) {
+ // Schedule the deletion of database, no matter how we return from this
+ // function.
+ AppCacheThread::DeleteSoon(AppCacheThread::db(), FROM_HERE, database);
michaeln 2011/08/29 17:43:15 Please use a local scoped_ptr<> here since it's li
marja 2011/08/30 09:45:09 Done.
+
std::set<GURL> origins;
database->FindOriginsWithGroups(&origins);
if (origins.empty())
@@ -82,8 +89,18 @@ void ClearOnExit(
return;
}
+ // We're deleting only session-only data, and there is no policy. Delete
+ // nothing.
+ if (!clear_all_appcaches && !special_storage_policy)
michaeln 2011/08/29 17:43:15 Looks like this could be moved up above the databa
marja 2011/08/30 09:45:09 Done.
+ return;
+
std::set<GURL>::const_iterator origin;
for (origin = origins.begin(); origin != origins.end(); ++origin) {
+ // We're deleting session-only origins, and this origin is not a
+ // session-only origin.
+ if (!clear_all_appcaches &&
+ !special_storage_policy->IsStorageSessionOnly(*origin))
+ continue;
if (special_storage_policy &&
special_storage_policy->IsStorageProtected(*origin))
continue;
@@ -1148,16 +1165,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()));
}
}
« no previous file with comments | « content/browser/appcache/chrome_appcache_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698