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

Unified Diff: content/browser/dom_storage/dom_storage_context_impl.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 6 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: content/browser/dom_storage/dom_storage_context_impl.cc
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc
index 683e105d7d4587564208ed0abe0bd487c1195c76..099a932d48c7e6cf08bf02b0680922e05b26b561 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/message_loop_proxy.h"
+#include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
#include "webkit/database/database_util.h"
@@ -26,6 +27,7 @@ using webkit_database::DatabaseUtil;
namespace {
const char kLocalStorageDirectory[] = "Local Storage";
+const char kSessionStorageDirectory[] = "Session Storage";
// TODO(michaeln): Fix the content layer api, FilePaths and
// string16 origin_ids are just wrong. Then get rid of
@@ -79,14 +81,14 @@ void GetAllStorageFilesHelper(
DOMStorageContextImpl::DOMStorageContextImpl(
const FilePath& data_path,
- quota::SpecialStoragePolicy* special_storage_policy) {
+ quota::SpecialStoragePolicy* special_storage_policy,
+ bool session_storage_on_disk) {
base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
- // TODO(marja): Pass a nonempty session storage directory when session storage
- // is backed on disk.
context_ = new dom_storage::DomStorageContext(
data_path.empty() ?
data_path : data_path.AppendASCII(kLocalStorageDirectory),
- FilePath(), // Empty session storage directory.
+ (data_path.empty() || !session_storage_on_disk) ?
+ data_path : data_path.AppendASCII(kSessionStorageDirectory),
special_storage_policy,
new DomStorageWorkerPoolTaskRunner(
worker_pool,
@@ -142,6 +144,20 @@ void DOMStorageContextImpl::DeleteDataModifiedSince(const base::Time& cutoff) {
cutoff));
}
+void DOMStorageContextImpl::DoomSessionStorage(int64 namespace_id) {
+ DCHECK(context_);
+ context_->task_runner()->PostShutdownBlockingTask(
+ FROM_HERE,
+ DomStorageTaskRunner::PRIMARY_SEQUENCE,
+ base::Bind(&DomStorageContext::DoomSessionStorage, context_,
+ namespace_id));
+}
+
+content::SessionStorageNamespace* DOMStorageContextImpl::CreateSessionStorage(
+ const std::string& persistent_id) {
+ return new SessionStorageNamespaceImpl(this, persistent_id);
+}
+
void DOMStorageContextImpl::PurgeMemory() {
DCHECK(context_);
context_->task_runner()->PostShutdownBlockingTask(
@@ -179,9 +195,10 @@ int64 DOMStorageContextImpl::LeakyCloneSessionStorage(
int64 existing_namespace_id) {
DCHECK(context_);
int64 clone_id = context_->AllocateSessionId();
+ std::string clone_persistent_id = context_->AllocatePersistentSessionId();
context_->task_runner()->PostTask(
FROM_HERE,
base::Bind(&DomStorageContext::CloneSessionNamespace, context_,
- existing_namespace_id, clone_id));
+ existing_namespace_id, clone_id, clone_persistent_id));
return clone_id;
}

Powered by Google App Engine
This is Rietveld 408576698