Chromium Code Reviews| Index: webkit/dom_storage/dom_storage_context.cc |
| diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc |
| index e31019067cea7b9922f5e894dd30e741c1d0b5c9..175316d4758ed5cdf3514a72274103376bbea44c 100644 |
| --- a/webkit/dom_storage/dom_storage_context.cc |
| +++ b/webkit/dom_storage/dom_storage_context.cc |
| @@ -10,9 +10,11 @@ |
| #include "base/location.h" |
| #include "base/time.h" |
| #include "webkit/dom_storage/dom_storage_area.h" |
| +#include "webkit/dom_storage/dom_storage_database.h" |
| #include "webkit/dom_storage/dom_storage_namespace.h" |
| #include "webkit/dom_storage/dom_storage_task_runner.h" |
| #include "webkit/dom_storage/dom_storage_types.h" |
| +#include "webkit/dom_storage/session_storage_database.h" |
| #include "webkit/quota/special_storage_policy.h" |
| using file_util::FileEnumerator; |
| @@ -38,6 +40,10 @@ DomStorageContext::DomStorageContext( |
| // namespace ids at one since zero is reserved for the |
| // kLocalStorageNamespaceId. |
| session_id_sequence_.GetNext(); |
| + if (!sessionstorage_directory_.empty()) { |
| + session_storage_database_ = |
| + new SessionStorageDatabase(sessionstorage_directory_); |
| + } |
| } |
| DomStorageContext::~DomStorageContext() { |
| @@ -87,6 +93,7 @@ void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos, |
| infos->push_back(info); |
| } |
| } |
| + // FIXME(marja): Get usage infos for sessionStorage (crbug.com/123599). |
| } |
| void DomStorageContext::DeleteOrigin(const GURL& origin) { |
| @@ -146,6 +153,16 @@ void DomStorageContext::Shutdown() { |
| base::Bind(&DomStorageContext::ClearLocalStateInCommitSequence, this)); |
| DCHECK(success); |
| } |
| + |
| + // If the last exit was unclean, the session storage backing might contain |
| + // leftover data. Delete it now. |
| + // TODO(marja): When doing a session restore, protect parts of the data from |
| + // deletion. |
| + bool success = task_runner_->PostShutdownBlockingTask( |
| + FROM_HERE, |
| + DomStorageTaskRunner::COMMIT_SEQUENCE, |
| + base::Bind(&DomStorageContext::DeleteLeftoverDataInCommitSequence, this)); |
|
michaeln
2012/04/22 21:43:35
it might be premature to have this here, feels lik
marja
2012/05/11 12:18:32
Should I make it so that this CL just deletes all
michaeln
2012/05/16 08:10:55
Maybe don't try to answer this question just yet,
|
| + DCHECK(success); |
| } |
| void DomStorageContext::AddEventObserver(EventObserver* observer) { |
| @@ -191,14 +208,31 @@ void DomStorageContext::CreateSessionNamespace( |
| return; |
| DCHECK(namespace_id != kLocalStorageNamespaceId); |
| DCHECK(namespaces_.find(namespace_id) == namespaces_.end()); |
| - namespaces_[namespace_id] = new DomStorageNamespace( |
| - namespace_id, task_runner_); |
| + if (session_storage_database_.get()) { |
| + // Session storage with backing. |
| + namespaces_[namespace_id] = new DomStorageNamespace( |
| + namespace_id, session_storage_database_.get(), task_runner_); |
| + } else { |
| + // Session storage without backing. |
| + namespaces_[namespace_id] = new DomStorageNamespace( |
| + namespace_id, task_runner_); |
| + } |
| } |
| void DomStorageContext::DeleteSessionNamespace( |
| int64 namespace_id) { |
| DCHECK_NE(kLocalStorageNamespaceId, namespace_id); |
| namespaces_.erase(namespace_id); |
| + // TODO(marja): When doing a session restore, protect parts of the data from |
| + // deletion. |
|
michaeln
2012/04/22 21:43:35
maybe the way the session handling logic in chrome
marja
2012/05/11 12:18:32
Hmm, not sure yet how this would work.
Could the
|
| + if (session_storage_database_.get()) { |
| + bool success = task_runner_->PostShutdownBlockingTask( |
| + FROM_HERE, |
| + DomStorageTaskRunner::COMMIT_SEQUENCE, |
| + base::Bind(&DomStorageContext::DeleteSessionNamespaceInCommitSequence, |
| + this, namespace_id)); |
| + DCHECK(success); |
| + } |
| } |
| void DomStorageContext::CloneSessionNamespace( |
| @@ -237,4 +271,13 @@ void DomStorageContext::ClearLocalStateInCommitSequence() { |
| } |
| } |
| +void DomStorageContext::DeleteSessionNamespaceInCommitSequence( |
| + int64 namespace_id) { |
| + session_storage_database_->DeleteNamespace(namespace_id); |
| +} |
| + |
| +void DomStorageContext::DeleteLeftoverDataInCommitSequence() { |
| + session_storage_database_->DeleteLeftoverData(); |
| +} |
| + |
| } // namespace dom_storage |