Index: chrome/browser/sessions/session_service.cc |
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc |
index 343a8985fb22ff4d4bff01428c049e77ffb5b8a6..ba9b5a67c16ecaa4bff819634686fb3990605585 100644 |
--- a/chrome/browser/sessions/session_service.cc |
+++ b/chrome/browser/sessions/session_service.cc |
@@ -33,10 +33,12 @@ |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
+#include "content/public/browser/dom_storage_context.h" |
#include "content/public/browser/navigation_details.h" |
#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 +74,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; |
@@ -600,6 +603,14 @@ void SessionService::Observe(int type, |
tab->restore_tab_helper()->session_id(), |
tab->extension_tab_helper()->extension_app()->id()); |
} |
+ |
+ // 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())); |
break; |
} |
@@ -608,6 +619,12 @@ void SessionService::Observe(int type, |
content::Source<TabContentsWrapper>(source).ptr(); |
if (!tab || tab->profile() != profile()) |
return; |
+ // Allow the associated sessionStorage to get deleted; it won't be needed |
+ // in the session restore. |
michaeln
2012/06/08 01:04:21
I see that NOTIFICATION_TAB_CONTENTS_DESTROYED hap
marja
2012/06/19 13:17:17
Did the SetShouldPersist change; it's cleaner now.
|
+ content::SessionStorageNamespace* session_storage_namespace = |
+ tab->web_contents()->GetController().GetSessionStorageNamespace(); |
+ content::BrowserContext::GetDOMStorageContext(profile())-> |
+ DoomSessionStorage(session_storage_namespace->persistent_id()); |
TabClosed(tab->restore_tab_helper()->window_id(), |
tab->restore_tab_helper()->session_id(), |
tab->web_contents()->GetClosedByUserGesture()); |
@@ -843,6 +860,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) { |
@@ -1239,6 +1265,19 @@ bool SessionService::CreateTabsAndWindows( |
break; |
} |
+ case kCommandSessionStorageAssociated: { |
+ scoped_ptr<Pickle> pickle(command->PayloadAsPickle()); |
+ SessionID::id_type tab_id; |
+ std::string session_storage_persistent_id; |
+ PickleIterator iter(*pickle.get()); |
+ pickle->ReadInt(&iter, &tab_id); |
+ pickle->ReadString(&iter, &session_storage_persistent_id); |
+ // Associate the session storage back. |
+ GetTab(tab_id, tabs)->session_storage_persistent_id = |
+ session_storage_persistent_id; |
+ break; |
+ } |
+ |
default: |
VLOG(1) << "Failed reading an unknown command " << command->id(); |
return true; |
@@ -1310,6 +1349,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( |