Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 82273002: Fix various issues in RedirectToFileResourceHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename test fixture Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 int route_id, 1143 int route_id,
1144 int process_type, 1144 int process_type,
1145 int child_id, 1145 int child_id,
1146 ResourceContext* resource_context) { 1146 ResourceContext* resource_context) {
1147 // Construct the IPC resource handler. 1147 // Construct the IPC resource handler.
1148 scoped_ptr<ResourceHandler> handler; 1148 scoped_ptr<ResourceHandler> handler;
1149 if (sync_result) { 1149 if (sync_result) {
1150 handler.reset(new SyncResourceHandler(request, sync_result, this)); 1150 handler.reset(new SyncResourceHandler(request, sync_result, this));
1151 } else { 1151 } else {
1152 handler.reset(new AsyncResourceHandler(request, this)); 1152 handler.reset(new AsyncResourceHandler(request, this));
1153 if (IsDetachableResourceType(request_data.resource_type)) {
1154 handler.reset(new DetachableResourceHandler(
1155 request,
1156 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1157 handler.Pass()));
1158 }
1159 } 1153 }
1160 1154
1161 // The RedirectToFileResourceHandler depends on being next in the chain. 1155 // The RedirectToFileResourceHandler depends on being next in the chain.
1162 if (request_data.download_to_file) { 1156 if (request_data.download_to_file) {
1163 handler.reset( 1157 handler.reset(
1164 new RedirectToFileResourceHandler(handler.Pass(), request, this)); 1158 new RedirectToFileResourceHandler(handler.Pass(), request));
1159 }
1160
1161 // Prefetches and <a ping> requests outlive their child process.
1162 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) {
1163 handler.reset(new DetachableResourceHandler(
1164 request,
1165 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1166 handler.Pass()));
1165 } 1167 }
1166 1168
1167 // Install a CrossSiteResourceHandler for all main frame requests. This will 1169 // Install a CrossSiteResourceHandler for all main frame requests. This will
1168 // let us check whether a transfer is required and pause for the unload 1170 // let us check whether a transfer is required and pause for the unload
1169 // handler either if so or if a cross-process navigation is already under way. 1171 // handler either if so or if a cross-process navigation is already under way.
1170 bool is_swappable_navigation = 1172 bool is_swappable_navigation =
1171 request_data.resource_type == ResourceType::MAIN_FRAME; 1173 request_data.resource_type == ResourceType::MAIN_FRAME;
1172 // If we are using --site-per-process, install it for subframes as well. 1174 // If we are using --site-per-process, install it for subframes as well.
1173 if (!is_swappable_navigation && 1175 if (!is_swappable_navigation &&
1174 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 1176 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1211
1210 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { 1212 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
1211 UnregisterDownloadedTempFile(filter_->child_id(), request_id); 1213 UnregisterDownloadedTempFile(filter_->child_id(), request_id);
1212 } 1214 }
1213 1215
1214 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { 1216 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) {
1215 // TODO(michaeln): maybe throttle DataDownloaded messages 1217 // TODO(michaeln): maybe throttle DataDownloaded messages
1216 } 1218 }
1217 1219
1218 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( 1220 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile(
1219 int child_id, int request_id, ShareableFileReference* reference) { 1221 int child_id, int request_id, const base::FilePath& file_path) {
1222 scoped_refptr<ShareableFileReference> reference =
1223 ShareableFileReference::Get(file_path);
1224 DCHECK(reference);
1225
1220 registered_temp_files_[child_id][request_id] = reference; 1226 registered_temp_files_[child_id][request_id] = reference;
1221 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( 1227 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
1222 child_id, reference->path()); 1228 child_id, reference->path());
1223 1229
1224 // 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
1225 // 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
1226 // 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
1227 // renderer to still have access to it. 1233 // renderer to still have access to it.
1228 // 1234 //
1229 // 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 2000 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
1995 && !policy->CanReadRawCookies(child_id)) { 2001 && !policy->CanReadRawCookies(child_id)) {
1996 VLOG(1) << "Denied unauthorized request for raw headers"; 2002 VLOG(1) << "Denied unauthorized request for raw headers";
1997 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 2003 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
1998 } 2004 }
1999 2005
2000 return load_flags; 2006 return load_flags;
2001 } 2007 }
2002 2008
2003 } // namespace content 2009 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698