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

Unified Diff: chrome/browser/sessions/session_service.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: chrome/browser/sessions/session_service.cc
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index e60d30e51d98f971c60ce634f8dd64013baeba2c..f99af8160c3b988750eb0997a1c2d9ca7b57d2e6 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -32,6 +32,8 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
+#include "content/browser/in_process_webkit/dom_storage_namespace.h"
+#include "content/browser/in_process_webkit/session_storage_namespace.h"
#include "content/browser/tab_contents/navigation_details.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -64,6 +66,7 @@ static const SessionCommand::id_type
static const SessionCommand::id_type kCommandSetPinnedState = 12;
static const SessionCommand::id_type kCommandSetExtensionAppID = 13;
static const SessionCommand::id_type kCommandSetWindowBounds3 = 14;
+static const SessionCommand::id_type kCommandSessionStorageCreated = 15;
// Every kWritesPerReset commands triggers recreating the file.
static const int kWritesPerReset = 250;
@@ -455,6 +458,8 @@ void SessionService::Init() {
registrar_.Add(
this, chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
content::NotificationService::AllSources());
+ registrar_.Add(this, content::NOTIFICATION_DOM_STORAGE_NAMESPACE_CREATED,
+ content::NotificationService::AllSources());
}
bool SessionService::ShouldNewWindowStartSession() {
@@ -517,6 +522,15 @@ void SessionService::Observe(int type,
content::Source<TabContentsWrapper>(source).ptr();
if (tab->profile() != profile())
return;
+
+ // Record the association between the sessionStorage namespace and the
+ // tab.
+ SessionStorageNamespace* session_storage_namespace =
+ tab->tab_contents()->controller().session_storage_namespace();
+ session_storage_namespace_map_[session_storage_namespace->id()] =
+ std::make_pair(tab->restore_tab_helper()->window_id(),
+ tab->restore_tab_helper()->session_id());
+
SetTabWindow(tab->restore_tab_helper()->window_id(),
tab->restore_tab_helper()->session_id());
if (tab->extension_tab_helper()->extension_app()) {
@@ -625,6 +639,24 @@ void SessionService::Observe(int type,
break;
}
+ case content::NOTIFICATION_DOM_STORAGE_NAMESPACE_CREATED: {
+ content::Details<DOMStorageNamespaceCreatedDetails>
+ namespace_created_details(details);
+
+ SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map_.find(namespace_created_details->id);
+ if (it != session_storage_namespace_map_.end()) {
+ Pickle session_storage_created_pickle;
+ session_storage_created_pickle.WriteInt(it->second.first.id());
+ session_storage_created_pickle.WriteInt(it->second.second.id());
+ session_storage_created_pickle.WriteString(
+ namespace_created_details->session_storage_directory.value());
+ ScheduleCommand(new SessionCommand(kCommandSessionStorageCreated,
michaeln 2011/12/13 20:40:03 I'm not at all familiar with this SessionService c
marja 2012/01/11 15:17:53 ScheduleCommand puts the command into a queue and
+ session_storage_created_pickle));
+ }
+ break;
+ }
+
default:
NOTREACHED();
}
@@ -1095,6 +1127,19 @@ bool SessionService::CreateTabsAndWindows(
GetTab(tab_id, tabs)->extension_app_id.swap(extension_app_id);
break;
}
+ case kCommandSessionStorageCreated: {
+ scoped_ptr<Pickle> pickle(command->PayloadAsPickle());
+ SessionID::id_type window_id;
+ SessionID::id_type tab_id;
+ std::string session_storage_directory;
+ void* iter = NULL;
+ pickle->ReadInt(&iter, &window_id);
+ pickle->ReadInt(&iter, &tab_id);
+ pickle->ReadString(&iter, &session_storage_directory);
+ GetTab(tab_id, tabs)->session_storage_directory =
+ FilePath(session_storage_directory);
+ break;
+ }
default:
return true;

Powered by Google App Engine
This is Rietveld 408576698