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

Unified Diff: content/browser/in_process_webkit/dom_storage_namespace.cc

Issue 8929007: Restore sessionStorage when chrome restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix: cloning storage areas. Created 8 years, 11 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/in_process_webkit/dom_storage_namespace.cc
diff --git a/content/browser/in_process_webkit/dom_storage_namespace.cc b/content/browser/in_process_webkit/dom_storage_namespace.cc
index 508786f1aaf58d7d8ba23b01793775028de8a052..1be4142ceac36479464043c88a47add389e78bef 100644
--- a/content/browser/in_process_webkit/dom_storage_namespace.cc
+++ b/content/browser/in_process_webkit/dom_storage_namespace.cc
@@ -21,24 +21,29 @@ DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace(
DOMStorageContext* dom_storage_context, const FilePath& data_dir_path) {
int64 id = kLocalStorageNamespaceId;
DCHECK(!dom_storage_context->GetStorageNamespace(id, false));
- return new DOMStorageNamespace(dom_storage_context, id,
+ return new DOMStorageNamespace(dom_storage_context, id, FilePath(""),
webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_LOCAL);
}
/* static */
DOMStorageNamespace* DOMStorageNamespace::CreateSessionStorageNamespace(
- DOMStorageContext* dom_storage_context, int64 id) {
+ DOMStorageContext* dom_storage_context, const FilePath& data_dir_path,
+ int64 id) {
DCHECK(!dom_storage_context->GetStorageNamespace(id, false));
- return new DOMStorageNamespace(dom_storage_context, id, WebString(),
- DOM_STORAGE_SESSION);
+ return new DOMStorageNamespace(
+ dom_storage_context, id, data_dir_path.BaseName(),
+ webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_SESSION);
}
-DOMStorageNamespace::DOMStorageNamespace(DOMStorageContext* dom_storage_context,
- int64 id,
- const WebString& data_dir_path,
- DOMStorageType dom_storage_type)
+DOMStorageNamespace::DOMStorageNamespace(
+ DOMStorageContext* dom_storage_context,
+ int64 id,
+ const FilePath& session_storage_directory,
+ const WebString& data_dir_path,
+ DOMStorageType dom_storage_type)
: dom_storage_context_(dom_storage_context),
id_(id),
+ session_storage_directory_(session_storage_directory),
data_dir_path_(data_dir_path),
dom_storage_type_(dom_storage_type) {
DCHECK(dom_storage_context_);
@@ -73,7 +78,8 @@ DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) {
DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION);
DCHECK(!dom_storage_context_->GetStorageNamespace(id, false));
DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace(
- dom_storage_context_, id, data_dir_path_, dom_storage_type_);
+ dom_storage_context_, id, session_storage_directory_, data_dir_path_,
+ dom_storage_type_);
// If we haven't used the namespace yet, there's nothing to copy.
if (storage_namespace_.get())
new_storage_namespace->storage_namespace_.reset(storage_namespace_->copy());
@@ -81,7 +87,6 @@ DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) {
}
void DOMStorageNamespace::PurgeMemory() {
- DCHECK(dom_storage_type_ == DOM_STORAGE_LOCAL);
for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin());
iter != origin_to_storage_area_.end(); ++iter)
iter->second->PurgeMemory();
@@ -94,16 +99,39 @@ WebStorageArea* DOMStorageNamespace::CreateWebStorageArea(
return storage_namespace_->createStorageArea(origin);
}
+void DOMStorageNamespace::CopyDataTo(DOMStorageNamespace* other) {
+ for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin());
+ iter != origin_to_storage_area_.end(); ++iter) {
+ DOMStorageArea* to_area = other->GetStorageArea(iter->first);
+ DCHECK(to_area);
+ iter->second->CopyDataTo(to_area);
+ }
+}
+
void DOMStorageNamespace::CreateWebStorageNamespaceIfNecessary() {
if (storage_namespace_.get())
return;
- if (dom_storage_type_ == DOM_STORAGE_LOCAL) {
- storage_namespace_.reset(
- WebStorageNamespace::createLocalStorageNamespace(data_dir_path_,
- WebStorageNamespace::m_localStorageQuota));
- } else {
+ // From WebKit point of view, also sessionStorage is localStorage, since we
+ // want to save it on disk. (Except for incognito.)
+ if (dom_storage_type_ == DOM_STORAGE_SESSION &&
+ data_dir_path_.isEmpty()) {
storage_namespace_.reset(WebStorageNamespace::createSessionStorageNamespace(
WebStorageNamespace::m_sessionStorageQuota));
+ } else {
+ storage_namespace_.reset(
+ WebStorageNamespace::createLocalStorageNamespace(
+ data_dir_path_,
+ WebStorageNamespace::m_localStorageQuota));
}
}
+
+SessionStorageCreatedDetails::SessionStorageCreatedDetails() { }
+
+SessionStorageCreatedDetails::SessionStorageCreatedDetails(
+ int64 id,
+ const FilePath& session_storage_directory)
+ : id(id),
+ session_storage_directory(session_storage_directory) { }
+
+SessionStorageCreatedDetails::~SessionStorageCreatedDetails() { }
« no previous file with comments | « content/browser/in_process_webkit/dom_storage_namespace.h ('k') | content/browser/in_process_webkit/webkit_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698