| OLD | NEW |
| 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/dom_storage/dom_storage_context.h" | 5 #include "webkit/dom_storage/dom_storage_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // which is backed by disk. | 163 // which is backed by disk. |
| 164 // TODO(marja): Purge sessionStorage, too. (Requires changes to the FastClear | 164 // TODO(marja): Purge sessionStorage, too. (Requires changes to the FastClear |
| 165 // functionality.) | 165 // functionality.) |
| 166 StorageNamespaceMap::iterator found = | 166 StorageNamespaceMap::iterator found = |
| 167 namespaces_.find(kLocalStorageNamespaceId); | 167 namespaces_.find(kLocalStorageNamespaceId); |
| 168 if (found != namespaces_.end()) | 168 if (found != namespaces_.end()) |
| 169 found->second->PurgeMemory(); | 169 found->second->PurgeMemory(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void DomStorageContext::Shutdown() { | 172 void DomStorageContext::Shutdown() { |
| 173 LOG(ERROR) << "DomStorageContext::Shutdown"; | |
| 174 is_shutdown_ = true; | 173 is_shutdown_ = true; |
| 175 StorageNamespaceMap::const_iterator it = namespaces_.begin(); | 174 StorageNamespaceMap::const_iterator it = namespaces_.begin(); |
| 176 for (; it != namespaces_.end(); ++it) | 175 for (; it != namespaces_.end(); ++it) |
| 177 it->second->Shutdown(); | 176 it->second->Shutdown(); |
| 178 | 177 |
| 179 if (localstorage_directory_.empty() && !session_storage_database_.get()) { | 178 if (localstorage_directory_.empty() && !session_storage_database_.get()) |
| 180 LOG(ERROR) << "No databases"; | |
| 181 return; | 179 return; |
| 182 } | |
| 183 | 180 |
| 184 // Respect the content policy settings about what to | 181 // Respect the content policy settings about what to |
| 185 // keep and what to discard. | 182 // keep and what to discard. |
| 186 if (force_keep_session_state_) { | 183 if (force_keep_session_state_) |
| 187 LOG(ERROR) << "Saving the session state"; | |
| 188 return; // Keep everything. | 184 return; // Keep everything. |
| 189 } | |
| 190 | 185 |
| 191 bool has_session_only_origins = | 186 bool has_session_only_origins = |
| 192 special_storage_policy_.get() && | 187 special_storage_policy_.get() && |
| 193 special_storage_policy_->HasSessionOnlyOrigins(); | 188 special_storage_policy_->HasSessionOnlyOrigins(); |
| 194 | 189 |
| 195 if (has_session_only_origins) { | 190 if (has_session_only_origins) { |
| 196 LOG(ERROR) << "There is session only data to clear"; | |
| 197 // We may have to delete something. We continue on the | 191 // We may have to delete something. We continue on the |
| 198 // commit sequence after area shutdown tasks have cycled | 192 // commit sequence after area shutdown tasks have cycled |
| 199 // thru that sequence (and closed their database files). | 193 // thru that sequence (and closed their database files). |
| 200 bool success = task_runner_->PostShutdownBlockingTask( | 194 bool success = task_runner_->PostShutdownBlockingTask( |
| 201 FROM_HERE, | 195 FROM_HERE, |
| 202 DomStorageTaskRunner::COMMIT_SEQUENCE, | 196 DomStorageTaskRunner::COMMIT_SEQUENCE, |
| 203 base::Bind(&DomStorageContext::ClearSessionOnlyOrigins, this)); | 197 base::Bind(&DomStorageContext::ClearSessionOnlyOrigins, this)); |
| 204 DCHECK(success); | 198 DCHECK(success); |
| 205 } | 199 } |
| 206 } | 200 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 CreateSessionNamespace(new_id, new_persistent_id); | 299 CreateSessionNamespace(new_id, new_persistent_id); |
| 306 } | 300 } |
| 307 | 301 |
| 308 void DomStorageContext::ClearSessionOnlyOrigins() { | 302 void DomStorageContext::ClearSessionOnlyOrigins() { |
| 309 if (!localstorage_directory_.empty()) { | 303 if (!localstorage_directory_.empty()) { |
| 310 std::vector<LocalStorageUsageInfo> infos; | 304 std::vector<LocalStorageUsageInfo> infos; |
| 311 const bool kDontIncludeFileInfo = false; | 305 const bool kDontIncludeFileInfo = false; |
| 312 GetLocalStorageUsage(&infos, kDontIncludeFileInfo); | 306 GetLocalStorageUsage(&infos, kDontIncludeFileInfo); |
| 313 for (size_t i = 0; i < infos.size(); ++i) { | 307 for (size_t i = 0; i < infos.size(); ++i) { |
| 314 const GURL& origin = infos[i].origin; | 308 const GURL& origin = infos[i].origin; |
| 315 LOG(ERROR) << "Data for origin " << origin; | 309 if (special_storage_policy_->IsStorageProtected(origin)) |
| 316 if (special_storage_policy_->IsStorageProtected(origin)) { | |
| 317 LOG(ERROR) << "Was protected"; | |
| 318 continue; | 310 continue; |
| 319 } | 311 if (!special_storage_policy_->IsStorageSessionOnly(origin)) |
| 320 if (!special_storage_policy_->IsStorageSessionOnly(origin)) { | |
| 321 LOG(ERROR) << "Not session only"; | |
| 322 continue; | 312 continue; |
| 323 } | |
| 324 | 313 |
| 325 LOG(ERROR) << "Clearing it"; | |
| 326 const bool kNotRecursive = false; | 314 const bool kNotRecursive = false; |
| 327 FilePath database_file_path = localstorage_directory_.Append( | 315 FilePath database_file_path = localstorage_directory_.Append( |
| 328 DomStorageArea::DatabaseFileNameFromOrigin(origin)); | 316 DomStorageArea::DatabaseFileNameFromOrigin(origin)); |
| 329 file_util::Delete(database_file_path, kNotRecursive); | 317 file_util::Delete(database_file_path, kNotRecursive); |
| 330 file_util::Delete( | 318 file_util::Delete( |
| 331 DomStorageDatabase::GetJournalFilePath(database_file_path), | 319 DomStorageDatabase::GetJournalFilePath(database_file_path), |
| 332 kNotRecursive); | 320 kNotRecursive); |
| 333 } | 321 } |
| 334 } | 322 } |
| 335 if (session_storage_database_.get()) { | 323 if (session_storage_database_.get()) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (!deletable_persistent_namespace_ids_.empty()) { | 414 if (!deletable_persistent_namespace_ids_.empty()) { |
| 427 task_runner_->PostDelayedTask( | 415 task_runner_->PostDelayedTask( |
| 428 FROM_HERE, base::Bind( | 416 FROM_HERE, base::Bind( |
| 429 &DomStorageContext::DeleteNextUnusedNamespace, | 417 &DomStorageContext::DeleteNextUnusedNamespace, |
| 430 this), | 418 this), |
| 431 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); | 419 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); |
| 432 } | 420 } |
| 433 } | 421 } |
| 434 | 422 |
| 435 } // namespace dom_storage | 423 } // namespace dom_storage |
| OLD | NEW |