diff options
18 files changed, 61 insertions, 42 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 3f16647..e91ef0d 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -363,7 +363,7 @@ class PrerenderBrowserTest : public InProcessBrowserTest { std::vector<net::TestServer::StringPair> replacement_text; replacement_text.push_back( - make_pair("REPLACE_WITH_PREFETCH_URL", dest_url_.spec())); + make_pair("REPLACE_WITH_PRERENDER_URL", dest_url_.spec())); std::string replacement_path; ASSERT_TRUE(net::TestServer::GetFilePathWithReplacements( "files/prerender/prerender_loader.html", @@ -462,7 +462,7 @@ class PrerenderBrowserTest : public InProcessBrowserTest { }; // Checks that a page is correctly prerendered in the case of a -// <link rel=prefetch> tag and then loaded into a tab in response to a +// <link rel=prerender> tag and then loaded into a tab in response to a // navigation. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); @@ -549,7 +549,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, NavigateToURL("files/prerender/prerender_page.html"); } -// Checks that a prefetch for an https will prevent a prerender from happening. +// Checks that a prerender for an https will prevent a prerender from happening. IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderHttps) { net::TestServer https_server(net::TestServer::TYPE_HTTPS, FilePath(FILE_PATH_LITERAL("chrome/test/data"))); diff --git a/chrome/browser/prerender/prerender_field_trial.cc b/chrome/browser/prerender/prerender_field_trial.cc index 258a43a..eb0f96d 100644 --- a/chrome/browser/prerender/prerender_field_trial.cc +++ b/chrome/browser/prerender/prerender_field_trial.cc @@ -92,12 +92,12 @@ void ConfigurePrefetchAndPrerender(const CommandLine& command_line) { PrerenderManager::PRERENDER_MODE_DISABLED); } else if (trial_group == kPrerenderExperiment1Group || trial_group == kPrerenderExperiment2Group) { - ResourceDispatcherHost::set_is_prefetch_enabled(true); + ResourceDispatcherHost::set_is_prefetch_enabled(false); PrerenderManager::SetMode( PrerenderManager::PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP); } else if (trial_group == kPrerenderControl1Group || trial_group == kPrerenderControl2Group) { - ResourceDispatcherHost::set_is_prefetch_enabled(true); + ResourceDispatcherHost::set_is_prefetch_enabled(false); PrerenderManager::SetMode( PrerenderManager::PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP); } else { @@ -110,7 +110,7 @@ void ConfigurePrefetchAndPrerender(const CommandLine& command_line) { PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_DISABLED); break; case PRERENDER_OPTION_ENABLED: - ResourceDispatcherHost::set_is_prefetch_enabled(true); + ResourceDispatcherHost::set_is_prefetch_enabled(false); PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_ENABLED); break; case PRERENDER_OPTION_PREFETCH_ONLY: diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index a95f1f1..c87dfb3 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -167,7 +167,7 @@ struct PrerenderManager::PendingContentsData { GURL referrer_; }; -void HandlePrefetchTag( +void HandleTag( const base::WeakPtr<PrerenderManager>& prerender_manager_weak_ptr, int render_process_id, int render_view_id, @@ -178,7 +178,7 @@ void HandlePrefetchTag( PrerenderManager* prerender_manager = prerender_manager_weak_ptr.get(); if (!prerender_manager || !prerender_manager->is_enabled()) return; - prerender_manager->RecordPrefetchTagObserved(); + prerender_manager->RecordTagObserved(); std::pair<int, int> child_route_id_pair = std::make_pair(render_process_id, render_view_id); @@ -818,13 +818,13 @@ PrerenderManager::PendingContentsData* return NULL; } -void PrerenderManager::RecordPrefetchTagObserved() { +void PrerenderManager::RecordTagObserved() { DCHECK(CalledOnValidThread()); // If we observe multiple tags within the 30 second window, we will still // reset the window to begin at the most recent occurrence, so that we will // always be in a window in the 30 seconds from each occurrence. - last_prefetch_seen_time_ = base::TimeTicks::Now(); + last_prerender_seen_time_ = base::TimeTicks::Now(); } void PrerenderManager::RemovePendingPreload(PrerenderContents* entry) { @@ -844,10 +844,10 @@ void PrerenderManager::RemovePendingPreload(PrerenderContents* entry) { bool PrerenderManager::WithinWindow() const { DCHECK(CalledOnValidThread()); - if (last_prefetch_seen_time_.is_null()) + if (last_prerender_seen_time_.is_null()) return false; base::TimeDelta elapsed_time = - base::TimeTicks::Now() - last_prefetch_seen_time_; + base::TimeTicks::Now() - last_prerender_seen_time_; return elapsed_time <= base::TimeDelta::FromSeconds(kWindowDurationSeconds); } diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index 0471414..bbe630c 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -40,7 +40,7 @@ namespace prerender { // Adds either a preload or a pending preload to the PrerenderManager. // Must be called on the UI thread. -void HandlePrefetchTag( +void HandleTag( const base::WeakPtr<PrerenderManager>& prerender_manager, int render_process_id, int render_view_id, @@ -153,8 +153,8 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, static bool IsPrerenderingPossible(); static bool IsControlGroup(); - // Records that a prefetch tag has been observed. - void RecordPrefetchTagObserved(); + // Records that a prerender tag has been observed. + void RecordTagObserved(); // Query the list of current prerender pages to see if the given tab contents // is prerendering a page. @@ -243,7 +243,7 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, const std::pair<int, int>& child_route_id_pair); // Returns whether the PrerenderManager is currently within the prerender - // window - effectively, up to 30 seconds after a prefetch tag has been + // window - effectively, up to 30 seconds after a prerender tag has been // observed. bool WithinWindow() const; @@ -300,10 +300,10 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, static PrerenderManagerMode mode_; - // The time when we last saw a prefetch request coming from a renderer. + // The time when we last saw a prerender request coming from a renderer. // This is used to record perceived PLT's for a certain amount of time - // from the point that we last saw a <link rel=prefetch> tag. - base::TimeTicks last_prefetch_seen_time_; + // from the point that we last saw a <link rel=prerender> tag. + base::TimeTicks last_prerender_seen_time_; // A count of how many prerenders we do per session. Initialized to 0 then // incremented and emitted to a histogram on each successful prerender. diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc index 84365e8..5581afa 100644 --- a/chrome/renderer/page_load_histograms.cc +++ b/chrome/renderer/page_load_histograms.cc @@ -306,6 +306,9 @@ void PageLoadHistograms::Dump(WebFrame* frame) { } // Histograms to determine if content prefetching has an impact on PLT. + // TODO(gavinp): Right now the prerendering and the prefetching field trials + // are mixed together. If we continue to launch prerender with + // link rel=prerender, then we should separate them. static const bool prefetching_fieldtrial = base::FieldTrialList::TrialExists("Prefetch"); if (prefetching_fieldtrial) { diff --git a/chrome/test/data/prerender/prerender_infinite_a.html b/chrome/test/data/prerender/prerender_infinite_a.html index d40dbf5..448d4e5 100644 --- a/chrome/test/data/prerender/prerender_infinite_a.html +++ b/chrome/test/data/prerender/prerender_infinite_a.html @@ -14,7 +14,7 @@ </script> </head> <body> - <link rel="prefetch" href="prerender_infinite_b.html"> + <link rel="prerender" href="prerender_infinite_b.html"> <a href="prerender_infinite_b.html">B</a> </body> </html> diff --git a/chrome/test/data/prerender/prerender_infinite_a_multiple.html b/chrome/test/data/prerender/prerender_infinite_a_multiple.html index f9fcf88..ac2e709 100644 --- a/chrome/test/data/prerender/prerender_infinite_a_multiple.html +++ b/chrome/test/data/prerender/prerender_infinite_a_multiple.html @@ -14,9 +14,9 @@ </script> </head> <body> - <link rel="prefetch" href="prerender_infinite_b_multiple.html"> + <link rel="prerender" href="prerender_infinite_b_multiple.html"> <a href="prerender_infinite_b_multiple.html">B</a> - <link rel="prefetch" href="prerender_infinite_c_multiple.html"> + <link rel="prerender" href="prerender_infinite_c_multiple.html"> <a href="prerender_infinite_c_multiple.html">C</a> </body> </html> diff --git a/chrome/test/data/prerender/prerender_infinite_b.html b/chrome/test/data/prerender/prerender_infinite_b.html index d485ae6..f6fdf8c 100644 --- a/chrome/test/data/prerender/prerender_infinite_b.html +++ b/chrome/test/data/prerender/prerender_infinite_b.html @@ -2,7 +2,7 @@ <head> </head> <body> - <link rel="prefetch" href="prerender_infinite_a.html"> + <link rel="prerender" href="prerender_infinite_a.html"> <a href="prerender_infinite_a.html">A</a> </body> </html> diff --git a/chrome/test/data/prerender/prerender_infinite_b_multiple.html b/chrome/test/data/prerender/prerender_infinite_b_multiple.html index 1699b40..a47b764 100644 --- a/chrome/test/data/prerender/prerender_infinite_b_multiple.html +++ b/chrome/test/data/prerender/prerender_infinite_b_multiple.html @@ -2,7 +2,7 @@ <head> </head> <body> - <link rel="prefetch" href="prerender_infinite_a_multiple.html"> + <link rel="prerender" href="prerender_infinite_a_multiple.html"> <a href="prerender_infinite_a_multiple.html">A</a> </body> </html> diff --git a/chrome/test/data/prerender/prerender_infinite_c_multiple.html b/chrome/test/data/prerender/prerender_infinite_c_multiple.html index 1699b40..a47b764 100644 --- a/chrome/test/data/prerender/prerender_infinite_c_multiple.html +++ b/chrome/test/data/prerender/prerender_infinite_c_multiple.html @@ -2,7 +2,7 @@ <head> </head> <body> - <link rel="prefetch" href="prerender_infinite_a_multiple.html"> + <link rel="prerender" href="prerender_infinite_a_multiple.html"> <a href="prerender_infinite_a_multiple.html">A</a> </body> </html> diff --git a/chrome/test/data/prerender/prerender_loader.html b/chrome/test/data/prerender/prerender_loader.html index 8ef9950..f8089d3 100644 --- a/chrome/test/data/prerender/prerender_loader.html +++ b/chrome/test/data/prerender/prerender_loader.html @@ -11,7 +11,7 @@ } function JsOpenLinkInNewWindow() { - window.open("REPLACE_WITH_PREFETCH_URL"); + window.open("REPLACE_WITH_PRERENDER_URL"); return true; } </script> @@ -19,9 +19,9 @@ </head> <body> <script> - document.write('<link rel="prefetch" href="REPLACE_WITH_PREFETCH_URL"/>'); + document.write('<link rel="prerender" href="REPLACE_WITH_PRERENDER_URL"/>'); </script> <a target="_blank" id="toClick" - href="REPLACE_WITH_PREFETCH_URL">Link To Click</a> + href="REPLACE_WITH_PRERENDER_URL">Link To Click</a> </body> </html> diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index c92d1d6..17633a8 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -437,9 +437,7 @@ void ResourceDispatcherHost::BeginRequest( child_id, route_id); // Handle a PREFETCH resource type. If prefetch is disabled, squelch the - // request. If prerendering is enabled, trigger a prerender for the URL - // and abort the request, to prevent double-gets. Otherwise, do a normal - // prefetch. + // request. Otherwise, do a normal request to warm the cache. if (request_data.resource_type == ResourceType::PREFETCH) { // All PREFETCH requests should be GETs, but be defensive about it. if (request_data.method != "GET") { @@ -450,20 +448,26 @@ void ResourceDispatcherHost::BeginRequest( AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); return; } + // Otherwise, treat like a normal request, and fall-through. + } + + // Handle a PRERENDER motivated request. Very similar to rel=prefetch, these + // rel=prerender requests instead launch an early render of the entire page. + if (request_data.resource_type == ResourceType::PRERENDER) { if (prerender::PrerenderManager::IsPrerenderingPossible()) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - NewRunnableFunction(prerender::HandlePrefetchTag, + NewRunnableFunction(prerender::HandleTag, resource_context.prerender_manager(), child_id, route_id, request_data.url, referrer, is_prerendering)); - AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); - return; } - // Otherwise, treat like a normal request, and fall-through. + // Prerendering or not, this request should stop. + AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); + return; } // Abort any prerenders that spawn requests that use invalid HTTP methods. @@ -524,7 +528,7 @@ void ResourceDispatcherHost::BeginRequest( } if (is_prerendering) - load_flags |= net::LOAD_PRERENDER; + load_flags |= net::LOAD_PRERENDERING; if (sync_result) load_flags |= net::LOAD_IGNORE_LIMITS; @@ -1981,7 +1985,7 @@ net::RequestPriority ResourceDispatcherHost::DetermineRequestPriority( // * How useful is the page to the user if this resource is not loaded yet. // Prerender-motivated requests should be made at IDLE. - if (load_flags & net::LOAD_PRERENDER) + if (load_flags & net::LOAD_PRERENDERING) return net::IDLE; switch (type) { @@ -2021,9 +2025,11 @@ net::RequestPriority ResourceDispatcherHost::DetermineRequestPriority( case ResourceType::FAVICON: return net::LOWEST; - // Prefetches are at a lower priority than even LOWEST, since they - // are not even required for rendering of the current page. + // Prefetches and prerenders are at a lower priority than even + // LOWEST, since they are not even required for rendering of the + // current page. case ResourceType::PREFETCH: + case ResourceType::PRERENDER: return net::IDLE; default: diff --git a/content/common/common_param_traits.cc b/content/common/common_param_traits.cc index 5e31003..92cbee6 100644 --- a/content/common/common_param_traits.cc +++ b/content/common/common_param_traits.cc @@ -121,6 +121,9 @@ void ParamTraits<ResourceType::Type>::Log(const param_type& p, std::string* l) { case ResourceType::PREFETCH: type = "PREFETCH"; break; + case ResourceType::PRERENDER: + type = "PRERENDER"; + break; case ResourceType::FAVICON: type = "FAVICON"; break; diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 4cbe162..a7c5f8f1 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -2572,7 +2572,10 @@ void RenderView::willSendRequest( if (top_data_source) { NavigationState* state = NavigationState::FromDataSource(top_data_source); - if (state && request.targetType() == WebURLRequest::TargetIsPrefetch) + // TODO(gavinp): separate out prefetching and prerender field trials + // if the rel=prerender rel type is sticking around. + if (state && (request.targetType() == WebURLRequest::TargetIsPrefetch || + request.targetType() == WebURLRequest::TargetIsPrerender)) state->set_was_prefetcher(true); } diff --git a/net/base/load_flags_list.h b/net/base/load_flags_list.h index 80fba2b..364ef94 100644 --- a/net/base/load_flags_list.h +++ b/net/base/load_flags_list.h @@ -104,7 +104,7 @@ LOAD_FLAG(PREFETCH, 1 << 23) // Indicates that this load was requested by a page that is currently // prerendering. -LOAD_FLAG(PRERENDER, 1 << 24) +LOAD_FLAG(PRERENDERING, 1 << 24) // Indicates that this is a load that ignores limits and should complete // immediately. @@ -113,3 +113,4 @@ LOAD_FLAG(IGNORE_LIMITS, 1 << 25) // Suppress login prompts for this request. Cached credentials or // default credentials may still be used for authentication. LOAD_FLAG(DO_NOT_PROMPT_FOR_LOGIN, 1 << 26) + diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index d22cff7..36a1674 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -1127,7 +1127,7 @@ void URLRequestHttpJob::RecordTimer() { to_start); } - const bool is_prerender = !!(request_info_.load_flags & LOAD_PRERENDER); + const bool is_prerender = !!(request_info_.load_flags & LOAD_PRERENDERING); if (is_prerender) { UMA_HISTOGRAM_MEDIUM_TIMES("Net.HttpTimeToFirstByte_Prerender", to_start); diff --git a/webkit/glue/resource_type.h b/webkit/glue/resource_type.h index 224656a..e9ae3b6 100644 --- a/webkit/glue/resource_type.h +++ b/webkit/glue/resource_type.h @@ -23,6 +23,7 @@ class ResourceType { WORKER, // the main resource of a dedicated worker. SHARED_WORKER, // the main resource of a shared worker. PREFETCH, // an explicitly requested prefetch + PRERENDER, // an explicitly requested prerender FAVICON, // a favicon LAST_TYPE // Place holder so we don't need to change ValidType // everytime. diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 0a874d0..dd5b20b 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -135,6 +135,8 @@ ResourceType::Type FromTargetType(WebURLRequest::TargetType type) { return ResourceType::SHARED_WORKER; case WebURLRequest::TargetIsPrefetch: return ResourceType::PREFETCH; + case WebURLRequest::TargetIsPrerender: + return ResourceType::PRERENDER; case WebURLRequest::TargetIsFavicon: return ResourceType::FAVICON; default: |