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

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

Issue 8929007: Restore sessionStorage when chrome restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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_context.cc
diff --git a/content/browser/in_process_webkit/dom_storage_context.cc b/content/browser/in_process_webkit/dom_storage_context.cc
index 065d8cff7d8905283ddbe57b258619e5f6766a83..95a5074a4dbcec80fb3f862c103741fcbd2342df 100644
--- a/content/browser/in_process_webkit/dom_storage_context.cc
+++ b/content/browser/in_process_webkit/dom_storage_context.cc
@@ -52,6 +52,9 @@ void ClearLocalState(const FilePath& domstorage_path,
const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] =
FILE_PATH_LITERAL("Local Storage");
+const FilePath::CharType DOMStorageContext::kSessionStorageDirectory[] =
+ FILE_PATH_LITERAL("Session Storage");
+
const FilePath::CharType DOMStorageContext::kLocalStorageExtension[] =
FILE_PATH_LITERAL(".localstorage");
@@ -164,6 +167,20 @@ DOMStorageNamespace* DOMStorageContext::GetStorageNamespace(
return CreateSessionStorage(id);
}
+DOMStorageNamespace* DOMStorageContext::RecreateSessionStorageNamespace(
+ int64 id,
+ const FilePath& session_storage_directory) {
+ FilePath dir_path;
+ if (!data_path_.empty()) {
+ dir_path = data_path_.Append(kSessionStorageDirectory)
michaeln 2011/12/13 20:40:03 in what circumstances is data_path_ empty, i'm gue
marja 2012/01/11 15:17:53 Yes.
+ .Append(session_storage_directory);
+ }
+ DOMStorageNamespace* new_namespace =
+ DOMStorageNamespace::CreateSessionStorageNamespace(this, dir_path, id);
+ RegisterStorageNamespace(new_namespace);
+ return new_namespace;
+}
+
void DOMStorageContext::RegisterMessageFilter(
DOMStorageMessageFilter* message_filter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -265,8 +282,18 @@ DOMStorageNamespace* DOMStorageContext::CreateLocalStorage() {
DOMStorageNamespace* DOMStorageContext::CreateSessionStorage(
int64 namespace_id) {
+ FilePath dir_path;
+ if (!data_path_.empty()) {
+ // We cannot use derive the directory name for the sessionStorage databases
jochen (gone - plz use gerrit) 2011/12/13 13:47:32 remove "use"
marja 2012/01/11 15:17:53 Done.
+ // directly from |namespace_id|. There is no guarantee that the same
+ // directory won't be created before we restore the session.
michaeln 2011/12/13 20:40:03 can you say more about the latter part of the comm
marja 2012/01/11 15:17:53 This was inaccurate, changed it to "There is no gu
+ file_util::CreateDirectory(data_path_.Append(kSessionStorageDirectory));
+ file_util::CreateTemporaryDirInDir(
+ data_path_.Append(kSessionStorageDirectory), "", &dir_path);
michaeln 2011/12/13 20:40:03 where/when are these directories deleted?
marja 2012/01/11 15:17:53 The deletion code is not yet in this CL, but the d
+ }
DOMStorageNamespace* new_namespace =
- DOMStorageNamespace::CreateSessionStorageNamespace(this, namespace_id);
+ DOMStorageNamespace::CreateSessionStorageNamespace(this, dir_path,
+ namespace_id);
RegisterStorageNamespace(new_namespace);
return new_namespace;
}

Powered by Google App Engine
This is Rietveld 408576698