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

Side by Side 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: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/appcache/chrome_appcache_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/appcache/appcache_storage_impl.h" 5 #include "webkit/appcache/appcache_storage_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 database->DeleteFallbackNameSpacesForCache(cache_record.cache_id) && 61 database->DeleteFallbackNameSpacesForCache(cache_record.cache_id) &&
62 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) && 62 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) &&
63 database->InsertDeletableResponseIds(*deletable_response_ids); 63 database->InsertDeletableResponseIds(*deletable_response_ids);
64 } else { 64 } else {
65 NOTREACHED() << "A existing group without a cache is unexpected"; 65 NOTREACHED() << "A existing group without a cache is unexpected";
66 success = database->DeleteGroup(group_id); 66 success = database->DeleteGroup(group_id);
67 } 67 }
68 return success; 68 return success;
69 } 69 }
70 70
71 // delete_permanent is false if we're deleting only session-only origins.
71 void ClearOnExit( 72 void ClearOnExit(
72 AppCacheDatabase* database, 73 AppCacheDatabase* database,
73 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { 74 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
75 bool delete_permanent) {
michaeln 2011/08/26 21:31:01 naming nit: Thoughout the project, this flag goes
marja 2011/08/29 09:41:42 I renamed the flag to clear_all_appcaches (as oppo
74 std::set<GURL> origins; 76 std::set<GURL> origins;
75 database->FindOriginsWithGroups(&origins); 77 database->FindOriginsWithGroups(&origins);
76 if (origins.empty()) 78 if (origins.empty())
77 return; // nothing to delete 79 return; // nothing to delete
78 80
79 sql::Connection* connection = database->db_connection(); 81 sql::Connection* connection = database->db_connection();
80 if (!connection) { 82 if (!connection) {
81 NOTREACHED() << "Missing database connection."; 83 NOTREACHED() << "Missing database connection.";
82 return; 84 return;
83 } 85 }
84 86
87 // We're deleting only session-only data, and there is no policy. Delete
88 // nothing.
89 if (!delete_permanent && !special_storage_policy)
90 return;
91
85 std::set<GURL>::const_iterator origin; 92 std::set<GURL>::const_iterator origin;
86 for (origin = origins.begin(); origin != origins.end(); ++origin) { 93 for (origin = origins.begin(); origin != origins.end(); ++origin) {
94 // We're deleting session-only origins, and this origin is not a
95 // session-only origin.
96 if (!delete_permanent &&
97 !special_storage_policy->IsStorageSessionOnly(*origin))
98 continue;
87 if (special_storage_policy && 99 if (special_storage_policy &&
88 special_storage_policy->IsStorageProtected(*origin)) 100 special_storage_policy->IsStorageProtected(*origin))
89 continue; 101 continue;
90 102
91 std::vector<AppCacheDatabase::GroupRecord> groups; 103 std::vector<AppCacheDatabase::GroupRecord> groups;
92 database->FindGroupsForOrigin(*origin, &groups); 104 database->FindGroupsForOrigin(*origin, &groups);
93 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group; 105 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group;
94 for (group = groups.begin(); group != groups.end(); ++group) { 106 for (group = groups.begin(); group != groups.end(); ++group) {
95 sql::Transaction transaction(connection); 107 sql::Transaction transaction(connection);
96 if (!transaction.Begin()) { 108 if (!transaction.Begin()) {
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 STLDeleteElements(&pending_simple_tasks_); 1153 STLDeleteElements(&pending_simple_tasks_);
1142 1154
1143 std::for_each(pending_quota_queries_.begin(), 1155 std::for_each(pending_quota_queries_.begin(),
1144 pending_quota_queries_.end(), 1156 pending_quota_queries_.end(),
1145 std::mem_fun(&DatabaseTask::CancelCompletion)); 1157 std::mem_fun(&DatabaseTask::CancelCompletion));
1146 std::for_each(scheduled_database_tasks_.begin(), 1158 std::for_each(scheduled_database_tasks_.begin(),
1147 scheduled_database_tasks_.end(), 1159 scheduled_database_tasks_.end(),
1148 std::mem_fun(&DatabaseTask::CancelCompletion)); 1160 std::mem_fun(&DatabaseTask::CancelCompletion));
1149 1161
1150 if (database_) { 1162 if (database_) {
1151 if (service()->clear_local_state_on_exit()) { 1163 AppCacheThread::PostTask(
1152 AppCacheThread::PostTask( 1164 AppCacheThread::db(),
1153 AppCacheThread::db(), 1165 FROM_HERE,
1154 FROM_HERE, 1166 NewRunnableFunction(
1155 NewRunnableFunction( 1167 ClearOnExit,
michaeln 2011/08/26 21:31:01 Since this is now done unconditionally, maybe rena
marja 2011/08/29 09:41:42 Renamed to CleanUpOnDatabaseThread.
1156 ClearOnExit, 1168 database_,
1157 database_, 1169 make_scoped_refptr(service_->special_storage_policy()),
1158 make_scoped_refptr(service_->special_storage_policy()))); 1170 service()->clear_local_state_on_exit()));
1159 }
1160 AppCacheThread::DeleteSoon(AppCacheThread::db(), FROM_HERE, database_); 1171 AppCacheThread::DeleteSoon(AppCacheThread::db(), FROM_HERE, database_);
michaeln 2011/08/26 21:31:01 if you buy that, this line could be deleted
marja 2011/08/29 09:41:42 Done.
1161 } 1172 }
1162 } 1173 }
1163 1174
1164 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory, 1175 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory,
1165 base::MessageLoopProxy* cache_thread) { 1176 base::MessageLoopProxy* cache_thread) {
1166 cache_directory_ = cache_directory; 1177 cache_directory_ = cache_directory;
1167 cache_thread_ = cache_thread; 1178 cache_thread_ = cache_thread;
1168 is_incognito_ = cache_directory_.empty(); 1179 is_incognito_ = cache_directory_.empty();
1169 1180
1170 FilePath db_file_path; 1181 FilePath db_file_path;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 Disable(); 1651 Disable();
1641 if (!is_incognito_) { 1652 if (!is_incognito_) {
1642 VLOG(1) << "Deleting existing appcache data and starting over."; 1653 VLOG(1) << "Deleting existing appcache data and starting over.";
1643 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE, 1654 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE,
1644 NewRunnableFunction(DeleteDirectory, cache_directory_)); 1655 NewRunnableFunction(DeleteDirectory, cache_directory_));
1645 } 1656 }
1646 } 1657 }
1647 } 1658 }
1648 1659
1649 } // namespace appcache 1660 } // namespace appcache
OLDNEW
« 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