OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Consults the RendererSecurity policy to determine whether the | 118 // Consults the RendererSecurity policy to determine whether the |
119 // ResourceDispatcherHost should service this request. A request might be | 119 // ResourceDispatcherHost should service this request. A request might be |
120 // disallowed if the renderer is not authorized to retrieve the request URL or | 120 // disallowed if the renderer is not authorized to retrieve the request URL or |
121 // if the renderer is attempting to upload an unauthorized file. | 121 // if the renderer is attempting to upload an unauthorized file. |
122 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, | 122 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, |
123 int child_id, | 123 int child_id, |
124 const ViewHostMsg_Resource_Request& request_data) { | 124 const ViewHostMsg_Resource_Request& request_data) { |
125 if (process_type == ChildProcessInfo::PLUGIN_PROCESS) | 125 if (process_type == ChildProcessInfo::PLUGIN_PROCESS) |
126 return true; | 126 return true; |
127 | 127 |
| 128 if (request_data.resource_type == ResourceType::PREFETCH && |
| 129 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisablePrefetch)) |
| 130 return false; |
| 131 |
128 ChildProcessSecurityPolicy* policy = | 132 ChildProcessSecurityPolicy* policy = |
129 ChildProcessSecurityPolicy::GetInstance(); | 133 ChildProcessSecurityPolicy::GetInstance(); |
130 | 134 |
131 // Check if the renderer is permitted to request the requested URL. | 135 // Check if the renderer is permitted to request the requested URL. |
132 if (!policy->CanRequestURL(child_id, request_data.url)) { | 136 if (!policy->CanRequestURL(child_id, request_data.url)) { |
133 LOG(INFO) << "Denied unauthorized request for " << | 137 LOG(INFO) << "Denied unauthorized request for " << |
134 request_data.url.possibly_invalid_spec(); | 138 request_data.url.possibly_invalid_spec(); |
135 return false; | 139 return false; |
136 } | 140 } |
137 | 141 |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 // blocking stylesheets, scripts and fonts, but are higher priority than | 1834 // blocking stylesheets, scripts and fonts, but are higher priority than |
1831 // images because if they exist they are probably more central to the page | 1835 // images because if they exist they are probably more central to the page |
1832 // focus than images on the page. | 1836 // focus than images on the page. |
1833 case ResourceType::SUB_RESOURCE: | 1837 case ResourceType::SUB_RESOURCE: |
1834 case ResourceType::OBJECT: | 1838 case ResourceType::OBJECT: |
1835 case ResourceType::MEDIA: | 1839 case ResourceType::MEDIA: |
1836 case ResourceType::WORKER: | 1840 case ResourceType::WORKER: |
1837 case ResourceType::SHARED_WORKER: | 1841 case ResourceType::SHARED_WORKER: |
1838 return net::LOW; | 1842 return net::LOW; |
1839 | 1843 |
1840 // Images are the lowest priority because they typically do not block | 1844 // Images are the "lowest" priority because they typically do not block |
1841 // downloads or rendering and most pages have some useful content without | 1845 // downloads or rendering and most pages have some useful content without |
1842 // them. | 1846 // them. |
1843 case ResourceType::IMAGE: | 1847 case ResourceType::IMAGE: |
1844 return net::LOWEST; | 1848 return net::LOWEST; |
1845 | 1849 |
| 1850 // Prefetches are at a lower priority than even LOWEST, since they |
| 1851 // are not even required for rendering of the current page. |
| 1852 case ResourceType::PREFETCH: |
| 1853 return net::IDLE; |
| 1854 |
1846 default: | 1855 default: |
1847 // When new resource types are added, their priority must be considered. | 1856 // When new resource types are added, their priority must be considered. |
1848 NOTREACHED(); | 1857 NOTREACHED(); |
1849 return net::LOW; | 1858 return net::LOW; |
1850 } | 1859 } |
1851 } | 1860 } |
OLD | NEW |