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 18 matching lines...) Expand all Loading... | |
29 #include "content/browser/child_process_security_policy_impl.h" | 29 #include "content/browser/child_process_security_policy_impl.h" |
30 #include "content/browser/download/download_resource_handler.h" | 30 #include "content/browser/download/download_resource_handler.h" |
31 #include "content/browser/download/save_file_manager.h" | 31 #include "content/browser/download/save_file_manager.h" |
32 #include "content/browser/download/save_file_resource_handler.h" | 32 #include "content/browser/download/save_file_resource_handler.h" |
33 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 33 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
34 #include "content/browser/frame_host/navigation_request_info.h" | 34 #include "content/browser/frame_host/navigation_request_info.h" |
35 #include "content/browser/loader/async_resource_handler.h" | 35 #include "content/browser/loader/async_resource_handler.h" |
36 #include "content/browser/loader/buffered_resource_handler.h" | 36 #include "content/browser/loader/buffered_resource_handler.h" |
37 #include "content/browser/loader/cross_site_resource_handler.h" | 37 #include "content/browser/loader/cross_site_resource_handler.h" |
38 #include "content/browser/loader/detachable_resource_handler.h" | 38 #include "content/browser/loader/detachable_resource_handler.h" |
39 #include "content/browser/loader/navigation_resource_handler.h" | |
39 #include "content/browser/loader/power_save_block_resource_throttle.h" | 40 #include "content/browser/loader/power_save_block_resource_throttle.h" |
40 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 41 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
41 #include "content/browser/loader/resource_message_filter.h" | 42 #include "content/browser/loader/resource_message_filter.h" |
42 #include "content/browser/loader/resource_request_info_impl.h" | 43 #include "content/browser/loader/resource_request_info_impl.h" |
43 #include "content/browser/loader/stream_resource_handler.h" | 44 #include "content/browser/loader/stream_resource_handler.h" |
44 #include "content/browser/loader/sync_resource_handler.h" | 45 #include "content/browser/loader/sync_resource_handler.h" |
45 #include "content/browser/loader/throttling_resource_handler.h" | 46 #include "content/browser/loader/throttling_resource_handler.h" |
46 #include "content/browser/loader/upload_data_stream_builder.h" | 47 #include "content/browser/loader/upload_data_stream_builder.h" |
47 #include "content/browser/renderer_host/render_view_host_delegate.h" | 48 #include "content/browser/renderer_host/render_view_host_delegate.h" |
48 #include "content/browser/renderer_host/render_view_host_impl.h" | 49 #include "content/browser/renderer_host/render_view_host_impl.h" |
49 #include "content/browser/resource_context_impl.h" | 50 #include "content/browser/resource_context_impl.h" |
50 #include "content/browser/service_worker/service_worker_request_handler.h" | 51 #include "content/browser/service_worker/service_worker_request_handler.h" |
51 #include "content/browser/streams/stream.h" | 52 #include "content/browser/streams/stream.h" |
52 #include "content/browser/streams/stream_context.h" | 53 #include "content/browser/streams/stream_context.h" |
53 #include "content/browser/streams/stream_registry.h" | 54 #include "content/browser/streams/stream_registry.h" |
54 #include "content/browser/web_contents/web_contents_impl.h" | 55 #include "content/browser/web_contents/web_contents_impl.h" |
55 #include "content/common/appcache_interfaces.h" | 56 #include "content/common/appcache_interfaces.h" |
56 #include "content/common/resource_messages.h" | 57 #include "content/common/resource_messages.h" |
57 #include "content/common/ssl_status_serialization.h" | 58 #include "content/common/ssl_status_serialization.h" |
58 #include "content/common/view_messages.h" | 59 #include "content/common/view_messages.h" |
59 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
60 #include "content/public/browser/content_browser_client.h" | 61 #include "content/public/browser/content_browser_client.h" |
61 #include "content/public/browser/download_manager.h" | 62 #include "content/public/browser/download_manager.h" |
62 #include "content/public/browser/download_url_parameters.h" | 63 #include "content/public/browser/download_url_parameters.h" |
63 #include "content/public/browser/global_request_id.h" | 64 #include "content/public/browser/global_request_id.h" |
64 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 65 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
65 #include "content/public/browser/resource_request_details.h" | 66 #include "content/public/browser/resource_request_details.h" |
66 #include "content/public/browser/resource_throttle.h" | 67 #include "content/public/browser/resource_throttle.h" |
67 #include "content/public/browser/stream_handle.h" | 68 #include "content/public/browser/stream_handle.h" |
69 #include "content/public/browser/stream_info.h" | |
68 #include "content/public/browser/user_metrics.h" | 70 #include "content/public/browser/user_metrics.h" |
69 #include "content/public/common/content_switches.h" | 71 #include "content/public/common/content_switches.h" |
70 #include "content/public/common/process_type.h" | 72 #include "content/public/common/process_type.h" |
71 #include "ipc/ipc_message_macros.h" | 73 #include "ipc/ipc_message_macros.h" |
72 #include "ipc/ipc_message_start.h" | 74 #include "ipc/ipc_message_start.h" |
73 #include "net/base/auth.h" | 75 #include "net/base/auth.h" |
74 #include "net/base/load_flags.h" | 76 #include "net/base/load_flags.h" |
75 #include "net/base/mime_util.h" | 77 #include "net/base/mime_util.h" |
76 #include "net/base/net_errors.h" | 78 #include "net/base/net_errors.h" |
77 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 79 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 return; | 298 return; |
297 web_contents->DidGetResourceResponseStart(*details.get()); | 299 web_contents->DidGetResourceResponseStart(*details.get()); |
298 } | 300 } |
299 | 301 |
300 bool IsValidatedSCT( | 302 bool IsValidatedSCT( |
301 const net::SignedCertificateTimestampAndStatus& sct_status) { | 303 const net::SignedCertificateTimestampAndStatus& sct_status) { |
302 return sct_status.status == net::ct::SCT_STATUS_OK; | 304 return sct_status.status == net::ct::SCT_STATUS_OK; |
303 } | 305 } |
304 | 306 |
305 storage::BlobStorageContext* GetBlobStorageContext( | 307 storage::BlobStorageContext* GetBlobStorageContext( |
306 ResourceMessageFilter* filter) { | 308 ChromeBlobStorageContext* blob_storage_context) { |
307 if (!filter->blob_storage_context()) | 309 if (!blob_storage_context) |
308 return NULL; | 310 return NULL; |
309 return filter->blob_storage_context()->context(); | 311 return blob_storage_context->context(); |
310 } | 312 } |
311 | 313 |
312 void AttachRequestBodyBlobDataHandles( | 314 void AttachRequestBodyBlobDataHandles( |
313 ResourceRequestBody* body, | 315 ResourceRequestBody* body, |
314 storage::BlobStorageContext* blob_context) { | 316 storage::BlobStorageContext* blob_context) { |
315 DCHECK(blob_context); | 317 DCHECK(blob_context); |
316 for (size_t i = 0; i < body->elements()->size(); ++i) { | 318 for (size_t i = 0; i < body->elements()->size(); ++i) { |
317 const ResourceRequestBody::Element& element = (*body->elements())[i]; | 319 const ResourceRequestBody::Element& element = (*body->elements())[i]; |
318 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) | 320 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) |
319 continue; | 321 continue; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 delete loaders; | 462 delete loaders; |
461 } else { | 463 } else { |
462 ++i; | 464 ++i; |
463 } | 465 } |
464 } | 466 } |
465 | 467 |
466 #ifndef NDEBUG | 468 #ifndef NDEBUG |
467 for (LoaderList::iterator i = loaders_to_cancel.begin(); | 469 for (LoaderList::iterator i = loaders_to_cancel.begin(); |
468 i != loaders_to_cancel.end(); ++i) { | 470 i != loaders_to_cancel.end(); ++i) { |
469 // There is no strict requirement that this be the case, but currently | 471 // There is no strict requirement that this be the case, but currently |
470 // downloads, streams, detachable requests, and transferred requests are the | 472 // downloads, streams, detachable requests, transferred requests, and |
471 // only requests that aren't cancelled when the associated processes go | 473 // browser-owned requests are the only requests that aren't cancelled when |
472 // away. It may be OK for this invariant to change in the future, but if | 474 // the associated processes go away. It may be OK for this invariant to |
473 // this assertion fires without the invariant changing, then it's indicative | 475 // change in the future, but if this assertion fires without the invariant |
474 // of a leak. | 476 // changing, then it's indicative of a leak. |
475 DCHECK((*i)->GetRequestInfo()->IsDownload() || | 477 DCHECK((*i)->GetRequestInfo()->IsDownload() || |
476 (*i)->GetRequestInfo()->is_stream() || | 478 (*i)->GetRequestInfo()->is_stream() || |
477 ((*i)->GetRequestInfo()->detachable_handler() && | 479 ((*i)->GetRequestInfo()->detachable_handler() && |
478 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || | 480 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || |
481 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || | |
479 (*i)->is_transferring()); | 482 (*i)->is_transferring()); |
480 } | 483 } |
481 #endif | 484 #endif |
482 | 485 |
483 loaders_to_cancel.clear(); | 486 loaders_to_cancel.clear(); |
484 | 487 |
485 // Validate that no more requests for this context were added. | 488 // Validate that no more requests for this context were added. |
486 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 489 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
487 i != pending_loaders_.end(); ++i) { | 490 i != pending_loaders_.end(); ++i) { |
488 // http://crbug.com/90971 | 491 // http://crbug.com/90971 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 | 659 |
657 StreamContext* stream_context = | 660 StreamContext* stream_context = |
658 GetStreamContextForResourceContext(info->GetContext()); | 661 GetStreamContextForResourceContext(info->GetContext()); |
659 | 662 |
660 scoped_ptr<StreamResourceHandler> handler( | 663 scoped_ptr<StreamResourceHandler> handler( |
661 new StreamResourceHandler(request, | 664 new StreamResourceHandler(request, |
662 stream_context->registry(), | 665 stream_context->registry(), |
663 origin)); | 666 origin)); |
664 | 667 |
665 info->set_is_stream(true); | 668 info->set_is_stream(true); |
666 delegate_->OnStreamCreated( | 669 scoped_ptr<StreamInfo> stream_info(new StreamInfo); |
667 request, | 670 stream_info->handle = handler->stream()->CreateHandle(); |
668 handler->stream()->CreateHandle( | 671 stream_info->original_url = request->url(); |
669 request->url(), | 672 stream_info->response = response; |
670 mime_type, | 673 delegate_->OnStreamCreated(request, stream_info.Pass()); |
671 response->head.headers)); | |
672 return handler.PassAs<ResourceHandler>(); | 674 return handler.PassAs<ResourceHandler>(); |
673 } | 675 } |
674 | 676 |
675 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest( | 677 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest( |
676 net::URLRequest* request) { | 678 net::URLRequest* request) { |
677 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 679 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
678 if (info) { | 680 if (info) { |
679 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); | 681 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); |
680 if (loader) | 682 if (loader) |
681 loader->ClearSSLClientAuthHandler(); | 683 loader->ClearSSLClientAuthHandler(); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1076 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
1075 SetReferrerForRequest(new_request.get(), referrer); | 1077 SetReferrerForRequest(new_request.get(), referrer); |
1076 | 1078 |
1077 net::HttpRequestHeaders headers; | 1079 net::HttpRequestHeaders headers; |
1078 headers.AddHeadersFromString(request_data.headers); | 1080 headers.AddHeadersFromString(request_data.headers); |
1079 new_request->SetExtraRequestHeaders(headers); | 1081 new_request->SetExtraRequestHeaders(headers); |
1080 | 1082 |
1081 new_request->SetLoadFlags(load_flags); | 1083 new_request->SetLoadFlags(load_flags); |
1082 | 1084 |
1083 storage::BlobStorageContext* blob_context = | 1085 storage::BlobStorageContext* blob_context = |
1084 GetBlobStorageContext(filter_); | 1086 GetBlobStorageContext(filter_->blob_storage_context()); |
1085 // Resolve elements from request_body and prepare upload data. | 1087 // Resolve elements from request_body and prepare upload data. |
1086 if (request_data.request_body.get()) { | 1088 if (request_data.request_body.get()) { |
1087 // Attaches the BlobDataHandles to request_body not to free the blobs and | 1089 // Attaches the BlobDataHandles to request_body not to free the blobs and |
1088 // any attached shareable files until upload completion. These data will be | 1090 // any attached shareable files until upload completion. These data will be |
1089 // used in UploadDataStream and ServiceWorkerURLRequestJob. | 1091 // used in UploadDataStream and ServiceWorkerURLRequestJob. |
1090 AttachRequestBodyBlobDataHandles( | 1092 AttachRequestBodyBlobDataHandles( |
1091 request_data.request_body.get(), | 1093 request_data.request_body.get(), |
1092 blob_context); | 1094 blob_context); |
1093 new_request->set_upload(UploadDataStreamBuilder::Build( | 1095 new_request->set_upload(UploadDataStreamBuilder::Build( |
1094 request_data.request_body.get(), | 1096 request_data.request_body.get(), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 } | 1196 } |
1195 | 1197 |
1196 // Prefetches and <a ping> requests outlive their child process. | 1198 // Prefetches and <a ping> requests outlive their child process. |
1197 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { | 1199 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { |
1198 handler.reset(new DetachableResourceHandler( | 1200 handler.reset(new DetachableResourceHandler( |
1199 request, | 1201 request, |
1200 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1202 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
1201 handler.Pass())); | 1203 handler.Pass())); |
1202 } | 1204 } |
1203 | 1205 |
1204 // Install a CrossSiteResourceHandler for all main frame requests. This will | 1206 // If using --enable-browser-side-navigation, the CrossSiteResourceHandler is |
1205 // let us check whether a transfer is required and pause for the unload | 1207 // not needed. |
1206 // handler either if so or if a cross-process navigation is already under way. | 1208 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1207 bool is_swappable_navigation = | 1209 switches::kEnableBrowserSideNavigation)) { |
1208 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | 1210 // Install a CrossSiteResourceHandler for all main frame requests. This |
1209 // If we are using --site-per-process, install it for subframes as well. | 1211 // will let us check whether a transfer is required and pause for the unload |
1210 if (!is_swappable_navigation && | 1212 // handler either if so or if a cross-process navigation is already under |
1211 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1213 // way. |
1212 switches::kSitePerProcess)) { | 1214 bool is_swappable_navigation = |
1213 is_swappable_navigation = | 1215 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; |
1214 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | 1216 // If we are using --site-per-process, install it for subframes as well. |
1217 if (!is_swappable_navigation && | |
1218 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1219 switches::kSitePerProcess)) { | |
1220 is_swappable_navigation = | |
1221 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
1222 } | |
1223 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1224 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request)); | |
1215 } | 1225 } |
1216 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1217 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request)); | |
1218 | 1226 |
1219 // Insert a buffered event handler before the actual one. | 1227 // Insert a buffered event handler before the actual one. |
1220 handler.reset( | 1228 handler.reset( |
1221 new BufferedResourceHandler(handler.Pass(), this, request)); | 1229 new BufferedResourceHandler(handler.Pass(), this, request)); |
1222 | 1230 |
1223 ScopedVector<ResourceThrottle> throttles; | 1231 ScopedVector<ResourceThrottle> throttles; |
1224 if (delegate_) { | 1232 if (delegate_) { |
1225 delegate_->RequestBeginning(request, | 1233 delegate_->RequestBeginning(request, |
1226 resource_context, | 1234 resource_context, |
1227 filter_->appcache_service(), | 1235 filter_->appcache_service(), |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1654 return true; | 1662 return true; |
1655 } | 1663 } |
1656 | 1664 |
1657 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1665 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
1658 const net::URLRequest* request_) { | 1666 const net::URLRequest* request_) { |
1659 const ResourceRequestInfoImpl* info = | 1667 const ResourceRequestInfoImpl* info = |
1660 ResourceRequestInfoImpl::ForRequest(request_); | 1668 ResourceRequestInfoImpl::ForRequest(request_); |
1661 IncrementOutstandingRequestsCount(-1, *info); | 1669 IncrementOutstandingRequestsCount(-1, *info); |
1662 } | 1670 } |
1663 | 1671 |
1664 void ResourceDispatcherHostImpl::StartNavigationRequest( | 1672 bool ResourceDispatcherHostImpl::BeginNavigationRequest( |
1673 ResourceContext* resource_context, | |
1674 int64 frame_tree_node_id, | |
1665 const NavigationRequestInfo& info, | 1675 const NavigationRequestInfo& info, |
1666 scoped_refptr<ResourceRequestBody> request_body, | 1676 scoped_refptr<ResourceRequestBody> request_body, |
1667 int64 navigation_request_id, | 1677 NavigationURLLoaderCore* loader) { |
clamy
2014/09/12 20:51:25
I would add a CHECK that browser side navigation i
davidben
2014/09/19 18:30:50
Good point. Done.
| |
1668 int64 frame_node_id) { | 1678 ResourceType resource_type = info.is_main_frame ? |
1669 NOTIMPLEMENTED(); | 1679 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
1670 } | |
1671 | 1680 |
1672 void ResourceDispatcherHostImpl::CancelNavigationRequest( | 1681 if (is_shutdown_ || |
1673 int64 navigation_request_id, | 1682 // TODO(davidben): Check ShouldServiceRequest here. This is important; it |
1674 int64 frame_node_id) { | 1683 // needs to be checked relative to the child that /requested/ the |
1675 NOTIMPLEMENTED(); | 1684 // navigation. It's where file upload checks, etc., come in. |
1685 (delegate_ && !delegate_->ShouldBeginRequest( | |
1686 info.navigation_params.method, | |
1687 info.navigation_params.url, | |
1688 resource_type, | |
1689 resource_context))) { | |
1690 return false; | |
1691 } | |
1692 | |
1693 // http://crbug.com/90971 | |
1694 char url_buf[128]; | |
1695 base::strlcpy( | |
1696 url_buf, info.navigation_params.url.spec().c_str(), arraysize(url_buf)); | |
1697 base::debug::Alias(url_buf); | |
1698 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | |
1699 | |
1700 const net::URLRequestContext* request_context = | |
1701 resource_context->GetRequestContext(); | |
1702 | |
1703 int load_flags = info.navigation_params.load_flags; | |
1704 load_flags |= net::LOAD_VERIFY_EV_CERT; | |
1705 if (info.is_main_frame) { | |
1706 load_flags |= net::LOAD_MAIN_FRAME; | |
1707 } else { | |
1708 load_flags |= net::LOAD_SUB_FRAME; | |
1709 } | |
1710 // Add a flag to selectively bypass the data reduction proxy if the resource | |
1711 // type is not an image. | |
1712 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | |
1713 | |
1714 // TODO(davidben): BuildLoadFlagsForRequest includes logic for | |
1715 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? | |
1716 | |
1717 // Sync loads should have maximum priority and should be the only | |
1718 // requests that have the ignore limits flag set. | |
1719 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); | |
1720 | |
1721 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for | |
1722 // prerender. There isn't a renderer process yet, so we need to use the | |
1723 // ResourceContext or something. | |
1724 scoped_ptr<net::URLRequest> new_request; | |
1725 new_request = request_context->CreateRequest( | |
1726 info.navigation_params.url, net::HIGHEST, NULL, NULL); | |
1727 | |
1728 new_request->set_method(info.navigation_params.method); | |
1729 new_request->set_first_party_for_cookies( | |
1730 info.first_party_for_cookies); | |
1731 if (info.is_main_frame) { | |
1732 new_request->set_first_party_url_policy( | |
1733 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
1734 } | |
1735 | |
1736 SetReferrerForRequest(new_request.get(), info.navigation_params.referrer); | |
1737 | |
1738 net::HttpRequestHeaders headers; | |
1739 headers.AddHeadersFromString(info.navigation_params.headers); | |
1740 new_request->SetExtraRequestHeaders(headers); | |
1741 | |
1742 new_request->SetLoadFlags(load_flags); | |
1743 | |
1744 // Resolve elements from request_body and prepare upload data. | |
1745 if (info.navigation_params.request_body.get()) { | |
1746 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
1747 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
1748 AttachRequestBodyBlobDataHandles( | |
1749 info.navigation_params.request_body.get(), | |
1750 blob_context); | |
1751 // TODO(davidben): The FileSystemContext is NULL here. In the case where | |
1752 // another renderer requested this navigation, this should be the same | |
1753 // FileSystemContext passed into ShouldServiceRequest. | |
1754 new_request->set_upload(UploadDataStreamBuilder::Build( | |
1755 info.navigation_params.request_body.get(), | |
1756 blob_context, | |
1757 NULL, // file_system_context | |
1758 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | |
1759 .get())); | |
1760 } | |
1761 | |
1762 request_id_--; | |
1763 | |
1764 // Make extra info and read footer (contains request ID). | |
1765 // | |
1766 // TODO(davidben): Associate the request with the FrameTreeNode or tab so that | |
1767 // IO thread -> UI thread hops will work. | |
1768 ResourceRequestInfoImpl* extra_info = | |
1769 new ResourceRequestInfoImpl( | |
1770 PROCESS_TYPE_BROWSER, | |
1771 -1, // child_id | |
1772 -1, // route_id | |
1773 -1, // request_data.origin_pid, | |
1774 request_id_, | |
1775 -1, // request_data.render_frame_id, | |
1776 info.is_main_frame, | |
1777 info.parent_is_main_frame, | |
1778 -1, // request_data.parent_render_frame_id, | |
1779 resource_type, | |
1780 info.navigation_params.transition_type, | |
1781 info.navigation_params.should_replace_current_entry, | |
1782 false, // is download | |
1783 false, // is stream | |
1784 info.navigation_params.allow_download, | |
1785 info.navigation_params.has_user_gesture, | |
1786 true, | |
1787 info.navigation_params.referrer.policy, | |
1788 // TODO(davidben): This is only used for prerenders. Replace | |
1789 // is_showing with something for that. Or maybe it just comes from the | |
1790 // same mechanism as the cookie one. | |
1791 blink::WebPageVisibilityStateVisible, | |
1792 resource_context, | |
1793 base::WeakPtr<ResourceMessageFilter>(), // filter | |
1794 true); | |
1795 // Request takes ownership. | |
1796 extra_info->AssociateWithRequest(new_request.get()); | |
1797 | |
1798 if (new_request->url().SchemeIs(url::kBlobScheme)) { | |
1799 // Hang on to a reference to ensure the blob is not released prior | |
1800 // to the job being started. | |
1801 ChromeBlobStorageContext* blob_context = | |
1802 GetChromeBlobStorageContextForResourceContext(resource_context); | |
1803 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | |
1804 new_request.get(), | |
1805 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | |
1806 } | |
1807 | |
1808 // TODO(davidben): Attach ServiceWorkerRequestHandler. | |
1809 | |
1810 // TODO(davidben): Attach AppCacheInterceptor. | |
1811 | |
1812 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | |
1813 new_request.get(), loader)); | |
1814 | |
1815 // Insert a buffered event handler before the actual one. | |
1816 handler.reset( | |
1817 new BufferedResourceHandler(handler.Pass(), this, new_request.get())); | |
1818 | |
1819 ScopedVector<ResourceThrottle> throttles; | |
1820 if (delegate_) { | |
1821 // TODO(davidben): appcache_service is currently NULL. | |
1822 delegate_->RequestBeginning(new_request.get(), | |
1823 resource_context, | |
1824 NULL, | |
1825 resource_type, | |
1826 &throttles); | |
1827 } | |
1828 | |
1829 if (new_request->has_upload()) { | |
1830 // Block power save while uploading data. | |
1831 throttles.push_back(new PowerSaveBlockResourceThrottle()); | |
1832 } | |
1833 | |
1834 // TODO(davidben): Attach ResourceScheduler's throttle. | |
1835 | |
1836 handler.reset(new ThrottlingResourceHandler( | |
1837 handler.Pass(), new_request.get(), throttles.Pass())); | |
1838 | |
1839 if (handler) | |
1840 BeginRequestInternal(new_request.Pass(), handler.Pass()); | |
1841 return true; | |
1676 } | 1842 } |
1677 | 1843 |
1678 // static | 1844 // static |
1679 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( | 1845 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( |
1680 net::URLRequest* request) { | 1846 net::URLRequest* request) { |
1681 // The following fields should be a minor size contribution (experimentally | 1847 // The following fields should be a minor size contribution (experimentally |
1682 // on the order of 100). However since they are variable length, it could | 1848 // on the order of 100). However since they are variable length, it could |
1683 // in theory be a sizeable contribution. | 1849 // in theory be a sizeable contribution. |
1684 int strings_cost = request->extra_request_headers().ToString().size() + | 1850 int strings_cost = request->extra_request_headers().ToString().size() + |
1685 request->original_url().spec().size() + | 1851 request->original_url().spec().size() + |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2049 | 2215 |
2050 // Add a flag to selectively bypass the data reduction proxy if the resource | 2216 // Add a flag to selectively bypass the data reduction proxy if the resource |
2051 // type is not an image. | 2217 // type is not an image. |
2052 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2218 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2053 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2219 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2054 | 2220 |
2055 return load_flags; | 2221 return load_flags; |
2056 } | 2222 } |
2057 | 2223 |
2058 } // namespace content | 2224 } // namespace content |
OLD | NEW |