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

Side by Side Diff: webkit/appcache/appcache_storage_impl.cc

Issue 10447117: Unwire the clear on exit preference from the storage systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) && 68 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) &&
69 database->InsertDeletableResponseIds(*deletable_response_ids); 69 database->InsertDeletableResponseIds(*deletable_response_ids);
70 } else { 70 } else {
71 NOTREACHED() << "A existing group without a cache is unexpected"; 71 NOTREACHED() << "A existing group without a cache is unexpected";
72 success = database->DeleteGroup(group_id); 72 success = database->DeleteGroup(group_id);
73 } 73 }
74 return success; 74 return success;
75 } 75 }
76 76
77 // Destroys |database|. If there is appcache data to be deleted 77 // Destroys |database|. If there is appcache data to be deleted
78 // (|save_session_state| is false), deletes all appcache data (if 78 // (|force_keep_session_state| is false), deletes session-only appcache data.
79 // |clear_all_data| is true), or session-only appcache data (otherwise). 79 void ClearSessionOnlyOrigins(
80 void CleanUpOnDatabaseThread(
81 AppCacheDatabase* database, 80 AppCacheDatabase* database,
82 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 81 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
83 bool clear_all_appcaches, 82 bool force_keep_session_state) {
84 bool save_session_state) {
85 scoped_ptr<AppCacheDatabase> database_to_delete(database); 83 scoped_ptr<AppCacheDatabase> database_to_delete(database);
86 84
87 // If saving session state, only delete the database. 85 // If saving session state, only delete the database.
88 if (save_session_state) 86 if (force_keep_session_state)
89 return; 87 return;
90 88
91 bool has_session_only_appcaches = 89 bool has_session_only_appcaches =
92 special_storage_policy.get() && 90 special_storage_policy.get() &&
93 special_storage_policy->HasSessionOnlyOrigins(); 91 special_storage_policy->HasSessionOnlyOrigins();
94 92
95 // Clearning only session-only databases, and there are none. 93 // Clearning only session-only databases, and there are none.
96 if (!clear_all_appcaches && !has_session_only_appcaches) 94 if (!has_session_only_appcaches)
97 return; 95 return;
98 96
99 std::set<GURL> origins; 97 std::set<GURL> origins;
100 database->FindOriginsWithGroups(&origins); 98 database->FindOriginsWithGroups(&origins);
101 if (origins.empty()) 99 if (origins.empty())
102 return; // nothing to delete 100 return; // nothing to delete
103 101
104 sql::Connection* connection = database->db_connection(); 102 sql::Connection* connection = database->db_connection();
105 if (!connection) { 103 if (!connection) {
106 NOTREACHED() << "Missing database connection."; 104 NOTREACHED() << "Missing database connection.";
107 return; 105 return;
108 } 106 }
109 107
110 std::set<GURL>::const_iterator origin; 108 std::set<GURL>::const_iterator origin;
111 for (origin = origins.begin(); origin != origins.end(); ++origin) { 109 for (origin = origins.begin(); origin != origins.end(); ++origin) {
112 if (!clear_all_appcaches && 110 if (!special_storage_policy->IsStorageSessionOnly(*origin))
113 !special_storage_policy->IsStorageSessionOnly(*origin))
114 continue; 111 continue;
115 if (special_storage_policy && 112 if (special_storage_policy &&
116 special_storage_policy->IsStorageProtected(*origin)) 113 special_storage_policy->IsStorageProtected(*origin))
117 continue; 114 continue;
118 115
119 std::vector<AppCacheDatabase::GroupRecord> groups; 116 std::vector<AppCacheDatabase::GroupRecord> groups;
120 database->FindGroupsForOrigin(*origin, &groups); 117 database->FindGroupsForOrigin(*origin, &groups);
121 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group; 118 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group;
122 for (group = groups.begin(); group != groups.end(); ++group) { 119 for (group = groups.begin(); group != groups.end(); ++group) {
123 sql::Transaction transaction(connection); 120 sql::Transaction transaction(connection);
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 std::for_each(pending_quota_queries_.begin(), 1305 std::for_each(pending_quota_queries_.begin(),
1309 pending_quota_queries_.end(), 1306 pending_quota_queries_.end(),
1310 std::mem_fun(&DatabaseTask::CancelCompletion)); 1307 std::mem_fun(&DatabaseTask::CancelCompletion));
1311 std::for_each(scheduled_database_tasks_.begin(), 1308 std::for_each(scheduled_database_tasks_.begin(),
1312 scheduled_database_tasks_.end(), 1309 scheduled_database_tasks_.end(),
1313 std::mem_fun(&DatabaseTask::CancelCompletion)); 1310 std::mem_fun(&DatabaseTask::CancelCompletion));
1314 1311
1315 if (database_ && 1312 if (database_ &&
1316 !db_thread_->PostTask( 1313 !db_thread_->PostTask(
1317 FROM_HERE, 1314 FROM_HERE,
1318 base::Bind(&CleanUpOnDatabaseThread, database_, 1315 base::Bind(&ClearSessionOnlyOrigins, database_,
1319 make_scoped_refptr(service_->special_storage_policy()), 1316 make_scoped_refptr(service_->special_storage_policy()),
1320 service()->clear_local_state_on_exit(), 1317 service()->force_keep_session_state()))) {
1321 service()->save_session_state()))) {
1322 delete database_; 1318 delete database_;
1323 } 1319 }
1324 } 1320 }
1325 1321
1326 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory, 1322 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory,
1327 base::MessageLoopProxy* db_thread, 1323 base::MessageLoopProxy* db_thread,
1328 base::MessageLoopProxy* cache_thread) { 1324 base::MessageLoopProxy* cache_thread) {
1329 DCHECK(db_thread); 1325 DCHECK(db_thread);
1330 1326
1331 cache_directory_ = cache_directory; 1327 cache_directory_ = cache_directory;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 Disable(); 1809 Disable();
1814 if (!is_incognito_) { 1810 if (!is_incognito_) {
1815 VLOG(1) << "Deleting existing appcache data and starting over."; 1811 VLOG(1) << "Deleting existing appcache data and starting over.";
1816 db_thread_->PostTask( 1812 db_thread_->PostTask(
1817 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); 1813 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_));
1818 } 1814 }
1819 } 1815 }
1820 } 1816 }
1821 1817
1822 } // namespace appcache 1818 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698