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

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: Rebased, with test robustified. 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 caf5475a627844324d056f94c845f3d3cb57e56a..63fcf3ee8d33f260668bd1ccf4ccf1f21e9cc49a 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -603,15 +603,19 @@ void SessionService::Observe(int type,
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().GetSessionStorageNamespaceMap()
- .find("")->second;
- 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();
michaeln 2012/08/08 22:29:30 Looks like namespaces for isolated-apps can be add
+ for (content::SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map.begin();
+ it != session_storage_namespace_map.end();
+ ++it) {
+ ScheduleCommand(CreateSessionStorageAssociatedCommand(
+ tab->restore_tab_helper()->session_id(),
+ it->second->persistent_id(), it->first));
+ it->second->SetShouldPersist(true);
+ }
break;
}
@@ -619,12 +623,16 @@ 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().GetSessionStorageNamespaceMap()
- .find("")->second;
- session_storage_namespace->SetShouldPersist(false);
+ // Allow the associated SessionStorageNamespaces to be deleted; they won't
+ // be needed in the session restore.
+ 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());
@@ -859,10 +867,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& partition_id) {
Pickle pickle;
pickle.WriteInt(tab_id.id());
pickle.WriteString(session_storage_persistent_id);
+ pickle.WriteString(partition_id);
return new SessionCommand(kCommandSessionStorageAssociated, pickle);
}
@@ -1266,13 +1276,19 @@ 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());
+ // TODO(ajwong): Is it okay to just skip this command and proceed with
+ // the rest of session restore?
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; // If the storage is corrupt, just ignore it.
// 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;
}
@@ -1346,13 +1362,18 @@ 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().GetSessionStorageNamespaceMap()
- .find("")->second;
- 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) {
+ 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