Index: chrome/browser/sessions/session_service.cc |
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc |
index 5e8bf8e74fda0889afcd478cc2367c8a3513e4f5..90706bafb2c781164c564103a1afacf0ac90bde1 100644 |
--- a/chrome/browser/sessions/session_service.cc |
+++ b/chrome/browser/sessions/session_service.cc |
@@ -18,6 +18,7 @@ |
#include "base/metrics/histogram.h" |
#include "base/pickle.h" |
#include "base/threading/thread.h" |
+#include "content/browser/dom_storage/session_storage_namespace_impl.h" |
michaeln
2012/05/30 01:29:19
we shouldn't be using interfaces that aren't in th
marja
2012/05/31 14:41:34
Removed this, but now session_restore needs to inc
|
#include "chrome/browser/extensions/extension_tab_helper.h" |
#include "chrome/browser/prefs/session_startup_pref.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -37,6 +38,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 +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; |
@@ -522,6 +525,8 @@ void SessionService::Init() { |
registrar_.Add( |
this, chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, |
content::NotificationService::AllSources()); |
+ registrar_.Add(this, content::NOTIFICATION_SESSION_STORAGE_ASSOCIATED, |
+ content::NotificationService::AllSources()); |
} |
bool SessionService::ShouldNewWindowStartSession() { |
@@ -600,6 +605,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(); |
+ session_storage_id_to_tab_[session_storage_namespace->id()] = |
+ std::make_pair(tab->restore_tab_helper()->window_id(), |
+ tab->restore_tab_helper()->session_id()); |
break; |
} |
@@ -700,6 +713,16 @@ void SessionService::Observe(int type, |
break; |
} |
+ case content::NOTIFICATION_SESSION_STORAGE_ASSOCIATED: { |
+ // FIXME: Read the association also when recreating the window & tab data. |
+ content::Details<SessionStorageAssociatedDetails> |
+ session_storage_associated_details(details); |
+ CreateAndScheduleSessionStorageAssociatedCommand( |
+ session_storage_associated_details->id, |
+ session_storage_associated_details->real_id); |
+ break; |
+ } |
+ |
default: |
NOTREACHED(); |
} |
@@ -846,6 +869,19 @@ SessionCommand* SessionService::CreatePinnedStateCommand( |
return command; |
} |
+void SessionService::CreateAndScheduleSessionStorageAssociatedCommand( |
+ int64 id, int64 real_id) { |
+ SessionStorageIdToTab::const_iterator it = |
+ session_storage_id_to_tab_.find(id); |
+ if (it == session_storage_id_to_tab_.end()) |
+ return; |
+ Pickle pickle; |
+ pickle.WriteInt(it->second.first.id()); |
+ pickle.WriteInt(it->second.second.id()); |
+ pickle.WriteInt64(real_id); |
+ ScheduleCommand(new SessionCommand(kCommandSessionStorageAssociated, pickle)); |
+} |
+ |
void SessionService::OnGotSessionCommands( |
Handle handle, |
scoped_refptr<InternalGetCommandsRequest> request) { |
@@ -1242,6 +1278,21 @@ bool SessionService::CreateTabsAndWindows( |
break; |
} |
+ case kCommandSessionStorageAssociated: { |
+ scoped_ptr<Pickle> pickle(command->PayloadAsPickle()); |
+ SessionID::id_type window_id; |
+ SessionID::id_type tab_id; |
+ int64 session_storage_id; |
+ PickleIterator iter(*pickle.get()); |
+ pickle->ReadInt(&iter, &window_id); |
+ pickle->ReadInt(&iter, &tab_id); |
+ pickle->ReadInt64(&iter, &session_storage_id); |
+ // Associate the session storage back. |
+ GetTab(tab_id, tabs)->session_storage_real_id = session_storage_id; |
+ GetTab(tab_id, tabs)->session_storage_real_id_associated = true; |
+ break; |
+ } |
+ |
default: |
VLOG(1) << "Failed reading an unknown command " << command->id(); |
return true; |