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 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 int route_id, | 1149 int route_id, |
1150 int process_type, | 1150 int process_type, |
1151 int child_id, | 1151 int child_id, |
1152 ResourceContext* resource_context) { | 1152 ResourceContext* resource_context) { |
1153 // Construct the IPC resource handler. | 1153 // Construct the IPC resource handler. |
1154 scoped_ptr<ResourceHandler> handler; | 1154 scoped_ptr<ResourceHandler> handler; |
1155 if (sync_result) { | 1155 if (sync_result) { |
1156 handler.reset(new SyncResourceHandler(request, sync_result, this)); | 1156 handler.reset(new SyncResourceHandler(request, sync_result, this)); |
1157 } else { | 1157 } else { |
1158 handler.reset(new AsyncResourceHandler(request, this)); | 1158 handler.reset(new AsyncResourceHandler(request, this)); |
| 1159 if (IsDetachableResourceType(request_data.resource_type)) { |
| 1160 handler.reset(new DetachableResourceHandler( |
| 1161 request, |
| 1162 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
| 1163 handler.Pass())); |
| 1164 } |
1159 } | 1165 } |
1160 | 1166 |
1161 // The RedirectToFileResourceHandler depends on being next in the chain. | 1167 // The RedirectToFileResourceHandler depends on being next in the chain. |
1162 if (request_data.download_to_file) { | 1168 if (request_data.download_to_file) { |
1163 handler.reset( | 1169 handler.reset( |
1164 new RedirectToFileResourceHandler(handler.Pass(), request)); | 1170 new RedirectToFileResourceHandler(handler.Pass(), request, this)); |
1165 } | |
1166 | |
1167 // Prefetches and <a ping> requests outlive their child process. | |
1168 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { | |
1169 handler.reset(new DetachableResourceHandler( | |
1170 request, | |
1171 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | |
1172 handler.Pass())); | |
1173 } | 1171 } |
1174 | 1172 |
1175 // Install a CrossSiteResourceHandler for all main frame requests. This will | 1173 // Install a CrossSiteResourceHandler for all main frame requests. This will |
1176 // let us check whether a transfer is required and pause for the unload | 1174 // let us check whether a transfer is required and pause for the unload |
1177 // handler either if so or if a cross-process navigation is already under way. | 1175 // handler either if so or if a cross-process navigation is already under way. |
1178 bool is_swappable_navigation = | 1176 bool is_swappable_navigation = |
1179 request_data.resource_type == ResourceType::MAIN_FRAME; | 1177 request_data.resource_type == ResourceType::MAIN_FRAME; |
1180 // If we are using --site-per-process, install it for subframes as well. | 1178 // If we are using --site-per-process, install it for subframes as well. |
1181 if (!is_swappable_navigation && | 1179 if (!is_swappable_navigation && |
1182 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 1180 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 | 1215 |
1218 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1216 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
1219 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1217 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
1220 } | 1218 } |
1221 | 1219 |
1222 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { | 1220 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { |
1223 // TODO(michaeln): maybe throttle DataDownloaded messages | 1221 // TODO(michaeln): maybe throttle DataDownloaded messages |
1224 } | 1222 } |
1225 | 1223 |
1226 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( | 1224 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( |
1227 int child_id, int request_id, const base::FilePath& file_path) { | 1225 int child_id, int request_id, ShareableFileReference* reference) { |
1228 scoped_refptr<ShareableFileReference> reference = | |
1229 ShareableFileReference::Get(file_path); | |
1230 DCHECK(reference); | |
1231 | |
1232 registered_temp_files_[child_id][request_id] = reference; | 1226 registered_temp_files_[child_id][request_id] = reference; |
1233 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 1227 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
1234 child_id, reference->path()); | 1228 child_id, reference->path()); |
1235 | 1229 |
1236 // When the temp file is deleted, revoke permissions that the renderer has | 1230 // When the temp file is deleted, revoke permissions that the renderer has |
1237 // to that file. This covers an edge case where the file is deleted and then | 1231 // to that file. This covers an edge case where the file is deleted and then |
1238 // the same name is re-used for some other purpose, we don't want the old | 1232 // the same name is re-used for some other purpose, we don't want the old |
1239 // renderer to still have access to it. | 1233 // renderer to still have access to it. |
1240 // | 1234 // |
1241 // We do this when the file is deleted because the renderer can take a blob | 1235 // We do this when the file is deleted because the renderer can take a blob |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 2005 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
2012 && !policy->CanReadRawCookies(child_id)) { | 2006 && !policy->CanReadRawCookies(child_id)) { |
2013 VLOG(1) << "Denied unauthorized request for raw headers"; | 2007 VLOG(1) << "Denied unauthorized request for raw headers"; |
2014 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 2008 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
2015 } | 2009 } |
2016 | 2010 |
2017 return load_flags; | 2011 return load_flags; |
2018 } | 2012 } |
2019 | 2013 |
2020 } // namespace content | 2014 } // namespace content |
OLD | NEW |