| Index: chrome/browser/prerender/prerender_contents.cc
|
| diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
|
| index 319e14b9ded99db7b9754dda9e936c3628227f62..9fc810a1e0c63293c4fa74d800307be3aad3399d 100644
|
| --- a/chrome/browser/prerender/prerender_contents.cc
|
| +++ b/chrome/browser/prerender/prerender_contents.cc
|
| @@ -39,6 +39,7 @@ using content::OpenURLParams;
|
| using content::RenderViewHost;
|
| using content::ResourceRedirectDetails;
|
| using content::SessionStorageNamespace;
|
| +using content::SessionStorageNamespaceMap;
|
| using content::WebContents;
|
|
|
| namespace prerender {
|
| @@ -210,14 +211,10 @@ bool PrerenderContents::IsPendingEntry(
|
| }
|
|
|
| void PrerenderContents::StartPendingPrerenders() {
|
| - SessionStorageNamespace* session_storage_namespace = NULL;
|
| - if (prerender_contents_.get()) {
|
| - // TODO(ajwong): This does not correctly handle storage for isolated apps.
|
| - session_storage_namespace =
|
| - prerender_contents_->web_contents()->GetController()
|
| - .GetSessionStorageNamespaceMap().find("")->second;
|
| - }
|
| - DCHECK(child_id_ == -1 || session_storage_namespace);
|
| + const SessionStorageNamespaceMap& session_storage_namespace_map =
|
| + prerender_contents_->web_contents()->GetController()
|
| + .GetSessionStorageNamespaceMap();
|
| + DCHECK(child_id_ == -1 || !session_storage_namespace_map.empty());
|
|
|
| std::vector<PendingPrerenderInfo> pending_prerender_list;
|
| pending_prerender_list.swap(pending_prerenders_);
|
| @@ -228,7 +225,7 @@ void PrerenderContents::StartPendingPrerenders() {
|
| if (it->weak_prerender_handle && it->weak_prerender_handle->IsValid()) {
|
| prerender_manager_->StartPendingPrerender(
|
| it->weak_prerender_handle.get(), ORIGIN_LINK_REL_PRERENDER, child_id_,
|
| - it->url, it->referrer, it->size, session_storage_namespace);
|
| + it->url, it->referrer, it->size, session_storage_namespace_map);
|
| }
|
| }
|
| }
|
| @@ -262,7 +259,6 @@ PrerenderContents::PrerenderContents(
|
| referrer_(referrer),
|
| profile_(profile),
|
| page_id_(0),
|
| - session_storage_namespace_id_(-1),
|
| has_stopped_loading_(false),
|
| has_finished_loading_(false),
|
| final_status_(FINAL_STATUS_MAX),
|
| @@ -279,8 +275,8 @@ PrerenderContents::PrerenderContents(
|
| void PrerenderContents::MakeIntoDummyReplacementOf(
|
| const PrerenderContents* original_prerender_contents) {
|
| load_start_time_ = original_prerender_contents->load_start_time_;
|
| - session_storage_namespace_id_ =
|
| - original_prerender_contents->session_storage_namespace_id_;
|
| + session_storage_namespace_ids_ =
|
| + original_prerender_contents->session_storage_namespace_ids_;
|
| }
|
|
|
| bool PrerenderContents::Init() {
|
| @@ -295,7 +291,7 @@ PrerenderContents::Factory* PrerenderContents::CreateFactory() {
|
| void PrerenderContents::StartPrerendering(
|
| int creator_child_id,
|
| const gfx::Size& size,
|
| - SessionStorageNamespace* session_storage_namespace,
|
| + const SessionStorageNamespaceMap& session_storage_namespace_map,
|
| bool is_control_group) {
|
| DCHECK(profile_ != NULL);
|
| DCHECK(!size.IsEmpty());
|
| @@ -306,8 +302,13 @@ void PrerenderContents::StartPrerendering(
|
| DCHECK_EQ(1U, alias_urls_.size());
|
|
|
| creator_child_id_ = creator_child_id;
|
| - session_storage_namespace_id_ = session_storage_namespace->id();
|
| size_ = size;
|
| + for (SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + session_storage_namespace_ids_.insert(it->second->id());
|
| + }
|
|
|
| InformRenderProcessAboutPrerender(prerender_url_, true,
|
| creator_child_id_);
|
| @@ -323,7 +324,7 @@ void PrerenderContents::StartPrerendering(
|
|
|
| prerendering_has_started_ = true;
|
|
|
| - WebContents* new_contents = CreateWebContents(session_storage_namespace);
|
| + WebContents* new_contents = CreateWebContents(session_storage_namespace_map);
|
| prerender_contents_.reset(new TabContents(new_contents));
|
| content::WebContentsObserver::Observe(new_contents);
|
|
|
| @@ -503,13 +504,10 @@ void PrerenderContents::OnRenderViewHostCreated(
|
| }
|
|
|
| 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[""] = session_storage_namespace;
|
| - return WebContents::CreateWithSessionStorage(
|
| - profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace_map);
|
| + const SessionStorageNamespaceMap& session_storage_namespace_map) {
|
| + return WebContents::CreateWithSessionStorage(profile_, NULL,
|
| + MSG_ROUTING_NONE, NULL,
|
| + session_storage_namespace_map);
|
| }
|
|
|
| void PrerenderContents::OnUpdateFaviconURL(
|
| @@ -561,11 +559,25 @@ void PrerenderContents::AddAliasURLsFromOtherPrerenderContents(
|
|
|
| bool PrerenderContents::Matches(
|
| const GURL& url,
|
| - const SessionStorageNamespace* session_storage_namespace) const {
|
| - DCHECK(child_id_ == -1 || session_storage_namespace);
|
| - if (session_storage_namespace &&
|
| - session_storage_namespace_id_ != session_storage_namespace->id())
|
| + const SessionStorageNamespaceMap& session_storage_namespace_map) const {
|
| + DCHECK(child_id_ == -1 || !session_storage_namespace_map.empty());
|
| +
|
| + // We must have the same session storage objects to match.
|
| + if (session_storage_namespace_ids_.size() !=
|
| + session_storage_namespace_map.size()) {
|
| return false;
|
| + }
|
| +
|
| + for (SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + if (session_storage_namespace_ids_.find(it->second->id()) ==
|
| + session_storage_namespace_ids_.end()) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| return std::count_if(alias_urls_.begin(), alias_urls_.end(),
|
| std::bind2nd(std::equal_to<GURL>(), url)) != 0;
|
| }
|
|
|