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

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

Issue 10850010: Make session restore understand that tabs have multiple SessionStorageNamespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: attempt to fix unittsets. Created 8 years, 4 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 9dbb0c909e3a181abe0200b5428e81df77c70608..9b5531a9d5f15ad9f933c3dab3079a6aef6a30d0 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -618,17 +618,22 @@ void SessionService::Observe(int type,
// Record the association between the SessionStorageNamespace and the
// tab.
- //
- // TODO(ajwong): This should be processing the whole map rather than
- // just the default. This in particular will not work for tabs with only
- // isolated apps which won't have a default partition.
- content::SessionStorageNamespace* session_storage_namespace =
- tab->web_contents()->GetController().
- GetDefaultSessionStorageNamespace();
- ScheduleCommand(CreateSessionStorageAssociatedCommand(
- tab->restore_tab_helper()->session_id(),
- session_storage_namespace->persistent_id()));
- session_storage_namespace->SetShouldPersist(true);
+ // Record the association between all the SessionStorageNamespaces and
+ // their containing tab.
+ const content::SessionStorageNamespaceMap& session_storage_namespace_map =
+ tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
+ LOG(ERROR) << "Associating map of size " << session_storage_namespace_map.size();
+ for (content::SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map.begin();
+ it != session_storage_namespace_map.end();
+ ++it) {
+ LOG(ERROR) << "Associating --" << it->first << "++ with --" << it->second->persistent_id();
+ ScheduleCommand(CreateSessionStorageAssociatedCommand(
+ tab->restore_tab_helper()->session_id(),
+ it->second->persistent_id(),
+ it->first));
+ it->second->SetShouldPersist(true);
+ }
break;
}
@@ -638,10 +643,14 @@ void SessionService::Observe(int type,
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().
- GetDefaultSessionStorageNamespace();
- session_storage_namespace->SetShouldPersist(false);
+ const content::SessionStorageNamespaceMap& session_storage_namespace_map =
+ tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
+ for (content::SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map.begin();
+ it != session_storage_namespace_map.end();
+ ++it) {
+ it->second->SetShouldPersist(false);
+ }
TabClosed(tab->restore_tab_helper()->window_id(),
tab->restore_tab_helper()->session_id(),
tab->web_contents()->GetClosedByUserGesture());
@@ -863,10 +872,12 @@ SessionCommand* SessionService::CreatePinnedStateCommand(
SessionCommand* SessionService::CreateSessionStorageAssociatedCommand(
const SessionID& tab_id,
- const std::string& session_storage_persistent_id) {
+ const std::string& session_storage_persistent_id,
+ const std::string& partiton_id) {
Pickle pickle;
pickle.WriteInt(tab_id.id());
pickle.WriteString(session_storage_persistent_id);
+ pickle.WriteString(partiton_id);
return new SessionCommand(kCommandSessionStorageAssociated, pickle);
}
@@ -1270,13 +1281,16 @@ bool SessionService::CreateTabsAndWindows(
scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle());
SessionID::id_type command_tab_id;
std::string session_storage_persistent_id;
+ std::string partition_id;
PickleIterator iter(*command_pickle.get());
if (!command_pickle->ReadInt(&iter, &command_tab_id) ||
- !command_pickle->ReadString(&iter, &session_storage_persistent_id))
- return true;
+ !command_pickle->ReadString(&iter, &session_storage_persistent_id) ||
+ !command_pickle->ReadString(&iter, &partition_id))
+ continue; // We can safely just lose SessionStorage on a restore.
// Associate the session storage back.
- GetTab(command_tab_id, tabs)->session_storage_persistent_id =
- session_storage_persistent_id;
+ GetTab(command_tab_id, tabs)->
+ session_storage_persistent_id_map[partition_id] =
+ session_storage_persistent_id;
break;
}
@@ -1350,12 +1364,19 @@ void SessionService::BuildCommandsForTab(
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().GetDefaultSessionStorageNamespace();
- ScheduleCommand(CreateSessionStorageAssociatedCommand(
- tab->restore_tab_helper()->session_id(),
- session_storage_namespace->persistent_id()));
+ // Record the association between the SessionStorageNamespaces and the tab.
+ const content::SessionStorageNamespaceMap& session_storage_namespace_map =
+ tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
+ for (content::SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map.begin();
+ it != session_storage_namespace_map.end();
+ ++it) {
+ // TODO(ajwong): Again I wonder if we should do this?
+ it->second->SetShouldPersist(true);
+ ScheduleCommand(CreateSessionStorageAssociatedCommand(
+ tab->restore_tab_helper()->session_id(),
+ it->second->persistent_id(), it->first));
+ }
}
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