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

Unified Diff: chrome/browser/sessions/session_service.cc

Issue 10572015: Session restore: Store and restore persistent IDs for sessionStorage. (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
« no previous file with comments | « chrome/browser/sessions/session_service.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_service.cc
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index b97b6a2800879417d78e3fbb9501b78c20e221ef..183523b2ddde6ff44a788e1f93b39ec70cab4851 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -37,6 +37,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/session_storage_namespace.h"
#include "content/public/browser/web_contents.h"
#if defined(OS_MACOSX)
@@ -72,6 +73,7 @@ static const SessionCommand::id_type kCommandSetWindowAppName = 15;
static const SessionCommand::id_type kCommandTabClosed = 16;
static const SessionCommand::id_type kCommandWindowClosed = 17;
static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18;
+static const SessionCommand::id_type kCommandSessionStorageAssociated = 19;
// Every kWritesPerReset commands triggers recreating the file.
static const int kWritesPerReset = 250;
@@ -599,6 +601,15 @@ void SessionService::Observe(int type,
tab->restore_tab_helper()->session_id(),
tab->extension_tab_helper()->extension_app()->id());
}
+
+ // Record the association between the SessionStorageNamespace and the
+ // tab.
+ content::SessionStorageNamespace* session_storage_namespace =
+ tab->web_contents()->GetController().GetSessionStorageNamespace();
+ ScheduleCommand(CreateSessionStorageAssociatedCommand(
+ tab->restore_tab_helper()->session_id(),
+ session_storage_namespace->persistent_id()));
+ session_storage_namespace->SetShouldPersist(true);
break;
}
@@ -606,6 +617,11 @@ void SessionService::Observe(int type,
TabContents* tab = content::Source<TabContents>(source).ptr();
if (!tab || tab->profile() != profile())
return;
+ // Allow the associated sessionStorage to get deleted; it won't be needed
+ // in the session restore.
+ content::SessionStorageNamespace* session_storage_namespace =
+ tab->web_contents()->GetController().GetSessionStorageNamespace();
+ session_storage_namespace->SetShouldPersist(false);
TabClosed(tab->restore_tab_helper()->window_id(),
tab->restore_tab_helper()->session_id(),
tab->web_contents()->GetClosedByUserGesture());
@@ -838,6 +854,15 @@ SessionCommand* SessionService::CreatePinnedStateCommand(
return command;
}
+SessionCommand* SessionService::CreateSessionStorageAssociatedCommand(
+ const SessionID& tab_id,
+ const std::string& session_storage_persistent_id) {
+ Pickle pickle;
+ pickle.WriteInt(tab_id.id());
+ pickle.WriteString(session_storage_persistent_id);
+ return new SessionCommand(kCommandSessionStorageAssociated, pickle);
+}
+
void SessionService::OnGotSessionCommands(
Handle handle,
scoped_refptr<InternalGetCommandsRequest> request) {
@@ -1234,6 +1259,20 @@ bool SessionService::CreateTabsAndWindows(
break;
}
+ case kCommandSessionStorageAssociated: {
+ scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle());
+ SessionID::id_type command_tab_id;
+ std::string session_storage_persistent_id;
+ PickleIterator iter(*command_pickle.get());
+ if (!command_pickle->ReadInt(&iter, &command_tab_id) ||
+ !command_pickle->ReadString(&iter, &session_storage_persistent_id))
+ return false;
michaeln 2012/06/20 18:09:11 The comment up top says... // If the file is corru
marja 2012/06/22 10:37:02 Done.
+ // Associate the session storage back.
+ GetTab(command_tab_id, tabs)->session_storage_persistent_id =
+ session_storage_persistent_id;
+ break;
+ }
+
default:
VLOG(1) << "Failed reading an unknown command " << command->id();
return true;
@@ -1303,6 +1342,13 @@ void SessionService::BuildCommandsForTab(
commands->push_back(
CreateSetTabIndexInWindowCommand(session_id, index_in_window));
}
+
+ // Record the association between the sessionStorage namespace and the tab.
+ content::SessionStorageNamespace* session_storage_namespace =
+ tab->web_contents()->GetController().GetSessionStorageNamespace();
+ ScheduleCommand(CreateSessionStorageAssociatedCommand(
+ tab->restore_tab_helper()->session_id(),
+ session_storage_namespace->persistent_id()));
}
void SessionService::BuildCommandsForBrowser(
« no previous file with comments | « chrome/browser/sessions/session_service.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698