summaryrefslogtreecommitdiffstats
path: root/content/browser/loader/resource_dispatcher_host_impl.cc
diff options
context:
space:
mode:
authorsimonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 19:45:32 +0000
committersimonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 19:45:32 +0000
commit102ab68eeb932e56276abd727b2b850e29abcd0b (patch)
tree85c8a8726e363cff02c86cec70bd00fa6b12b040 /content/browser/loader/resource_dispatcher_host_impl.cc
parent185c0345eceb16301eac0b2a129382517f6acf04 (diff)
downloadchromium_src-102ab68eeb932e56276abd727b2b850e29abcd0b.zip
chromium_src-102ab68eeb932e56276abd727b2b850e29abcd0b.tar.gz
chromium_src-102ab68eeb932e56276abd727b2b850e29abcd0b.tar.bz2
Use WebKit's resource priorities instead of computing our own.
This has no effect on PLT, Speed Index, TTFB, or first paint. This simply allows us to benefit from improvements to WebKit's prioritization. For instance, deferred scripts should be lower priority than blocking scripts. We'll likely use the priority to deprioritize preloads too. In practical terms, the only significant change is that WebKit prioritizes CSS above JS and fonts. That didn't affect the metrics. BUG=None Review URL: https://chromiumcodereview.appspot.com/12045105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/loader/resource_dispatcher_host_impl.cc')
-rw-r--r--content/browser/loader/resource_dispatcher_host_impl.cc52
1 files changed, 10 insertions, 42 deletions
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 36fee38..9dcf49e 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -203,58 +203,26 @@ void RemoveDownloadFileFromChildSecurityPolicy(int child_id,
#pragma warning(default: 4748)
#endif
-net::RequestPriority DetermineRequestPriority(ResourceType::Type type) {
- // Determine request priority based on how critical this resource typically
- // is to user-perceived page load performance. Important considerations are:
- // * Can this resource block the download of other resources.
- // * Can this resource block the rendering of the page.
- // * How useful is the page to the user if this resource is not loaded yet.
-
- switch (type) {
- // Main frames are the highest priority because they can block nearly every
- // type of other resource and there is no useful display without them.
- // Sub frames are a close second, however it is a common pattern to wrap
- // ads in an iframe or even in multiple nested iframes. It is worth
- // investigating if there is a better priority for them.
- case ResourceType::MAIN_FRAME:
- case ResourceType::SUB_FRAME:
+net::RequestPriority DetermineRequestPriority(
+ const ResourceHostMsg_Request& request_data) {
+ switch (request_data.priority) {
+ case WebKit::WebURLRequest::PriorityVeryHigh:
return net::HIGHEST;
- // Stylesheets and scripts can block rendering and loading of other
- // resources. Fonts can block text from rendering.
- case ResourceType::STYLESHEET:
- case ResourceType::SCRIPT:
- case ResourceType::FONT_RESOURCE:
+ case WebKit::WebURLRequest::PriorityHigh:
return net::MEDIUM;
- // Sub resources, objects and media are lower priority than potentially
- // blocking stylesheets, scripts and fonts, but are higher priority than
- // images because if they exist they are probably more central to the page
- // focus than images on the page.
- case ResourceType::SUB_RESOURCE:
- case ResourceType::OBJECT:
- case ResourceType::MEDIA:
- case ResourceType::WORKER:
- case ResourceType::SHARED_WORKER:
- case ResourceType::XHR:
+ case WebKit::WebURLRequest::PriorityMedium:
return net::LOW;
- // Images are the "lowest" priority because they typically do not block
- // downloads or rendering and most pages have some useful content without
- // them.
- case ResourceType::IMAGE:
- // Favicons aren't required for rendering the current page, but
- // are user visible.
- case ResourceType::FAVICON:
+ case WebKit::WebURLRequest::PriorityLow:
return net::LOWEST;
- // Prefetches are at a lower priority than even LOWEST, since they are not
- // even required for rendering of the current page.
- case ResourceType::PREFETCH:
+ case WebKit::WebURLRequest::PriorityVeryLow:
return net::IDLE;
+ case WebKit::WebURLRequest::PriorityUnresolved:
default:
- // When new resource types are added, their priority must be considered.
NOTREACHED();
return net::LOW;
}
@@ -954,7 +922,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
request->set_load_flags(load_flags);
- request->set_priority(DetermineRequestPriority(request_data.resource_type));
+ request->set_priority(DetermineRequestPriority(request_data));
// Resolve elements from request_body and prepare upload data.
if (request_data.request_body) {