OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 database->DeleteFallbackNameSpacesForCache(cache_record.cache_id) && | 65 database->DeleteFallbackNameSpacesForCache(cache_record.cache_id) && |
66 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) && | 66 database->DeleteOnlineWhiteListForCache(cache_record.cache_id) && |
67 database->InsertDeletableResponseIds(*deletable_response_ids); | 67 database->InsertDeletableResponseIds(*deletable_response_ids); |
68 } else { | 68 } else { |
69 NOTREACHED() << "A existing group without a cache is unexpected"; | 69 NOTREACHED() << "A existing group without a cache is unexpected"; |
70 success = database->DeleteGroup(group_id); | 70 success = database->DeleteGroup(group_id); |
71 } | 71 } |
72 return success; | 72 return success; |
73 } | 73 } |
74 | 74 |
75 // Deletes all appcache data (if clear_all_data is true), or session-only | 75 // Destroys |database|. If there is appcache data to be deleted |
76 // appcache data. Also, schedules the database to be destroyed. | 76 // (|save_session_state| is false), deletes all appcache data (if |
| 77 // |clear_all_data| is true), or session-only appcache data (otherwise). |
77 void CleanUpOnDatabaseThread( | 78 void CleanUpOnDatabaseThread( |
78 AppCacheDatabase* database, | 79 AppCacheDatabase* database, |
79 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 80 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
80 bool clear_all_appcaches) { | 81 bool clear_all_appcaches, |
| 82 bool save_session_state) { |
81 scoped_ptr<AppCacheDatabase> database_to_delete(database); | 83 scoped_ptr<AppCacheDatabase> database_to_delete(database); |
82 | 84 |
| 85 // If saving session state, only delete the database. |
| 86 if (save_session_state) |
| 87 return; |
| 88 |
83 bool has_session_only_appcaches = | 89 bool has_session_only_appcaches = |
84 special_storage_policy.get() && | 90 special_storage_policy.get() && |
85 special_storage_policy->HasSessionOnlyOrigins(); | 91 special_storage_policy->HasSessionOnlyOrigins(); |
86 | 92 |
87 // Clearning only session-only databases, and there are none. | 93 // Clearning only session-only databases, and there are none. |
88 if (!clear_all_appcaches && !has_session_only_appcaches) | 94 if (!clear_all_appcaches && !has_session_only_appcaches) |
89 return; | 95 return; |
90 | 96 |
91 std::set<GURL> origins; | 97 std::set<GURL> origins; |
92 database->FindOriginsWithGroups(&origins); | 98 database->FindOriginsWithGroups(&origins); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 std::mem_fun(&DatabaseTask::CancelCompletion)); | 1190 std::mem_fun(&DatabaseTask::CancelCompletion)); |
1185 std::for_each(scheduled_database_tasks_.begin(), | 1191 std::for_each(scheduled_database_tasks_.begin(), |
1186 scheduled_database_tasks_.end(), | 1192 scheduled_database_tasks_.end(), |
1187 std::mem_fun(&DatabaseTask::CancelCompletion)); | 1193 std::mem_fun(&DatabaseTask::CancelCompletion)); |
1188 | 1194 |
1189 if (database_) { | 1195 if (database_) { |
1190 db_thread_->PostTask( | 1196 db_thread_->PostTask( |
1191 FROM_HERE, | 1197 FROM_HERE, |
1192 base::Bind(&CleanUpOnDatabaseThread, database_, | 1198 base::Bind(&CleanUpOnDatabaseThread, database_, |
1193 make_scoped_refptr(service_->special_storage_policy()), | 1199 make_scoped_refptr(service_->special_storage_policy()), |
1194 service()->clear_local_state_on_exit())); | 1200 service()->clear_local_state_on_exit(), |
| 1201 service()->save_session_state())); |
1195 } | 1202 } |
1196 } | 1203 } |
1197 | 1204 |
1198 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory, | 1205 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory, |
1199 base::MessageLoopProxy* db_thread, | 1206 base::MessageLoopProxy* db_thread, |
1200 base::MessageLoopProxy* cache_thread) { | 1207 base::MessageLoopProxy* cache_thread) { |
1201 DCHECK(db_thread); | 1208 DCHECK(db_thread); |
1202 | 1209 |
1203 cache_directory_ = cache_directory; | 1210 cache_directory_ = cache_directory; |
1204 is_incognito_ = cache_directory_.empty(); | 1211 is_incognito_ = cache_directory_.empty(); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 Disable(); | 1678 Disable(); |
1672 if (!is_incognito_) { | 1679 if (!is_incognito_) { |
1673 VLOG(1) << "Deleting existing appcache data and starting over."; | 1680 VLOG(1) << "Deleting existing appcache data and starting over."; |
1674 db_thread_->PostTask( | 1681 db_thread_->PostTask( |
1675 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); | 1682 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); |
1676 } | 1683 } |
1677 } | 1684 } |
1678 } | 1685 } |
1679 | 1686 |
1680 } // namespace appcache | 1687 } // namespace appcache |
OLD | NEW |