OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 int route_id, | 1141 int route_id, |
1142 int process_type, | 1142 int process_type, |
1143 int child_id, | 1143 int child_id, |
1144 ResourceContext* resource_context) { | 1144 ResourceContext* resource_context) { |
1145 // Construct the IPC resource handler. | 1145 // Construct the IPC resource handler. |
1146 scoped_ptr<ResourceHandler> handler; | 1146 scoped_ptr<ResourceHandler> handler; |
1147 if (sync_result) { | 1147 if (sync_result) { |
1148 handler.reset(new SyncResourceHandler(request, sync_result, this)); | 1148 handler.reset(new SyncResourceHandler(request, sync_result, this)); |
1149 } else { | 1149 } else { |
1150 handler.reset(new AsyncResourceHandler(request, this)); | 1150 handler.reset(new AsyncResourceHandler(request, this)); |
1151 if (IsDetachableResourceType(request_data.resource_type)) { | |
1152 handler.reset(new DetachableResourceHandler( | |
1153 request, | |
1154 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | |
1155 handler.Pass())); | |
1156 } | |
1157 } | 1151 } |
1158 | 1152 |
1159 // The RedirectToFileResourceHandler depends on being next in the chain. | 1153 // The RedirectToFileResourceHandler depends on being next in the chain. |
1160 if (request_data.download_to_file) { | 1154 if (request_data.download_to_file) { |
1161 handler.reset( | 1155 handler.reset( |
1162 new RedirectToFileResourceHandler(handler.Pass(), request, this)); | 1156 new RedirectToFileResourceHandler(handler.Pass(), request)); |
| 1157 } |
| 1158 |
| 1159 // Prefetches and <a ping> requests outlive their child process. |
| 1160 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { |
| 1161 handler.reset(new DetachableResourceHandler( |
| 1162 request, |
| 1163 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
| 1164 handler.Pass())); |
1163 } | 1165 } |
1164 | 1166 |
1165 // Install a CrossSiteResourceHandler for all main frame requests. This will | 1167 // Install a CrossSiteResourceHandler for all main frame requests. This will |
1166 // let us check whether a transfer is required and pause for the unload | 1168 // let us check whether a transfer is required and pause for the unload |
1167 // handler either if so or if a cross-process navigation is already under way. | 1169 // handler either if so or if a cross-process navigation is already under way. |
1168 bool is_swappable_navigation = | 1170 bool is_swappable_navigation = |
1169 request_data.resource_type == ResourceType::MAIN_FRAME; | 1171 request_data.resource_type == ResourceType::MAIN_FRAME; |
1170 // If we are using --site-per-process, install it for subframes as well. | 1172 // If we are using --site-per-process, install it for subframes as well. |
1171 if (!is_swappable_navigation && | 1173 if (!is_swappable_navigation && |
1172 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 1174 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1209 |
1208 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1210 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
1209 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1211 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
1210 } | 1212 } |
1211 | 1213 |
1212 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { | 1214 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { |
1213 // TODO(michaeln): maybe throttle DataDownloaded messages | 1215 // TODO(michaeln): maybe throttle DataDownloaded messages |
1214 } | 1216 } |
1215 | 1217 |
1216 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( | 1218 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( |
1217 int child_id, int request_id, ShareableFileReference* reference) { | 1219 int child_id, int request_id, const base::FilePath& file_path) { |
| 1220 scoped_refptr<ShareableFileReference> reference = |
| 1221 ShareableFileReference::Get(file_path); |
| 1222 DCHECK(reference); |
| 1223 |
1218 registered_temp_files_[child_id][request_id] = reference; | 1224 registered_temp_files_[child_id][request_id] = reference; |
1219 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 1225 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
1220 child_id, reference->path()); | 1226 child_id, reference->path()); |
1221 | 1227 |
1222 // When the temp file is deleted, revoke permissions that the renderer has | 1228 // When the temp file is deleted, revoke permissions that the renderer has |
1223 // to that file. This covers an edge case where the file is deleted and then | 1229 // to that file. This covers an edge case where the file is deleted and then |
1224 // the same name is re-used for some other purpose, we don't want the old | 1230 // the same name is re-used for some other purpose, we don't want the old |
1225 // renderer to still have access to it. | 1231 // renderer to still have access to it. |
1226 // | 1232 // |
1227 // We do this when the file is deleted because the renderer can take a blob | 1233 // We do this when the file is deleted because the renderer can take a blob |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 1999 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
1994 && !policy->CanReadRawCookies(child_id)) { | 2000 && !policy->CanReadRawCookies(child_id)) { |
1995 VLOG(1) << "Denied unauthorized request for raw headers"; | 2001 VLOG(1) << "Denied unauthorized request for raw headers"; |
1996 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 2002 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
1997 } | 2003 } |
1998 | 2004 |
1999 return load_flags; | 2005 return load_flags; |
2000 } | 2006 } |
2001 | 2007 |
2002 } // namespace content | 2008 } // namespace content |
OLD | NEW |