| 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 <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 #include "storage/browser/blob/blob_url_request_job_factory.h" | 112 #include "storage/browser/blob/blob_url_request_job_factory.h" |
| 113 #include "storage/browser/blob/shareable_file_reference.h" | 113 #include "storage/browser/blob/shareable_file_reference.h" |
| 114 #include "storage/browser/fileapi/file_permission_policy.h" | 114 #include "storage/browser/fileapi/file_permission_policy.h" |
| 115 #include "storage/browser/fileapi/file_system_context.h" | 115 #include "storage/browser/fileapi/file_system_context.h" |
| 116 #include "url/url_constants.h" | 116 #include "url/url_constants.h" |
| 117 | 117 |
| 118 using base::Time; | 118 using base::Time; |
| 119 using base::TimeDelta; | 119 using base::TimeDelta; |
| 120 using base::TimeTicks; | 120 using base::TimeTicks; |
| 121 using storage::ShareableFileReference; | 121 using storage::ShareableFileReference; |
| 122 using SyncLoadResultCallback = |
| 123 content::ResourceDispatcherHostImpl::SyncLoadResultCallback; |
| 122 | 124 |
| 123 // ---------------------------------------------------------------------------- | 125 // ---------------------------------------------------------------------------- |
| 124 | 126 |
| 125 namespace content { | 127 namespace content { |
| 126 | 128 |
| 127 namespace { | 129 namespace { |
| 128 | 130 |
| 129 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; | 131 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; |
| 130 | 132 |
| 131 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates | 133 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 case RESOURCE_TYPE_PREFETCH: | 216 case RESOURCE_TYPE_PREFETCH: |
| 215 case RESOURCE_TYPE_PING: | 217 case RESOURCE_TYPE_PING: |
| 216 case RESOURCE_TYPE_CSP_REPORT: | 218 case RESOURCE_TYPE_CSP_REPORT: |
| 217 return true; | 219 return true; |
| 218 default: | 220 default: |
| 219 return false; | 221 return false; |
| 220 } | 222 } |
| 221 } | 223 } |
| 222 | 224 |
| 223 // Aborts a request before an URLRequest has actually been created. | 225 // Aborts a request before an URLRequest has actually been created. |
| 224 void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, | 226 void AbortRequestBeforeItStarts( |
| 225 IPC::Message* sync_result, | 227 ResourceMessageFilter* filter, |
| 226 int request_id, | 228 const SyncLoadResultCallback& sync_result_handler, |
| 227 mojom::URLLoaderClientPtr url_loader_client) { | 229 int request_id, |
| 228 if (sync_result) { | 230 mojom::URLLoaderClientPtr url_loader_client) { |
| 231 if (sync_result_handler) { |
| 229 SyncLoadResult result; | 232 SyncLoadResult result; |
| 230 result.error_code = net::ERR_ABORTED; | 233 result.error_code = net::ERR_ABORTED; |
| 231 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); | 234 sync_result_handler.Run(&result); |
| 232 filter->Send(sync_result); | |
| 233 } else { | 235 } else { |
| 234 // Tell the renderer that this request was disallowed. | 236 // Tell the renderer that this request was disallowed. |
| 235 ResourceRequestCompletionStatus request_complete_data; | 237 ResourceRequestCompletionStatus request_complete_data; |
| 236 request_complete_data.error_code = net::ERR_ABORTED; | 238 request_complete_data.error_code = net::ERR_ABORTED; |
| 237 request_complete_data.was_ignored_by_handler = false; | 239 request_complete_data.was_ignored_by_handler = false; |
| 238 request_complete_data.exists_in_cache = false; | 240 request_complete_data.exists_in_cache = false; |
| 239 // No security info needed, connection not established. | 241 // No security info needed, connection not established. |
| 240 request_complete_data.completion_time = base::TimeTicks(); | 242 request_complete_data.completion_time = base::TimeTicks(); |
| 241 request_complete_data.encoded_data_length = 0; | 243 request_complete_data.encoded_data_length = 0; |
| 242 if (url_loader_client) { | 244 if (url_loader_client) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (frame_host) | 409 if (frame_host) |
| 408 routing_ids->insert(frame_host->GetGlobalFrameRoutingId()); | 410 routing_ids->insert(frame_host->GetGlobalFrameRoutingId()); |
| 409 if (pending_frame_host) | 411 if (pending_frame_host) |
| 410 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId()); | 412 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId()); |
| 411 } | 413 } |
| 412 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 414 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 413 base::Bind(&NotifyForRouteSetOnIO, frame_callback, | 415 base::Bind(&NotifyForRouteSetOnIO, frame_callback, |
| 414 base::Passed(std::move(routing_ids)))); | 416 base::Passed(std::move(routing_ids)))); |
| 415 } | 417 } |
| 416 | 418 |
| 419 // Sends back the result of a synchronous loading result to the renderer through |
| 420 // Chrome IPC. |
| 421 void HandleSyncLoadResult(base::WeakPtr<ResourceMessageFilter> filter, |
| 422 std::unique_ptr<IPC::Message> sync_result, |
| 423 const SyncLoadResult* result) { |
| 424 if (!filter) |
| 425 return; |
| 426 |
| 427 if (result) { |
| 428 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result.get(), *result); |
| 429 } else { |
| 430 sync_result->set_reply_error(); |
| 431 } |
| 432 filter->Send(sync_result.release()); |
| 433 } |
| 434 |
| 417 } // namespace | 435 } // namespace |
| 418 | 436 |
| 419 ResourceDispatcherHostImpl::LoadInfo::LoadInfo() {} | 437 ResourceDispatcherHostImpl::LoadInfo::LoadInfo() {} |
| 420 ResourceDispatcherHostImpl::LoadInfo::LoadInfo(const LoadInfo& other) = default; | 438 ResourceDispatcherHostImpl::LoadInfo::LoadInfo(const LoadInfo& other) = default; |
| 421 ResourceDispatcherHostImpl::LoadInfo::~LoadInfo() {} | 439 ResourceDispatcherHostImpl::LoadInfo::~LoadInfo() {} |
| 422 | 440 |
| 423 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} | 441 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} |
| 424 | 442 |
| 425 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} | 443 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} |
| 426 | 444 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 !IsBrowserSideNavigationEnabled()) { | 1070 !IsBrowserSideNavigationEnabled()) { |
| 1053 BrowserThread::PostTask( | 1071 BrowserThread::PostTask( |
| 1054 BrowserThread::UI, | 1072 BrowserThread::UI, |
| 1055 FROM_HERE, | 1073 FROM_HERE, |
| 1056 base::Bind(&LogResourceRequestTimeOnUI, | 1074 base::Bind(&LogResourceRequestTimeOnUI, |
| 1057 TimeTicks::Now(), | 1075 TimeTicks::Now(), |
| 1058 filter_->child_id(), | 1076 filter_->child_id(), |
| 1059 request_data.render_frame_id, | 1077 request_data.render_frame_id, |
| 1060 request_data.url)); | 1078 request_data.url)); |
| 1061 } | 1079 } |
| 1062 BeginRequest(request_id, request_data, NULL, routing_id, | 1080 BeginRequest(request_id, request_data, SyncLoadResultCallback(), routing_id, |
| 1063 std::move(mojo_request), std::move(url_loader_client)); | 1081 std::move(mojo_request), std::move(url_loader_client)); |
| 1064 } | 1082 } |
| 1065 | 1083 |
| 1066 // Begins a resource request with the given params on behalf of the specified | 1084 // Begins a resource request with the given params on behalf of the specified |
| 1067 // child process. Responses will be dispatched through the given receiver. The | 1085 // child process. Responses will be dispatched through the given receiver. The |
| 1068 // process ID is used to lookup WebContentsImpl from routing_id's in the case of | 1086 // process ID is used to lookup WebContentsImpl from routing_id's in the case of |
| 1069 // a request from a renderer. request_context is the cookie/cache context to be | 1087 // a request from a renderer. request_context is the cookie/cache context to be |
| 1070 // used for this request. | 1088 // used for this request. |
| 1071 // | 1089 // |
| 1072 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 1090 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
| 1073 // a normal asynchronous set of response messages will be generated. | 1091 // a normal asynchronous set of response messages will be generated. |
| 1074 void ResourceDispatcherHostImpl::OnSyncLoad(int request_id, | 1092 void ResourceDispatcherHostImpl::OnSyncLoad(int request_id, |
| 1075 const ResourceRequest& request_data, | 1093 const ResourceRequest& request_data, |
| 1076 IPC::Message* sync_result) { | 1094 IPC::Message* sync_result) { |
| 1077 BeginRequest(request_id, request_data, sync_result, sync_result->routing_id(), | 1095 SyncLoadResultCallback callback = base::Bind( |
| 1096 &HandleSyncLoadResult, filter_->GetWeakPtr(), |
| 1097 base::Passed(WrapUnique(sync_result))); |
| 1098 BeginRequest(request_id, request_data, callback, sync_result->routing_id(), |
| 1078 nullptr, nullptr); | 1099 nullptr, nullptr); |
| 1079 } | 1100 } |
| 1080 | 1101 |
| 1081 bool ResourceDispatcherHostImpl::IsRequestIDInUse( | 1102 bool ResourceDispatcherHostImpl::IsRequestIDInUse( |
| 1082 const GlobalRequestID& id) const { | 1103 const GlobalRequestID& id) const { |
| 1083 if (pending_loaders_.find(id) != pending_loaders_.end()) | 1104 if (pending_loaders_.find(id) != pending_loaders_.end()) |
| 1084 return true; | 1105 return true; |
| 1085 for (const auto& blocked_loaders : blocked_loaders_map_) { | 1106 for (const auto& blocked_loaders : blocked_loaders_map_) { |
| 1086 for (const auto& loader : *blocked_loaders.second.get()) { | 1107 for (const auto& loader : *blocked_loaders.second.get()) { |
| 1087 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1108 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 } | 1195 } |
| 1175 } | 1196 } |
| 1176 | 1197 |
| 1177 // We should have a CrossSiteResourceHandler to finish the transfer. | 1198 // We should have a CrossSiteResourceHandler to finish the transfer. |
| 1178 DCHECK(info->cross_site_handler()); | 1199 DCHECK(info->cross_site_handler()); |
| 1179 } | 1200 } |
| 1180 | 1201 |
| 1181 void ResourceDispatcherHostImpl::BeginRequest( | 1202 void ResourceDispatcherHostImpl::BeginRequest( |
| 1182 int request_id, | 1203 int request_id, |
| 1183 const ResourceRequest& request_data, | 1204 const ResourceRequest& request_data, |
| 1184 IPC::Message* sync_result, // only valid for sync | 1205 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
| 1185 int route_id, | 1206 int route_id, |
| 1186 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 1207 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
| 1187 mojom::URLLoaderClientPtr url_loader_client) { | 1208 mojom::URLLoaderClientPtr url_loader_client) { |
| 1188 int process_type = filter_->process_type(); | 1209 int process_type = filter_->process_type(); |
| 1189 int child_id = filter_->child_id(); | 1210 int child_id = filter_->child_id(); |
| 1190 | 1211 |
| 1191 // Reject request id that's currently in use. | 1212 // Reject request id that's currently in use. |
| 1192 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { | 1213 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { |
| 1193 bad_message::ReceivedBadMessage(filter_, | 1214 bad_message::ReceivedBadMessage(filter_, |
| 1194 bad_message::RDH_INVALID_REQUEST_ID); | 1215 bad_message::RDH_INVALID_REQUEST_ID); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 &request_context); | 1270 &request_context); |
| 1250 | 1271 |
| 1251 // Parse the headers before calling ShouldServiceRequest, so that they are | 1272 // Parse the headers before calling ShouldServiceRequest, so that they are |
| 1252 // available to be validated. | 1273 // available to be validated. |
| 1253 net::HttpRequestHeaders headers; | 1274 net::HttpRequestHeaders headers; |
| 1254 headers.AddHeadersFromString(request_data.headers); | 1275 headers.AddHeadersFromString(request_data.headers); |
| 1255 | 1276 |
| 1256 if (is_shutdown_ || | 1277 if (is_shutdown_ || |
| 1257 !ShouldServiceRequest(process_type, child_id, request_data, headers, | 1278 !ShouldServiceRequest(process_type, child_id, request_data, headers, |
| 1258 filter_, resource_context)) { | 1279 filter_, resource_context)) { |
| 1259 AbortRequestBeforeItStarts(filter_, sync_result, request_id, | 1280 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, |
| 1260 std::move(url_loader_client)); | 1281 std::move(url_loader_client)); |
| 1261 return; | 1282 return; |
| 1262 } | 1283 } |
| 1263 // Check if we have a registered interceptor for the headers passed in. If | 1284 // Check if we have a registered interceptor for the headers passed in. If |
| 1264 // yes then we need to mark the current request as pending and wait for the | 1285 // yes then we need to mark the current request as pending and wait for the |
| 1265 // interceptor to invoke the callback with a status code indicating whether | 1286 // interceptor to invoke the callback with a status code indicating whether |
| 1266 // the request needs to be aborted or continued. | 1287 // the request needs to be aborted or continued. |
| 1267 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { | 1288 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
| 1268 HeaderInterceptorMap::iterator index = | 1289 HeaderInterceptorMap::iterator index = |
| 1269 http_header_interceptor_map_.find(it.name()); | 1290 http_header_interceptor_map_.find(it.name()); |
| 1270 if (index != http_header_interceptor_map_.end()) { | 1291 if (index != http_header_interceptor_map_.end()) { |
| 1271 HeaderInterceptorInfo& interceptor_info = index->second; | 1292 HeaderInterceptorInfo& interceptor_info = index->second; |
| 1272 | 1293 |
| 1273 bool call_interceptor = true; | 1294 bool call_interceptor = true; |
| 1274 if (!interceptor_info.starts_with.empty()) { | 1295 if (!interceptor_info.starts_with.empty()) { |
| 1275 call_interceptor = | 1296 call_interceptor = |
| 1276 base::StartsWith(it.value(), interceptor_info.starts_with, | 1297 base::StartsWith(it.value(), interceptor_info.starts_with, |
| 1277 base::CompareCase::INSENSITIVE_ASCII); | 1298 base::CompareCase::INSENSITIVE_ASCII); |
| 1278 } | 1299 } |
| 1279 if (call_interceptor) { | 1300 if (call_interceptor) { |
| 1280 interceptor_info.interceptor.Run( | 1301 interceptor_info.interceptor.Run( |
| 1281 it.name(), it.value(), child_id, resource_context, | 1302 it.name(), it.value(), child_id, resource_context, |
| 1282 base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest, | 1303 base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest, |
| 1283 base::Unretained(this), request_id, request_data, | 1304 base::Unretained(this), request_id, request_data, |
| 1284 sync_result, route_id, headers, | 1305 sync_result_handler, route_id, headers, |
| 1285 base::Passed(std::move(mojo_request)), | 1306 base::Passed(std::move(mojo_request)), |
| 1286 base::Passed(std::move(url_loader_client)))); | 1307 base::Passed(std::move(url_loader_client)))); |
| 1287 return; | 1308 return; |
| 1288 } | 1309 } |
| 1289 } | 1310 } |
| 1290 } | 1311 } |
| 1291 ContinuePendingBeginRequest(request_id, request_data, sync_result, route_id, | 1312 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler, |
| 1292 headers, std::move(mojo_request), | 1313 route_id, headers, std::move(mojo_request), |
| 1293 std::move(url_loader_client), true, 0); | 1314 std::move(url_loader_client), true, 0); |
| 1294 } | 1315 } |
| 1295 | 1316 |
| 1296 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( | 1317 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( |
| 1297 int request_id, | 1318 int request_id, |
| 1298 const ResourceRequest& request_data, | 1319 const ResourceRequest& request_data, |
| 1299 IPC::Message* sync_result, // only valid for sync | 1320 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
| 1300 int route_id, | 1321 int route_id, |
| 1301 const net::HttpRequestHeaders& headers, | 1322 const net::HttpRequestHeaders& headers, |
| 1302 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 1323 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
| 1303 mojom::URLLoaderClientPtr url_loader_client, | 1324 mojom::URLLoaderClientPtr url_loader_client, |
| 1304 bool continue_request, | 1325 bool continue_request, |
| 1305 int error_code) { | 1326 int error_code) { |
| 1306 if (!continue_request) { | 1327 if (!continue_request) { |
| 1307 // TODO(ananta): Find a way to specify the right error code here. Passing | 1328 // TODO(ananta): Find a way to specify the right error code here. Passing |
| 1308 // in a non-content error code is not safe. | 1329 // in a non-content error code is not safe. |
| 1309 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN); | 1330 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN); |
| 1310 AbortRequestBeforeItStarts(filter_, sync_result, request_id, | 1331 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, |
| 1311 std::move(url_loader_client)); | 1332 std::move(url_loader_client)); |
| 1312 return; | 1333 return; |
| 1313 } | 1334 } |
| 1314 | 1335 |
| 1315 int process_type = filter_->process_type(); | 1336 int process_type = filter_->process_type(); |
| 1316 int child_id = filter_->child_id(); | 1337 int child_id = filter_->child_id(); |
| 1317 | 1338 |
| 1318 bool is_navigation_stream_request = | 1339 bool is_navigation_stream_request = |
| 1319 IsBrowserSideNavigationEnabled() && | 1340 IsBrowserSideNavigationEnabled() && |
| 1320 IsResourceTypeFrame(request_data.resource_type) && | 1341 IsResourceTypeFrame(request_data.resource_type) && |
| 1321 process_type == PROCESS_TYPE_RENDERER; | 1342 process_type == PROCESS_TYPE_RENDERER; |
| 1322 | 1343 |
| 1323 ResourceContext* resource_context = NULL; | 1344 ResourceContext* resource_context = NULL; |
| 1324 net::URLRequestContext* request_context = NULL; | 1345 net::URLRequestContext* request_context = NULL; |
| 1325 filter_->GetContexts(request_data.resource_type, &resource_context, | 1346 filter_->GetContexts(request_data.resource_type, &resource_context, |
| 1326 &request_context); | 1347 &request_context); |
| 1327 | 1348 |
| 1328 // Allow the observer to block/handle the request. | 1349 // Allow the observer to block/handle the request. |
| 1329 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, | 1350 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, |
| 1330 request_data.url, | 1351 request_data.url, |
| 1331 request_data.resource_type, | 1352 request_data.resource_type, |
| 1332 resource_context)) { | 1353 resource_context)) { |
| 1333 AbortRequestBeforeItStarts(filter_, sync_result, request_id, | 1354 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, |
| 1334 std::move(url_loader_client)); | 1355 std::move(url_loader_client)); |
| 1335 return; | 1356 return; |
| 1336 } | 1357 } |
| 1337 | 1358 |
| 1338 // Construct the request. | 1359 // Construct the request. |
| 1339 std::unique_ptr<net::URLRequest> new_request = request_context->CreateRequest( | 1360 std::unique_ptr<net::URLRequest> new_request = request_context->CreateRequest( |
| 1340 is_navigation_stream_request ? request_data.resource_body_stream_url | 1361 is_navigation_stream_request ? request_data.resource_body_stream_url |
| 1341 : request_data.url, | 1362 : request_data.url, |
| 1342 request_data.priority, nullptr); | 1363 request_data.priority, nullptr); |
| 1343 | 1364 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 } | 1417 } |
| 1397 new_request->set_upload(UploadDataStreamBuilder::Build( | 1418 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 1398 request_data.request_body.get(), blob_context, | 1419 request_data.request_body.get(), blob_context, |
| 1399 filter_->file_system_context(), | 1420 filter_->file_system_context(), |
| 1400 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 1421 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
| 1401 } | 1422 } |
| 1402 | 1423 |
| 1403 bool allow_download = request_data.allow_download && | 1424 bool allow_download = request_data.allow_download && |
| 1404 IsResourceTypeFrame(request_data.resource_type); | 1425 IsResourceTypeFrame(request_data.resource_type); |
| 1405 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login; | 1426 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login; |
| 1406 bool is_sync_load = sync_result != NULL; | 1427 bool is_sync_load = !!sync_result_handler; |
| 1407 | 1428 |
| 1408 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only | 1429 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only |
| 1409 // allow requesting them if requester has ReadRawCookies permission. | 1430 // allow requesting them if requester has ReadRawCookies permission. |
| 1410 ChildProcessSecurityPolicyImpl* policy = | 1431 ChildProcessSecurityPolicyImpl* policy = |
| 1411 ChildProcessSecurityPolicyImpl::GetInstance(); | 1432 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 1412 bool report_raw_headers = request_data.report_raw_headers; | 1433 bool report_raw_headers = request_data.report_raw_headers; |
| 1413 if (report_raw_headers && !policy->CanReadRawCookies(child_id)) { | 1434 if (report_raw_headers && !policy->CanReadRawCookies(child_id)) { |
| 1414 // TODO: crbug.com/523063 can we call bad_message::ReceivedBadMessage here? | 1435 // TODO: crbug.com/523063 can we call bad_message::ReceivedBadMessage here? |
| 1415 VLOG(1) << "Denied unauthorized request for raw headers"; | 1436 VLOG(1) << "Denied unauthorized request for raw headers"; |
| 1416 report_raw_headers = false; | 1437 report_raw_headers = false; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 request_data.fetch_frame_type, request_data.request_body, | 1529 request_data.fetch_frame_type, request_data.request_body, |
| 1509 request_data.initiated_in_secure_context); | 1530 request_data.initiated_in_secure_context); |
| 1510 | 1531 |
| 1511 // Have the appcache associate its extra info with the request. | 1532 // Have the appcache associate its extra info with the request. |
| 1512 AppCacheInterceptor::SetExtraRequestInfo( | 1533 AppCacheInterceptor::SetExtraRequestInfo( |
| 1513 new_request.get(), filter_->appcache_service(), child_id, | 1534 new_request.get(), filter_->appcache_service(), child_id, |
| 1514 request_data.appcache_host_id, request_data.resource_type, | 1535 request_data.appcache_host_id, request_data.resource_type, |
| 1515 request_data.should_reset_appcache); | 1536 request_data.should_reset_appcache); |
| 1516 | 1537 |
| 1517 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( | 1538 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( |
| 1518 new_request.get(), request_data, sync_result, route_id, process_type, | 1539 new_request.get(), request_data, sync_result_handler, route_id, |
| 1519 child_id, resource_context, std::move(mojo_request), | 1540 process_type, child_id, resource_context, std::move(mojo_request), |
| 1520 std::move(url_loader_client))); | 1541 std::move(url_loader_client))); |
| 1521 | 1542 |
| 1522 if (handler) | 1543 if (handler) |
| 1523 BeginRequestInternal(std::move(new_request), std::move(handler)); | 1544 BeginRequestInternal(std::move(new_request), std::move(handler)); |
| 1524 } | 1545 } |
| 1525 | 1546 |
| 1526 std::unique_ptr<ResourceHandler> | 1547 std::unique_ptr<ResourceHandler> |
| 1527 ResourceDispatcherHostImpl::CreateResourceHandler( | 1548 ResourceDispatcherHostImpl::CreateResourceHandler( |
| 1528 net::URLRequest* request, | 1549 net::URLRequest* request, |
| 1529 const ResourceRequest& request_data, | 1550 const ResourceRequest& request_data, |
| 1530 IPC::Message* sync_result, | 1551 const SyncLoadResultCallback& sync_result_handler, |
| 1531 int route_id, | 1552 int route_id, |
| 1532 int process_type, | 1553 int process_type, |
| 1533 int child_id, | 1554 int child_id, |
| 1534 ResourceContext* resource_context, | 1555 ResourceContext* resource_context, |
| 1535 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 1556 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
| 1536 mojom::URLLoaderClientPtr url_loader_client) { | 1557 mojom::URLLoaderClientPtr url_loader_client) { |
| 1537 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. | 1558 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. |
| 1538 tracked_objects::ScopedTracker tracking_profile( | 1559 tracked_objects::ScopedTracker tracking_profile( |
| 1539 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1560 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1540 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); | 1561 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); |
| 1541 // Construct the IPC resource handler. | 1562 // Construct the IPC resource handler. |
| 1542 std::unique_ptr<ResourceHandler> handler; | 1563 std::unique_ptr<ResourceHandler> handler; |
| 1543 if (sync_result) { | 1564 if (sync_result_handler) { |
| 1544 // download_to_file is not supported for synchronous requests. | 1565 // download_to_file is not supported for synchronous requests. |
| 1545 if (request_data.download_to_file) { | 1566 if (request_data.download_to_file) { |
| 1546 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); | 1567 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); |
| 1547 return std::unique_ptr<ResourceHandler>(); | 1568 return std::unique_ptr<ResourceHandler>(); |
| 1548 } | 1569 } |
| 1549 | 1570 |
| 1550 DCHECK(!mojo_request.is_pending()); | 1571 DCHECK(!mojo_request.is_pending()); |
| 1551 DCHECK(!url_loader_client); | 1572 DCHECK(!url_loader_client); |
| 1552 handler.reset(new SyncResourceHandler(request, sync_result, this)); | 1573 handler.reset(new SyncResourceHandler(request, sync_result_handler, this)); |
| 1553 } else { | 1574 } else { |
| 1554 if (mojo_request.is_pending()) { | 1575 if (mojo_request.is_pending()) { |
| 1555 handler.reset(new MojoAsyncResourceHandler(request, this, | 1576 handler.reset(new MojoAsyncResourceHandler(request, this, |
| 1556 std::move(mojo_request), | 1577 std::move(mojo_request), |
| 1557 std::move(url_loader_client))); | 1578 std::move(url_loader_client))); |
| 1558 } else { | 1579 } else { |
| 1559 handler.reset(new AsyncResourceHandler(request, this)); | 1580 handler.reset(new AsyncResourceHandler(request, this)); |
| 1560 } | 1581 } |
| 1561 | 1582 |
| 1562 // The RedirectToFileResourceHandler depends on being next in the chain. | 1583 // The RedirectToFileResourceHandler depends on being next in the chain. |
| 1563 if (request_data.download_to_file) { | 1584 if (request_data.download_to_file) { |
| 1564 handler.reset( | 1585 handler.reset( |
| 1565 new RedirectToFileResourceHandler(std::move(handler), request)); | 1586 new RedirectToFileResourceHandler(std::move(handler), request)); |
| 1566 } | 1587 } |
| 1567 } | 1588 } |
| 1568 | 1589 |
| 1569 bool start_detached = request_data.download_to_network_cache_only; | 1590 bool start_detached = request_data.download_to_network_cache_only; |
| 1570 | 1591 |
| 1571 // Prefetches and <a ping> requests outlive their child process. | 1592 // Prefetches and <a ping> requests outlive their child process. |
| 1572 if (!sync_result && (start_detached || | 1593 if (!sync_result_handler && |
| 1573 IsDetachableResourceType(request_data.resource_type))) { | 1594 (start_detached || |
| 1595 IsDetachableResourceType(request_data.resource_type))) { |
| 1574 std::unique_ptr<DetachableResourceHandler> detachable_handler = | 1596 std::unique_ptr<DetachableResourceHandler> detachable_handler = |
| 1575 base::MakeUnique<DetachableResourceHandler>( | 1597 base::MakeUnique<DetachableResourceHandler>( |
| 1576 request, | 1598 request, |
| 1577 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1599 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
| 1578 std::move(handler)); | 1600 std::move(handler)); |
| 1579 if (start_detached) | 1601 if (start_detached) |
| 1580 detachable_handler->Detach(); | 1602 detachable_handler->Detach(); |
| 1581 handler = std::move(detachable_handler); | 1603 handler = std::move(detachable_handler); |
| 1582 } | 1604 } |
| 1583 | 1605 |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2729 &throttles); | 2751 &throttles); |
| 2730 if (!throttles.empty()) { | 2752 if (!throttles.empty()) { |
| 2731 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2753 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
| 2732 std::move(throttles))); | 2754 std::move(throttles))); |
| 2733 } | 2755 } |
| 2734 } | 2756 } |
| 2735 return handler; | 2757 return handler; |
| 2736 } | 2758 } |
| 2737 | 2759 |
| 2738 } // namespace content | 2760 } // namespace content |
| OLD | NEW |