summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authormarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 21:20:55 +0000
committermarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 21:20:55 +0000
commit9cc8fd9c7aa8c6ef9afc02c6ffab48c216723fda (patch)
treef7078c4bd4b48f904aa1d3b39504a07b9a01884c /webkit
parent17b5a817290e1b495a577fcc783d15fb8bc89137 (diff)
downloadchromium_src-9cc8fd9c7aa8c6ef9afc02c6ffab48c216723fda.zip
chromium_src-9cc8fd9c7aa8c6ef9afc02c6ffab48c216723fda.tar.gz
chromium_src-9cc8fd9c7aa8c6ef9afc02c6ffab48c216723fda.tar.bz2
Session restore: Store and restore persistent IDs for sessionStorage.
Saving the sessionStorage data on disk will be done in a future CL. BUG=104292 TEST=TBD Review URL: https://chromiumcodereview.appspot.com/10572015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/dom_storage/dom_storage_context.cc3
-rw-r--r--webkit/dom_storage/dom_storage_context.h2
-rw-r--r--webkit/dom_storage/dom_storage_session.cc12
-rw-r--r--webkit/dom_storage/dom_storage_session.h2
-rw-r--r--webkit/tools/test_shell/simple_dom_storage_system.cc2
5 files changed, 15 insertions, 6 deletions
diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc
index 8d8c4e6..9d431ba 100644
--- a/webkit/dom_storage/dom_storage_context.cc
+++ b/webkit/dom_storage/dom_storage_context.cc
@@ -190,8 +190,9 @@ void DomStorageContext::CreateSessionNamespace(
}
void DomStorageContext::DeleteSessionNamespace(
- int64 namespace_id) {
+ int64 namespace_id, bool should_persist_data) {
DCHECK_NE(kLocalStorageNamespaceId, namespace_id);
+ // TODO(marja): Protect the sessionStorage data (once it's written on disk).
namespaces_.erase(namespace_id);
}
diff --git a/webkit/dom_storage/dom_storage_context.h b/webkit/dom_storage/dom_storage_context.h
index 33b1e8c..b6fe5da 100644
--- a/webkit/dom_storage/dom_storage_context.h
+++ b/webkit/dom_storage/dom_storage_context.h
@@ -156,7 +156,7 @@ class DomStorageContext
// Must be called on the background thread.
void CreateSessionNamespace(int64 namespace_id,
const std::string& persistent_namespace_id);
- void DeleteSessionNamespace(int64 namespace_id);
+ void DeleteSessionNamespace(int64 namespace_id, bool should_persist_data);
void CloneSessionNamespace(int64 existing_id, int64 new_id,
const std::string& new_persistent_id);
diff --git a/webkit/dom_storage/dom_storage_session.cc b/webkit/dom_storage/dom_storage_session.cc
index 91c2f39..2961fa3 100644
--- a/webkit/dom_storage/dom_storage_session.cc
+++ b/webkit/dom_storage/dom_storage_session.cc
@@ -16,7 +16,8 @@ namespace dom_storage {
DomStorageSession::DomStorageSession(DomStorageContext* context)
: context_(context),
namespace_id_(context->AllocateSessionId()),
- persistent_namespace_id_(context->AllocatePersistentSessionId()) {
+ persistent_namespace_id_(context->AllocatePersistentSessionId()),
+ should_persist_(false) {
context->task_runner()->PostTask(
FROM_HERE,
base::Bind(&DomStorageContext::CreateSessionNamespace,
@@ -27,13 +28,18 @@ DomStorageSession::DomStorageSession(DomStorageContext* context,
const std::string& persistent_namespace_id)
: context_(context),
namespace_id_(context->AllocateSessionId()),
- persistent_namespace_id_(persistent_namespace_id) {
+ persistent_namespace_id_(persistent_namespace_id),
+ should_persist_(false) {
context->task_runner()->PostTask(
FROM_HERE,
base::Bind(&DomStorageContext::CreateSessionNamespace,
context_, namespace_id_, persistent_namespace_id_));
}
+void DomStorageSession::SetShouldPersist(bool should_persist) {
+ should_persist_ = should_persist;
+}
+
DomStorageSession* DomStorageSession::Clone() {
return CloneFrom(context_, namespace_id_);
}
@@ -63,7 +69,7 @@ DomStorageSession::~DomStorageSession() {
context_->task_runner()->PostTask(
FROM_HERE,
base::Bind(&DomStorageContext::DeleteSessionNamespace,
- context_, namespace_id_));
+ context_, namespace_id_, should_persist_));
}
} // namespace dom_storage
diff --git a/webkit/dom_storage/dom_storage_session.h b/webkit/dom_storage/dom_storage_session.h
index 6de9f95..6f16943 100644
--- a/webkit/dom_storage/dom_storage_session.h
+++ b/webkit/dom_storage/dom_storage_session.h
@@ -34,6 +34,7 @@ class DomStorageSession
const std::string& persistent_namespace_id() const {
return persistent_namespace_id_;
}
+ void SetShouldPersist(bool should_persist);
DomStorageSession* Clone();
// Constructs a |DomStorageSession| by cloning
@@ -52,6 +53,7 @@ class DomStorageSession
scoped_refptr<DomStorageContext> context_;
int64 namespace_id_;
std::string persistent_namespace_id_;
+ bool should_persist_;
DISALLOW_IMPLICIT_CONSTRUCTORS(DomStorageSession);
};
diff --git a/webkit/tools/test_shell/simple_dom_storage_system.cc b/webkit/tools/test_shell/simple_dom_storage_system.cc
index 5b6188b5..4e040e2 100644
--- a/webkit/tools/test_shell/simple_dom_storage_system.cc
+++ b/webkit/tools/test_shell/simple_dom_storage_system.cc
@@ -94,7 +94,7 @@ SimpleDomStorageSystem::NamespaceImpl::~NamespaceImpl() {
namespace_id_ == kInvalidNamespaceId || !Context()) {
return;
}
- Context()->DeleteSessionNamespace(namespace_id_);
+ Context()->DeleteSessionNamespace(namespace_id_, false);
}
WebStorageArea* SimpleDomStorageSystem::NamespaceImpl::createStorageArea(