diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 09:36:07 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 09:36:07 +0000 |
commit | 6ee12c40c7888500e87b33fb1993faf3d689eb09 (patch) | |
tree | 5db10a6c2c6d5466f906952d3c87f5c4534bf685 /chrome/browser/sessions | |
parent | c0f533f2784bb98483b29d68609a5118dd86c92a (diff) | |
download | chromium_src-6ee12c40c7888500e87b33fb1993faf3d689eb09.zip chromium_src-6ee12c40c7888500e87b33fb1993faf3d689eb09.tar.gz chromium_src-6ee12c40c7888500e87b33fb1993faf3d689eb09.tar.bz2 |
Fix SessionStorage
Apparently the session storage code was pretty horribly broken. It didn't correctly handle tabs being restored, didn't have the proper lifetime (this was the issue exposed in the bug), and had many leaks.
To fix this, things had to be plumbed fairly differently. We need to pass session storage in on TabContents creation to ensure that the first RenderView will have the correct session storage id. When closing a tab, we need to save the session storage with the restoration service. When restoring a tab, we pass it back into the tab contents class. When duplicating a tab, we clone the storage.
Lifetimes are now handled by standard reference counting code. A SessionStorageNamespace object wraps an ID. When it's instantiated, it allocates an ID. When it's destroyed, it deletes the ID. IDs make this process very lightweight (the heavyweight stuff is allocated on first use of SessionStorage) and it seperates the more complex lifetimes of SessionStorage namespaces (where less deterministic shutdown is more tollerable) from the LocalStorage namespace which needs to shutdown very precisely.
BUG=52393
TEST=Set some variable on session storage; close the tab; re-open the tab; the variable should still be set. You can also run through the repro steps in the bug.
Review URL: http://codereview.chromium.org/3325012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions')
-rw-r--r-- | chrome/browser/sessions/session_restore.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.cc | 11 | ||||
-rw-r--r-- | chrome/browser/sessions/tab_restore_service.h | 6 |
3 files changed, 15 insertions, 5 deletions
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 9a20e65..ab3b4a7 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -518,7 +518,8 @@ class SessionRestoreImpl : public NotificationObserver { tab.extension_app_id, false, tab.pinned, - true)->controller()); + true, + NULL)->controller()); } } diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index c62312a..23b7470 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -338,7 +338,8 @@ void TabRestoreService::RestoreEntryById(Browser* browser, tab.extension_app_id, (static_cast<int>(tab_i) == window->selected_tab_index), - tab.pinned, tab.from_last_session); + tab.pinned, tab.from_last_session, + tab.session_storage_namespace); if (restored_tab) restored_tab->controller().LoadIfNecessary(); } @@ -476,6 +477,8 @@ void TabRestoreService::PopulateTab(Tab* tab, if (extension) tab->extension_app_id = extension->id(); + tab->session_storage_namespace = controller->session_storage_namespace(); + // Browser may be NULL during unit tests. if (browser) { tab->browser_id = browser->session_id().id(); @@ -866,7 +869,8 @@ Browser* TabRestoreService::RestoreTab(const Tab& tab, browser->ReplaceRestoredTab(tab.navigations, tab.current_navigation_index, tab.from_last_session, - tab.extension_app_id); + tab.extension_app_id, + tab.session_storage_namespace); } else { if (tab.has_browser()) browser = BrowserList::FindBrowserWithID(tab.browser_id); @@ -889,7 +893,8 @@ Browser* TabRestoreService::RestoreTab(const Tab& tab, tab_index, tab.current_navigation_index, tab.extension_app_id, - true, tab.pinned, tab.from_last_session); + true, tab.pinned, tab.from_last_session, + tab.session_storage_namespace); } return browser; } diff --git a/chrome/browser/sessions/tab_restore_service.h b/chrome/browser/sessions/tab_restore_service.h index 2f9a237..48c9dab 100644 --- a/chrome/browser/sessions/tab_restore_service.h +++ b/chrome/browser/sessions/tab_restore_service.h @@ -12,6 +12,7 @@ #include "base/observer_list.h" #include "base/time.h" +#include "chrome/browser/in_process_webkit/session_storage_namespace.h" #include "chrome/browser/sessions/base_session_service.h" #include "chrome/browser/sessions/session_id.h" #include "chrome/browser/sessions/session_types.h" @@ -19,8 +20,8 @@ class Browser; class NavigationController; class Profile; -struct SessionWindow; class TabRestoreServiceObserver; +struct SessionWindow; // TabRestoreService is responsible for maintaining the most recently closed // tabs and windows. When a tab is closed @@ -94,6 +95,9 @@ class TabRestoreService : public BaseSessionService { // If non-empty gives the id of the extension for the tab. std::string extension_app_id; + + // The associated session storage namespace (if any). + scoped_refptr<SessionStorageNamespace> session_storage_namespace; }; // Represents a previously open window. |