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

Unified Diff: webkit/dom_storage/dom_storage_context.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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 78363d437469a597abc6b280edc309d819bdd085..cc305990cc14f7026b6992fe94439f7a03f3486f 100644
--- a/webkit/dom_storage/dom_storage_context.cc
+++ b/webkit/dom_storage/dom_storage_context.cc
@@ -13,6 +13,7 @@
#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;
@@ -36,6 +37,16 @@ DomStorageContext::DomStorageContext(
// namespace ids at one since zero is reserved for the
// kLocalStorageNamespaceId.
session_id_sequence_.GetNext();
+ // FIXME(marja): hack.
+ if (!directory_.empty()) {
+ session_storage_database_ =
+ new SessionStorageDatabase(directory.Append("Session Storage"));
+ // Delete the possible leftover data from previous run from the session
+ // storage.
+ // TODO(marja): When doing a session restore, protect parts of the data from
+ // deletion and call this when we know if a session restore will happen.
+ session_storage_database_->DeleteLeftoverData();
michaeln 2012/04/12 01:48:46 This constructor is invoked on the UI thread in ch
marja 2012/04/19 10:20:50 Yes, this was wrong. If we crash, DeleteSessionNa
+ }
}
DomStorageContext::~DomStorageContext() {
@@ -84,6 +95,7 @@ void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos,
infos->push_back(info);
}
}
+ // FIXME(marja): Get usage infos for sessionStorage.
michaeln 2012/04/12 01:48:46 The content settings ui doesn't show anything abou
marja 2012/04/19 10:20:50 Done. crbug.com/123599
}
void DomStorageContext::DeleteOrigin(const GURL& origin) {
@@ -188,8 +200,15 @@ 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(
@@ -229,7 +248,7 @@ void DomStorageContext::ClearLocalStateInCommitSequence() {
DomStorageArea::DatabaseFileNameFromOrigin(origin));
file_util::Delete(database_file_path, kNotRecursive);
file_util::Delete(
- DomStorageDatabase::GetJournalFilePath(database_file_path),
+ LocalStorageDatabase::GetJournalFilePath(database_file_path),
kNotRecursive);
}
}

Powered by Google App Engine
This is Rietveld 408576698