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

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 117c47acfa01762a1e8f4eac24921371946b2075..a9106ba3dbe9a3834c37a915e16fd2bae795c63d 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -6,7 +6,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.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 +28,7 @@ using webkit_database::DatabaseUtil;
namespace {
const char kLocalStorageDirectory[] = "Local Storage";
+const char kSessionStorageDirectory[] = "Session Storage";
void InvokeUsageInfoCallbackHelper(
const DOMStorageContext::GetUsageInfoCallback& callback,
@@ -100,12 +103,16 @@ DOMStorageContextImpl::DOMStorageContextImpl(
const FilePath& data_path,
quota::SpecialStoragePolicy* special_storage_policy) {
base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
- // TODO(marja): Pass a nonempty session storage directory when session storage
- // is backed on disk.
+ // TODO(marja): Remove this as soon as the sessionStorage on disk
+ // implementation is on by default.
+ const char kEnableRestoreSessionState[] = "enable-restore-session-state";
+ bool session_storage_on_disk =
+ CommandLine::ForCurrentProcess()->HasSwitch(kEnableRestoreSessionState);
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,
@@ -170,6 +177,23 @@ void DOMStorageContextImpl::DeleteLocalStorageFile(const FilePath& file_path) {
FilePathToOrigin(file_path)));
}
+void DOMStorageContextImpl::DoomSessionStorage(
+ const std::string& persistent_namespace_id) {
+ DCHECK(context_);
+ context_->task_runner()->PostShutdownBlockingTask(
+ FROM_HERE,
+ DomStorageTaskRunner::PRIMARY_SEQUENCE,
+ base::Bind(&DomStorageContext::DoomSessionStorage, context_,
+ persistent_namespace_id));
+}
+
+scoped_refptr<content::SessionStorageNamespace>
+DOMStorageContextImpl::RecreateSessionStorage(
+ const std::string& persistent_id) {
+ return scoped_refptr<content::SessionStorageNamespace>(
+ new SessionStorageNamespaceImpl(this, persistent_id));
+}
+
void DOMStorageContextImpl::PurgeMemory() {
DCHECK(context_);
context_->task_runner()->PostShutdownBlockingTask(

Powered by Google App Engine
This is Rietveld 408576698