diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 21:37:00 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 21:37:00 +0000 |
commit | 92e0a618fed5c5fe2d1e300394b0bcc1b0f50dea (patch) | |
tree | 625dbcd1541458fffa915b016e2f1508da0a6f59 /content | |
parent | 67e16b3941e532e5e20a7c9367c32e845911ce24 (diff) | |
download | chromium_src-92e0a618fed5c5fe2d1e300394b0bcc1b0f50dea.zip chromium_src-92e0a618fed5c5fe2d1e300394b0bcc1b0f50dea.tar.gz chromium_src-92e0a618fed5c5fe2d1e300394b0bcc1b0f50dea.tar.bz2 |
Reduce likelihood of double-get of top-level prerendered resource.
When a link to a prerendered page is clicked, a
DidStartProvisionalLoadForFrame is sent, as well as a RequestResource
IPC for the top-level page, both from the referring page. The
RequestResource caused an additional GET of the top-level page, which
is frequently uncacheable.
To prevent this from happening, RequestResource's which _might_ match
a prerendered page URL are deferred. On the UI thread, the child_id
and route_id of the request are checked against active
RenderViewHost's. If there is no longer an active RenderViewHost
(which would happen if the prerendered page is swapped in), the
request is cancelled. Otherwise, it is resumed.
BUG=71089
TEST=Existing browser_tests, unit_tests --gtest_filter=*PrerenderTrackerUrls*, click on a link that is being prerendered and make sure that a request is not sent over the wire.
Review URL: http://codereview.chromium.org/7074001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.cc | 10 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.h | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index ce8fb05..b7512ae 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -1387,9 +1387,15 @@ void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) { return; } - if (!defer_start) { - InsertIntoResourceQueue(request, *info); + // TODO(cbentzel): Should we isolate this to resource handlers instead of + // adding an interface to the observer? + if (!defer_start && observer_ && filter_) { + defer_start = observer_->ShouldDeferStart(request, + filter_->resource_context()); } + + if (!defer_start) + InsertIntoResourceQueue(request, *info); } void ResourceDispatcherHost::InsertIntoResourceQueue( diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index 1d3a0dc..60d4193 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -73,6 +73,14 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate { virtual void MutateLoadFlags(int child_id, int route_id, int* load_flags) = 0; + // Called to determine whether a request's start should be deferred. This + // is only called if the ResourceHandler associated with the request does + // not ask for a deferral. A return value of true will defer the start of + // the request, false will continue the request. + virtual bool ShouldDeferStart( + net::URLRequest* request, + const content::ResourceContext& resource_context) = 0; + // Called when an SSL Client Certificate is requested. If false is returned, // the request is canceled. Otherwise, the certificate is chosen. virtual bool AcceptSSLClientCertificateRequest( |