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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for initial review. Created 8 years, 9 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return false; 378 return false;
379 } 379 }
380 380
381 // If the session storage namespaces don't match, cancel the prerender. 381 // If the session storage namespaces don't match, cancel the prerender.
382 RenderViewHost* old_render_view_host = web_contents->GetRenderViewHost(); 382 RenderViewHost* old_render_view_host = web_contents->GetRenderViewHost();
383 RenderViewHost* new_render_view_host = 383 RenderViewHost* new_render_view_host =
384 prerender_contents->prerender_contents()->web_contents()-> 384 prerender_contents->prerender_contents()->web_contents()->
385 GetRenderViewHost(); 385 GetRenderViewHost();
386 DCHECK(old_render_view_host); 386 DCHECK(old_render_view_host);
387 DCHECK(new_render_view_host); 387 DCHECK(new_render_view_host);
388 if (old_render_view_host->session_storage_namespace() != 388 if (old_render_view_host->GetSessionStorageNamespace() !=
389 new_render_view_host->session_storage_namespace()) { 389 new_render_view_host->GetSessionStorageNamespace()) {
390 DestroyAndMarkMatchCompleteAsUsed( 390 DestroyAndMarkMatchCompleteAsUsed(
391 prerender_contents.release(), 391 prerender_contents.release(),
392 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH); 392 FINAL_STATUS_SESSION_STORAGE_NAMESPACE_MISMATCH);
393 return false; 393 return false;
394 } 394 }
395 395
396 // If we don't want to use prerenders at all, we are done. 396 // If we don't want to use prerenders at all, we are done.
397 // For bookkeeping purposes, we need to mark this TabContents to 397 // For bookkeeping purposes, we need to mark this TabContents to
398 // reflect that it would have been prerendered. 398 // reflect that it would have been prerendered.
399 if (GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP) { 399 if (GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP) {
(...skipping 16 matching lines...) Expand all
416 histograms_->RecordTimeUntilUsed(GetCurrentTimeTicks() - 416 histograms_->RecordTimeUntilUsed(GetCurrentTimeTicks() -
417 prerender_contents->load_start_time(), 417 prerender_contents->load_start_time(),
418 config_.max_age); 418 config_.max_age);
419 } 419 }
420 420
421 histograms_->RecordPerSessionCount(++prerenders_per_session_count_); 421 histograms_->RecordPerSessionCount(++prerenders_per_session_count_);
422 histograms_->RecordUsedPrerender(prerender_contents->origin()); 422 histograms_->RecordUsedPrerender(prerender_contents->origin());
423 prerender_contents->set_final_status(FINAL_STATUS_USED); 423 prerender_contents->set_final_status(FINAL_STATUS_USED);
424 424
425 new_render_view_host->Send( 425 new_render_view_host->Send(
426 new ChromeViewMsg_SetIsPrerendering(new_render_view_host->routing_id(), 426 new ChromeViewMsg_SetIsPrerendering(new_render_view_host->GetRoutingID(),
427 false)); 427 false));
428 428
429 TabContentsWrapper* new_tab_contents = 429 TabContentsWrapper* new_tab_contents =
430 prerender_contents->ReleasePrerenderContents(); 430 prerender_contents->ReleasePrerenderContents();
431 TabContentsWrapper* old_tab_contents = 431 TabContentsWrapper* old_tab_contents =
432 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); 432 TabContentsWrapper::GetCurrentWrapperForContents(web_contents);
433 DCHECK(new_tab_contents); 433 DCHECK(new_tab_contents);
434 DCHECK(old_tab_contents); 434 DCHECK(old_tab_contents);
435 435
436 MarkWebContentsAsPrerendered(new_tab_contents->web_contents()); 436 MarkWebContentsAsPrerendered(new_tab_contents->web_contents());
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return false; 861 return false;
862 } 862 }
863 863
864 RenderViewHost* source_render_view_host = NULL; 864 RenderViewHost* source_render_view_host = NULL;
865 if (child_route_id_pair.first != -1) { 865 if (child_route_id_pair.first != -1) {
866 source_render_view_host = 866 source_render_view_host =
867 RenderViewHost::FromID(child_route_id_pair.first, 867 RenderViewHost::FromID(child_route_id_pair.first,
868 child_route_id_pair.second); 868 child_route_id_pair.second);
869 // Don't prerender page if parent RenderViewHost no longer exists, or it has 869 // Don't prerender page if parent RenderViewHost no longer exists, or it has
870 // no view. The latter should only happen when the RenderView has closed. 870 // no view. The latter should only happen when the RenderView has closed.
871 if (!source_render_view_host || !source_render_view_host->view()) { 871 if (!source_render_view_host || !source_render_view_host->GetView()) {
872 RecordFinalStatus(origin, experiment, 872 RecordFinalStatus(origin, experiment,
873 FINAL_STATUS_SOURCE_RENDER_VIEW_CLOSED); 873 FINAL_STATUS_SOURCE_RENDER_VIEW_CLOSED);
874 return false; 874 return false;
875 } 875 }
876 } 876 }
877 877
878 if (!session_storage_namespace && source_render_view_host) { 878 if (!session_storage_namespace && source_render_view_host) {
879 session_storage_namespace = 879 session_storage_namespace =
880 source_render_view_host->session_storage_namespace(); 880 source_render_view_host->GetSessionStorageNamespace();
881 } 881 }
882 882
883 PrerenderContents* prerender_contents = CreatePrerenderContents( 883 PrerenderContents* prerender_contents = CreatePrerenderContents(
884 url, referrer, origin, experiment); 884 url, referrer, origin, experiment);
885 if (!prerender_contents || !prerender_contents->Init()) 885 if (!prerender_contents || !prerender_contents->Init())
886 return false; 886 return false;
887 887
888 histograms_->RecordPrerenderStarted(origin); 888 histograms_->RecordPrerenderStarted(origin);
889 889
890 // TODO(cbentzel): Move invalid checks here instead of PrerenderContents? 890 // TODO(cbentzel): Move invalid checks here instead of PrerenderContents?
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (!render_process_host || !render_process_host->GetBrowserContext()) 1194 if (!render_process_host || !render_process_host->GetBrowserContext())
1195 return NULL; 1195 return NULL;
1196 Profile* profile = Profile::FromBrowserContext( 1196 Profile* profile = Profile::FromBrowserContext(
1197 render_process_host->GetBrowserContext()); 1197 render_process_host->GetBrowserContext());
1198 if (!profile) 1198 if (!profile)
1199 return NULL; 1199 return NULL;
1200 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1200 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1201 } 1201 }
1202 1202
1203 } // namespace prerender 1203 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698