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