diff options
author | dominich@google.com <dominich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 21:21:10 +0000 |
---|---|---|
committer | dominich@google.com <dominich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 21:21:10 +0000 |
commit | b5f9845372bb2496aa6f6bd694e2ba4dc9523bde (patch) | |
tree | 34cf7b63d18321f7e73219ee392d6df7cc2fac5a /chrome/browser/prerender | |
parent | 43250c7bc9096609ca89af72153c9a6c0a4d53e2 (diff) | |
download | chromium_src-b5f9845372bb2496aa6f6bd694e2ba4dc9523bde.zip chromium_src-b5f9845372bb2496aa6f6bd694e2ba4dc9523bde.tar.gz chromium_src-b5f9845372bb2496aa6f6bd694e2ba4dc9523bde.tar.bz2 |
Add set of prerendering RenderViewHosts to allow setting of PRERENDER load flag in browser.
Conflicts:
chrome/browser/prerender/prerender_contents.cc
chrome/browser/prerender/prerender_manager.cc
BUG=72519, 70957
TEST=Create two html pages A and B with A containing a link rel="prefetch" to B. Enable prerender and navigate to A. Observe that the request for B and all requests from B correctly have the LOAD_PRERENDER load flag set.
Review URL: http://codereview.chromium.org/6588071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prerender')
-rw-r--r-- | chrome/browser/prerender/prerender_contents.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 3ee183f..6133f08 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -5,8 +5,10 @@ #include "chrome/browser/prerender/prerender_contents.h" #include "base/process_util.h" +#include "base/task.h" #include "base/utf_string_conversions.h" #include "chrome/browser/background_contents_service.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/prerender/prerender_final_status.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" @@ -19,6 +21,7 @@ #include "chrome/common/url_constants.h" #include "chrome/common/view_types.h" #include "content/browser/browsing_instance.h" +#include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "ui/gfx/rect.h" @@ -29,6 +32,18 @@ namespace prerender { +void AddChildRoutePair(ResourceDispatcherHost* rdh, + int child_id, int route_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + rdh->AddPrerenderChildRoutePair(child_id, route_id); +} + +void RemoveChildRoutePair(ResourceDispatcherHost* rdh, + int child_id, int route_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + rdh->RemovePrerenderChildRoutePair(child_id, route_id); +} + class PrerenderContentsFactoryImpl : public PrerenderContents::Factory { public: virtual PrerenderContents* CreatePrerenderContents( @@ -78,6 +93,18 @@ void PrerenderContents::StartPrerendering() { render_view_host_->WasHidden(); render_view_host_->AllowScriptToClose(true); + // Register this with the ResourceDispatcherHost as a prerender + // RenderViewHost. This must be done before the Navigate message to catch all + // resource requests, but as it is on the same thread as the Navigate message + // (IO) there is no race condition. + int process_id = render_view_host_->process()->id(); + int view_id = render_view_host_->routing_id(); + ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + NewRunnableFunction(&AddChildRoutePair, rdh, + process_id, view_id)); + + // Close ourselves when the application is shutting down. registrar_.Add(this, NotificationType::APP_TERMINATING, NotificationService::AllSources()); @@ -109,6 +136,7 @@ void PrerenderContents::StartPrerendering() { params.transition = PageTransition::LINK; params.navigation_type = ViewMsg_Navigate_Params::PRERENDER; params.referrer = referrer_; + render_view_host_->Navigate(params); } @@ -130,6 +158,12 @@ PrerenderContents::~PrerenderContents() { if (!render_view_host_) // Will be null for unit tests. return; + int process_id = render_view_host_->process()->id(); + int view_id = render_view_host_->routing_id(); + ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + NewRunnableFunction(&RemoveChildRoutePair, rdh, + process_id, view_id)); render_view_host_->Shutdown(); // deletes render_view_host } |