diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-20 01:06:30 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-20 01:06:30 +0000 |
commit | fdac6adeae4bd9a79b4d93d006d96ac2bd902bde (patch) | |
tree | de319c63b9d50a17de408b7f4daf12da1a8c0329 /chrome | |
parent | 243f55f68ef7a32d3d1c7f11ff26dfcf5cdda112 (diff) | |
download | chromium_src-fdac6adeae4bd9a79b4d93d006d96ac2bd902bde.zip chromium_src-fdac6adeae4bd9a79b4d93d006d96ac2bd902bde.tar.gz chromium_src-fdac6adeae4bd9a79b4d93d006d96ac2bd902bde.tar.bz2 |
Revert "Fix SessionStorage confusion between RenderViewHostImpl and NavigationController."
Reason: There's something wrong with the StoragePartition cleanup, see comments in
https://codereview.chromium.org/19756002/.
BUG=
TBR=michaeln@chromium.org
Review URL: https://chromiumcodereview.appspot.com/19765009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
14 files changed, 57 insertions, 25 deletions
diff --git a/chrome/browser/extensions/activity_log/activity_log_browsertest.cc b/chrome/browser/extensions/activity_log/activity_log_browsertest.cc index 0b5ee0a..db573c1 100644 --- a/chrome/browser/extensions/activity_log/activity_log_browsertest.cc +++ b/chrome/browser/extensions/activity_log/activity_log_browsertest.cc @@ -95,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(ActivityLogPrerenderTest, TestScriptInjected) { scoped_ptr<prerender::PrerenderHandle> prerender_handle( prerender_manager->AddPrerenderFromLocalPredictor( url, - web_contents->GetController().GetSessionStorageNamespace(), + web_contents->GetController().GetDefaultSessionStorageNamespace(), kSize)); page_observer.Wait(); diff --git a/chrome/browser/extensions/activity_log/activity_log_unittest.cc b/chrome/browser/extensions/activity_log/activity_log_unittest.cc index 30b8d0a..4a7958e 100644 --- a/chrome/browser/extensions/activity_log/activity_log_unittest.cc +++ b/chrome/browser/extensions/activity_log/activity_log_unittest.cc @@ -249,7 +249,7 @@ TEST_F(ActivityLogTest, LogPrerender) { scoped_ptr<prerender::PrerenderHandle> prerender_handle( prerender_manager->AddPrerenderFromLocalPredictor( url, - web_contents()->GetController().GetSessionStorageNamespace(), + web_contents()->GetController().GetDefaultSessionStorageNamespace(), kSize)); const std::vector<content::WebContents*> contentses = @@ -271,3 +271,4 @@ TEST_F(ActivityLogTest, LogPrerender) { } } // namespace extensions + diff --git a/chrome/browser/predictors/autocomplete_action_predictor.cc b/chrome/browser/predictors/autocomplete_action_predictor.cc index 5a1e75b..2b9e732 100644 --- a/chrome/browser/predictors/autocomplete_action_predictor.cc +++ b/chrome/browser/predictors/autocomplete_action_predictor.cc @@ -138,7 +138,7 @@ void AutocompleteActionPredictor::ClearTransitionalMatches() { void AutocompleteActionPredictor::StartPrerendering( const GURL& url, - content::SessionStorageNamespace* session_storage_namespace, + const content::SessionStorageNamespaceMap& session_storage_namespace_map, const gfx::Size& size) { // Only cancel the old prerender after starting the new one, so if the URLs // are the same, the underlying prerender will be reused. @@ -146,6 +146,11 @@ void AutocompleteActionPredictor::StartPrerendering( prerender_handle_.release()); if (prerender::PrerenderManager* prerender_manager = prerender::PrerenderManagerFactory::GetForProfile(profile_)) { + content::SessionStorageNamespace* session_storage_namespace = NULL; + content::SessionStorageNamespaceMap::const_iterator it = + session_storage_namespace_map.find(std::string()); + if (it != session_storage_namespace_map.end()) + session_storage_namespace = it->second.get(); prerender_handle_.reset(prerender_manager->AddPrerenderFromOmnibox( url, session_storage_namespace, size)); } diff --git a/chrome/browser/predictors/autocomplete_action_predictor.h b/chrome/browser/predictors/autocomplete_action_predictor.h index 762d31a..b1c4f97 100644 --- a/chrome/browser/predictors/autocomplete_action_predictor.h +++ b/chrome/browser/predictors/autocomplete_action_predictor.h @@ -98,7 +98,7 @@ class AutocompleteActionPredictor // prerenders (if any). void StartPrerendering( const GURL& url, - content::SessionStorageNamespace* session_storage_namespace, + const content::SessionStorageNamespaceMap& session_storage_namespace_map, const gfx::Size& size); // Return true if the suggestion type warrants a TCP/IP preconnection. diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 36e7375..d95a0ad 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -640,7 +640,7 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest { current_browser()->tab_strip_model()->GetActiveWebContents(); if (!web_contents) return NULL; - return web_contents->GetController().GetSessionStorageNamespace(); + return web_contents->GetController().GetDefaultSessionStorageNamespace(); } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 6f7caf4..957809f 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -180,8 +180,9 @@ void PrerenderContents::PrepareForUse() { SessionStorageNamespace* session_storage_namespace = NULL; if (prerender_contents_) { + // TODO(ajwong): This does not correctly handle storage for isolated apps. session_storage_namespace = prerender_contents_-> - GetController().GetSessionStorageNamespace(); + GetController().GetDefaultSessionStorageNamespace(); } prerender_manager_->StartPendingPrerenders( child_id_, &pending_prerenders_, session_storage_namespace); @@ -473,8 +474,12 @@ size_t PrerenderContents::pending_prerender_count() const { WebContents* PrerenderContents::CreateWebContents( SessionStorageNamespace* session_storage_namespace) { + // TODO(ajwong): Remove the temporary map once prerendering is aware of + // multiple session storage namespaces per tab. + content::SessionStorageNamespaceMap session_storage_namespace_map; + session_storage_namespace_map[std::string()] = session_storage_namespace; return WebContents::CreateWithSessionStorage( - WebContents::CreateParams(profile_), session_storage_namespace); + WebContents::CreateParams(profile_), session_storage_namespace_map); } void PrerenderContents::NotifyPrerenderStart() { diff --git a/chrome/browser/prerender/prerender_local_predictor.cc b/chrome/browser/prerender/prerender_local_predictor.cc index 398a06f..93525f6 100644 --- a/chrome/browser/prerender/prerender_local_predictor.cc +++ b/chrome/browser/prerender/prerender_local_predictor.cc @@ -536,7 +536,7 @@ void PrerenderLocalPredictor::OnLookupURL( scoped_refptr<SessionStorageNamespace> session_storage_namespace = - source_web_contents->GetController().GetSessionStorageNamespace(); + source_web_contents->GetController().GetDefaultSessionStorageNamespace(); gfx::Rect container_bounds; source_web_contents->GetView()->GetContainerBounds(&container_bounds); @@ -883,7 +883,7 @@ void PrerenderLocalPredictor::OnTabHelperURLSeen( p->prerender_handle->Matches( url, web_contents->GetController(). - GetSessionStorageNamespace()); + GetDefaultSessionStorageNamespace()); } } if (best_matched_prerender) { diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 9cdeff0..7089c60 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -328,8 +328,10 @@ PrerenderHandle* PrerenderManager::AddPrerenderFromLinkRelPrerender( return NULL; if (source_web_contents->GetURL().host() == url.host()) origin = ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN; + // TODO(ajwong): This does not correctly handle storage for isolated apps. session_storage_namespace = - source_web_contents->GetController().GetSessionStorageNamespace(); + source_web_contents->GetController() + .GetDefaultSessionStorageNamespace(); } // If the prerender request comes from a recently cancelled prerender that @@ -411,8 +413,10 @@ bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents, DeleteOldEntries(); to_delete_prerenders_.clear(); + // TODO(ajwong): This doesn't handle isolated apps correctly. PrerenderData* prerender_data = FindPrerenderData( - url, web_contents->GetController().GetSessionStorageNamespace()); + url, + web_contents->GetController().GetDefaultSessionStorageNamespace()); if (!prerender_data) return false; DCHECK(prerender_data->contents()); diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 59945a7..6626bfe 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -1073,18 +1073,18 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorage) { ui_test_utils::NavigateToURL(browser(), url1_); content::NavigationController* controller = &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); - ASSERT_TRUE(controller->GetSessionStorageNamespace()); + ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); std::string session_storage_persistent_id = - controller->GetSessionStorageNamespace()->persistent_id(); + controller->GetDefaultSessionStorageNamespace()->persistent_id(); Browser* new_browser = QuitBrowserAndRestore(browser(), 1); ASSERT_EQ(1u, active_browser_list_->size()); ASSERT_EQ(url1_, new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); content::NavigationController* new_controller = &new_browser->tab_strip_model()->GetActiveWebContents()->GetController(); - ASSERT_TRUE(new_controller->GetSessionStorageNamespace()); + ASSERT_TRUE(new_controller->GetDefaultSessionStorageNamespace()); std::string restored_session_storage_persistent_id = - new_controller->GetSessionStorageNamespace()->persistent_id(); + new_controller->GetDefaultSessionStorageNamespace()->persistent_id(); EXPECT_EQ(session_storage_persistent_id, restored_session_storage_persistent_id); } @@ -1095,12 +1095,15 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { { content::NavigationController* controller = &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); - ASSERT_TRUE(controller->GetSessionStorageNamespace()); + ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); + content::SessionStorageNamespaceMap session_storage_namespace_map; + session_storage_namespace_map[std::string()] = + controller->GetDefaultSessionStorageNamespace(); scoped_ptr<content::WebContents> web_contents( content::WebContents::CreateWithSessionStorage( content::WebContents::CreateParams(browser()->profile()), - controller->GetSessionStorageNamespace())); + session_storage_namespace_map)); TabStripModel* tab_strip_model = browser()->tab_strip_model(); scoped_ptr<content::WebContents> old_web_contents( @@ -1115,7 +1118,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { content::NavigationController* controller = &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); EXPECT_TRUE( - controller->GetSessionStorageNamespace()->should_persist()); + controller->GetDefaultSessionStorageNamespace()->should_persist()); // Quit and restore. Check that no extra tabs were created. Browser* new_browser = QuitBrowserAndRestore(browser(), 1); diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 05bf038..dd97f43 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -1334,7 +1334,7 @@ void SessionService::BuildCommandsForTab(const SessionID& window_id, // Record the association between the sessionStorage namespace and the tab. content::SessionStorageNamespace* session_storage_namespace = - tab->GetController().GetSessionStorageNamespace(); + tab->GetController().GetDefaultSessionStorageNamespace(); ScheduleCommand(CreateSessionStorageAssociatedCommand( session_tab_helper->session_id(), session_storage_namespace->persistent_id())); @@ -1736,8 +1736,12 @@ void SessionService::TabInserted(WebContents* contents) { // 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 = - contents->GetController().GetSessionStorageNamespace(); + contents->GetController().GetDefaultSessionStorageNamespace(); ScheduleCommand(CreateSessionStorageAssociatedCommand( session_tab_helper->session_id(), session_storage_namespace->persistent_id())); @@ -1748,7 +1752,7 @@ void SessionService::TabClosing(WebContents* contents) { // Allow the associated sessionStorage to get deleted; it won't be needed // in the session restore. content::SessionStorageNamespace* session_storage_namespace = - contents->GetController().GetSessionStorageNamespace(); + contents->GetController().GetDefaultSessionStorageNamespace(); session_storage_namespace->SetShouldPersist(false); SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(contents); diff --git a/chrome/browser/sessions/tab_restore_service_helper.cc b/chrome/browser/sessions/tab_restore_service_helper.cc index 2782b47..2b13861 100644 --- a/chrome/browser/sessions/tab_restore_service_helper.cc +++ b/chrome/browser/sessions/tab_restore_service_helper.cc @@ -419,7 +419,9 @@ void TabRestoreServiceHelper::PopulateTab( tab->user_agent_override = controller->GetWebContents()->GetUserAgentOverride(); - tab->session_storage_namespace = controller->GetSessionStorageNamespace(); + // TODO(ajwong): This does not correctly handle storage for isolated apps. + tab->session_storage_namespace = + controller->GetDefaultSessionStorageNamespace(); // Delegate may be NULL during unit tests. if (delegate) { diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index eba4e94..f039ac3 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -1295,7 +1295,7 @@ TEST_F(ProfileSyncServiceSessionTest, CheckPrerenderedWebContentsSwap) { // Create new WebContents, with the required tab helpers. WebContents* new_web_contents = WebContents::CreateWithSessionStorage( WebContents::CreateParams(profile()), - old_web_contents->GetController().GetSessionStorageNamespace()); + old_web_contents->GetController().GetSessionStorageNamespaceMap()); SessionTabHelper::CreateForWebContents(new_web_contents); TabContentsSyncedTabDelegate::CreateForWebContents(new_web_contents); new_web_contents->GetController() diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc index a949fc5..9bb737a 100644 --- a/chrome/browser/ui/browser_tabrestore.cc +++ b/chrome/browser/ui/browser_tabrestore.cc @@ -14,6 +14,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/session_storage_namespace.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" @@ -44,6 +45,13 @@ WebContents* CreateRestoredTab( content::SessionStorageNamespace* session_storage_namespace, const std::string& user_agent_override) { GURL restore_url = navigations.at(selected_navigation).virtual_url(); + // TODO(ajwong): Remove the temporary session_storage_namespace_map when + // we teach session restore to understand that one tab can have multiple + // SessionStorageNamespace objects. Also remove the + // session_storage_namespace.h include since we only need that to assign + // into the map. + content::SessionStorageNamespaceMap session_storage_namespace_map; + session_storage_namespace_map[std::string()] = session_storage_namespace; WebContents::CreateParams create_params( browser->profile(), tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url)); @@ -55,7 +63,7 @@ WebContents* CreateRestoredTab( } WebContents* web_contents = content::WebContents::CreateWithSessionStorage( create_params, - session_storage_namespace); + session_storage_namespace_map); extensions::TabHelper::CreateForWebContents(web_contents); extensions::TabHelper::FromWebContents(web_contents)-> SetExtensionAppById(extension_app_id); diff --git a/chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.cc b/chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.cc index a50c59a..7868c8c 100644 --- a/chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.cc +++ b/chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.cc @@ -93,6 +93,6 @@ void OmniboxCurrentPageDelegateImpl::DoPrerender( predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_)-> StartPrerendering( match.destination_url, - web_contents->GetController().GetSessionStorageNamespace(), + web_contents->GetController().GetSessionStorageNamespaceMap(), container_bounds.size()); } |