OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 // Unit tests pass in a process_id == -1. | 229 // Unit tests pass in a process_id == -1. |
230 SessionStorageNamespace* session_storage_namespace = NULL; | 230 SessionStorageNamespace* session_storage_namespace = NULL; |
231 if (process_id != -1) { | 231 if (process_id != -1) { |
232 RenderViewHost* source_render_view_host = | 232 RenderViewHost* source_render_view_host = |
233 RenderViewHost::FromID(process_id, route_id); | 233 RenderViewHost::FromID(process_id, route_id); |
234 if (!source_render_view_host) | 234 if (!source_render_view_host) |
235 return NULL; | 235 return NULL; |
| 236 WebContents* source_web_contents = |
| 237 WebContents::FromRenderViewHost(source_render_view_host); |
| 238 if (!source_web_contents) |
| 239 return NULL; |
| 240 // TODO(ajwong): This does not correctly handle storage for isolated apps. |
236 session_storage_namespace = | 241 session_storage_namespace = |
237 source_render_view_host->GetSessionStorageNamespace(); | 242 source_web_contents->GetController() |
| 243 .GetSessionStorageNamespaceMap().find("")->second; |
238 } | 244 } |
239 | 245 |
240 return AddPrerender(ORIGIN_LINK_REL_PRERENDER, | 246 return AddPrerender(ORIGIN_LINK_REL_PRERENDER, |
241 process_id, url, referrer, size, | 247 process_id, url, referrer, size, |
242 session_storage_namespace); | 248 session_storage_namespace); |
243 #endif | 249 #endif |
244 } | 250 } |
245 | 251 |
246 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox( | 252 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox( |
247 const GURL& url, | 253 const GURL& url, |
(...skipping 21 matching lines...) Expand all Loading... |
269 active_prerender_list_.front()->contents(); | 275 active_prerender_list_.front()->contents(); |
270 prerender_contents->Destroy(FINAL_STATUS_CANCELLED); | 276 prerender_contents->Destroy(FINAL_STATUS_CANCELLED); |
271 } | 277 } |
272 } | 278 } |
273 | 279 |
274 bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents, | 280 bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents, |
275 const GURL& url) { | 281 const GURL& url) { |
276 DCHECK(CalledOnValidThread()); | 282 DCHECK(CalledOnValidThread()); |
277 DCHECK(!IsWebContentsPrerendering(web_contents)); | 283 DCHECK(!IsWebContentsPrerendering(web_contents)); |
278 | 284 |
279 RenderViewHost* old_render_view_host = web_contents->GetRenderViewHost(); | |
280 | |
281 DeleteOldEntries(); | 285 DeleteOldEntries(); |
282 DeletePendingDeleteEntries(); | 286 DeletePendingDeleteEntries(); |
| 287 // TODO(ajwong): This doesn't handle isolated apps correctly. |
283 PrerenderData* prerender_data = FindPrerenderData( | 288 PrerenderData* prerender_data = FindPrerenderData( |
284 url, old_render_view_host->GetSessionStorageNamespace()); | 289 url, |
| 290 web_contents->GetController().GetSessionStorageNamespaceMap() |
| 291 .find("")->second); |
285 if (!prerender_data) | 292 if (!prerender_data) |
286 return false; | 293 return false; |
287 DCHECK(prerender_data->contents_); | 294 DCHECK(prerender_data->contents_); |
288 if (IsNoSwapInExperiment(prerender_data->contents_->experiment_id())) | 295 if (IsNoSwapInExperiment(prerender_data->contents_->experiment_id())) |
289 return false; | 296 return false; |
290 | 297 |
291 if (TabContents* new_tab_contents = | 298 if (TabContents* new_tab_contents = |
292 prerender_data->contents_->prerender_contents()) { | 299 prerender_data->contents_->prerender_contents()) { |
293 if (web_contents == new_tab_contents->web_contents()) | 300 if (web_contents == new_tab_contents->web_contents()) |
294 return false; // Do not swap in to ourself. | 301 return false; // Do not swap in to ourself. |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 if (!render_process_host || !render_process_host->GetBrowserContext()) | 1235 if (!render_process_host || !render_process_host->GetBrowserContext()) |
1229 return NULL; | 1236 return NULL; |
1230 Profile* profile = Profile::FromBrowserContext( | 1237 Profile* profile = Profile::FromBrowserContext( |
1231 render_process_host->GetBrowserContext()); | 1238 render_process_host->GetBrowserContext()); |
1232 if (!profile) | 1239 if (!profile) |
1233 return NULL; | 1240 return NULL; |
1234 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); | 1241 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); |
1235 } | 1242 } |
1236 | 1243 |
1237 } // namespace prerender | 1244 } // namespace prerender |
OLD | NEW |