Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 10831116: Move SessionStorageNamespace entirely into NavigationController and support StoragePartitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add some rudimentary testing. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 } 228 }
229 229
230 // Unit tests pass in a process_id == -1. 230 // Unit tests pass in a process_id == -1.
231 SessionStorageNamespace* session_storage_namespace = NULL; 231 SessionStorageNamespace* session_storage_namespace = NULL;
232 if (process_id != -1) { 232 if (process_id != -1) {
233 RenderViewHost* source_render_view_host = 233 RenderViewHost* source_render_view_host =
234 RenderViewHost::FromID(process_id, route_id); 234 RenderViewHost::FromID(process_id, route_id);
235 if (!source_render_view_host) 235 if (!source_render_view_host)
236 return NULL; 236 return NULL;
237 WebContents* source_web_contents =
238 WebContents::FromRenderViewHost(source_render_view_host);
239 if (!source_web_contents)
240 return NULL;
241 // TODO(ajwong): This does not correctly handle storage for isolated apps.
237 session_storage_namespace = 242 session_storage_namespace =
238 source_render_view_host->GetSessionStorageNamespace(); 243 source_web_contents->GetController()
244 .GetSessionStorageNamespaceMap().find("")->second;
239 } 245 }
240 246
241 return AddPrerender(ORIGIN_LINK_REL_PRERENDER, 247 return AddPrerender(ORIGIN_LINK_REL_PRERENDER,
242 process_id, url, referrer, size, 248 process_id, url, referrer, size,
243 session_storage_namespace); 249 session_storage_namespace);
244 #endif 250 #endif
245 } 251 }
246 252
247 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox( 253 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox(
248 const GURL& url, 254 const GURL& url,
(...skipping 21 matching lines...) Expand all
270 active_prerender_list_.front()->contents(); 276 active_prerender_list_.front()->contents();
271 prerender_contents->Destroy(FINAL_STATUS_CANCELLED); 277 prerender_contents->Destroy(FINAL_STATUS_CANCELLED);
272 } 278 }
273 } 279 }
274 280
275 bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents, 281 bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents,
276 const GURL& url) { 282 const GURL& url) {
277 DCHECK(CalledOnValidThread()); 283 DCHECK(CalledOnValidThread());
278 DCHECK(!IsWebContentsPrerendering(web_contents)); 284 DCHECK(!IsWebContentsPrerendering(web_contents));
279 285
280 RenderViewHost* old_render_view_host = web_contents->GetRenderViewHost();
281
282 DeleteOldEntries(); 286 DeleteOldEntries();
283 DeletePendingDeleteEntries(); 287 DeletePendingDeleteEntries();
288 // TODO(ajwong): This doesn't handle isolated apps correctly.
284 PrerenderData* prerender_data = FindPrerenderData( 289 PrerenderData* prerender_data = FindPrerenderData(
285 url, old_render_view_host->GetSessionStorageNamespace()); 290 url,
291 web_contents->GetController().GetSessionStorageNamespaceMap()
292 .find("")->second);
286 if (!prerender_data) 293 if (!prerender_data)
287 return false; 294 return false;
288 DCHECK(prerender_data->contents_); 295 DCHECK(prerender_data->contents_);
289 if (IsNoSwapInExperiment(prerender_data->contents_->experiment_id())) 296 if (IsNoSwapInExperiment(prerender_data->contents_->experiment_id()))
290 return false; 297 return false;
291 298
292 if (TabContents* new_tab_contents = 299 if (TabContents* new_tab_contents =
293 prerender_data->contents_->prerender_contents()) { 300 prerender_data->contents_->prerender_contents()) {
294 if (web_contents == new_tab_contents->web_contents()) 301 if (web_contents == new_tab_contents->web_contents())
295 return false; // Do not swap in to ourself. 302 return false; // Do not swap in to ourself.
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 if (!render_process_host || !render_process_host->GetBrowserContext()) 1236 if (!render_process_host || !render_process_host->GetBrowserContext())
1230 return NULL; 1237 return NULL;
1231 Profile* profile = Profile::FromBrowserContext( 1238 Profile* profile = Profile::FromBrowserContext(
1232 render_process_host->GetBrowserContext()); 1239 render_process_host->GetBrowserContext());
1233 if (!profile) 1240 if (!profile)
1234 return NULL; 1241 return NULL;
1235 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1242 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1236 } 1243 }
1237 1244
1238 } // namespace prerender 1245 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698