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

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: Rebase Created 6 years, 11 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 <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 #include "content/browser/loader/async_resource_handler.h" 33 #include "content/browser/loader/async_resource_handler.h"
34 #include "content/browser/loader/buffered_resource_handler.h" 34 #include "content/browser/loader/buffered_resource_handler.h"
35 #include "content/browser/loader/cross_site_resource_handler.h" 35 #include "content/browser/loader/cross_site_resource_handler.h"
36 #include "content/browser/loader/detachable_resource_handler.h" 36 #include "content/browser/loader/detachable_resource_handler.h"
37 #include "content/browser/loader/power_save_block_resource_throttle.h" 37 #include "content/browser/loader/power_save_block_resource_throttle.h"
38 #include "content/browser/loader/redirect_to_file_resource_handler.h" 38 #include "content/browser/loader/redirect_to_file_resource_handler.h"
39 #include "content/browser/loader/resource_message_filter.h" 39 #include "content/browser/loader/resource_message_filter.h"
40 #include "content/browser/loader/resource_request_info_impl.h" 40 #include "content/browser/loader/resource_request_info_impl.h"
41 #include "content/browser/loader/stream_resource_handler.h" 41 #include "content/browser/loader/stream_resource_handler.h"
42 #include "content/browser/loader/sync_resource_handler.h" 42 #include "content/browser/loader/sync_resource_handler.h"
43 #include "content/browser/loader/temporary_file_stream.h"
43 #include "content/browser/loader/throttling_resource_handler.h" 44 #include "content/browser/loader/throttling_resource_handler.h"
44 #include "content/browser/loader/upload_data_stream_builder.h" 45 #include "content/browser/loader/upload_data_stream_builder.h"
45 #include "content/browser/plugin_service_impl.h" 46 #include "content/browser/plugin_service_impl.h"
46 #include "content/browser/renderer_host/render_view_host_delegate.h" 47 #include "content/browser/renderer_host/render_view_host_delegate.h"
47 #include "content/browser/renderer_host/render_view_host_impl.h" 48 #include "content/browser/renderer_host/render_view_host_impl.h"
48 #include "content/browser/resource_context_impl.h" 49 #include "content/browser/resource_context_impl.h"
49 #include "content/browser/streams/stream.h" 50 #include "content/browser/streams/stream.h"
50 #include "content/browser/streams/stream_context.h" 51 #include "content/browser/streams/stream_context.h"
51 #include "content/browser/streams/stream_registry.h" 52 #include "content/browser/streams/stream_registry.h"
52 #include "content/browser/worker_host/worker_service_impl.h" 53 #include "content/browser/worker_host/worker_service_impl.h"
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 int route_id, 1141 int route_id,
1141 int process_type, 1142 int process_type,
1142 int child_id, 1143 int child_id,
1143 ResourceContext* resource_context) { 1144 ResourceContext* resource_context) {
1144 // Construct the IPC resource handler. 1145 // Construct the IPC resource handler.
1145 scoped_ptr<ResourceHandler> handler; 1146 scoped_ptr<ResourceHandler> handler;
1146 if (sync_result) { 1147 if (sync_result) {
1147 handler.reset(new SyncResourceHandler(request, sync_result, this)); 1148 handler.reset(new SyncResourceHandler(request, sync_result, this));
1148 } else { 1149 } else {
1149 handler.reset(new AsyncResourceHandler(request, this)); 1150 handler.reset(new AsyncResourceHandler(request, this));
1150 if (IsDetachableResourceType(request_data.resource_type)) {
1151 handler.reset(new DetachableResourceHandler(
1152 request,
1153 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1154 handler.Pass()));
1155 }
1156 } 1151 }
1157 1152
1158 // The RedirectToFileResourceHandler depends on being next in the chain. 1153 // The RedirectToFileResourceHandler depends on being next in the chain.
1159 if (request_data.download_to_file) { 1154 if (request_data.download_to_file) {
1160 handler.reset( 1155 handler.reset(
1161 new RedirectToFileResourceHandler(handler.Pass(), request, this)); 1156 new RedirectToFileResourceHandler(
1157 handler.Pass(), request,
1158 base::Bind(&CreateTemporaryFileStream)));
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()));
1162 } 1167 }
1163 1168
1164 // Install a CrossSiteResourceHandler for all main frame requests. This will 1169 // Install a CrossSiteResourceHandler for all main frame requests. This will
1165 // 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
1166 // 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.
1167 bool is_swappable_navigation = 1172 bool is_swappable_navigation =
1168 request_data.resource_type == ResourceType::MAIN_FRAME; 1173 request_data.resource_type == ResourceType::MAIN_FRAME;
1169 // 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.
1170 if (!is_swappable_navigation && 1175 if (!is_swappable_navigation &&
1171 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 1176 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1211
1207 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { 1212 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
1208 UnregisterDownloadedTempFile(filter_->child_id(), request_id); 1213 UnregisterDownloadedTempFile(filter_->child_id(), request_id);
1209 } 1214 }
1210 1215
1211 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { 1216 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) {
1212 // TODO(michaeln): maybe throttle DataDownloaded messages 1217 // TODO(michaeln): maybe throttle DataDownloaded messages
1213 } 1218 }
1214 1219
1215 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( 1220 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile(
1216 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 if (!reference) {
1225 NOTREACHED();
1226 return;
1227 }
1228
1217 registered_temp_files_[child_id][request_id] = reference; 1229 registered_temp_files_[child_id][request_id] = reference;
1218 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( 1230 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
1219 child_id, reference->path()); 1231 child_id, reference->path());
1220 1232
1221 // When the temp file is deleted, revoke permissions that the renderer has 1233 // When the temp file is deleted, revoke permissions that the renderer has
1222 // to that file. This covers an edge case where the file is deleted and then 1234 // to that file. This covers an edge case where the file is deleted and then
1223 // the same name is re-used for some other purpose, we don't want the old 1235 // the same name is re-used for some other purpose, we don't want the old
1224 // renderer to still have access to it. 1236 // renderer to still have access to it.
1225 // 1237 //
1226 // We do this when the file is deleted because the renderer can take a blob 1238 // We do this when the file is deleted because the renderer can take a blob
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 1986 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
1975 && !policy->CanReadRawCookies(child_id)) { 1987 && !policy->CanReadRawCookies(child_id)) {
1976 VLOG(1) << "Denied unauthorized request for raw headers"; 1988 VLOG(1) << "Denied unauthorized request for raw headers";
1977 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 1989 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
1978 } 1990 }
1979 1991
1980 return load_flags; 1992 return load_flags;
1981 } 1993 }
1982 1994
1983 } // namespace content 1995 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698