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 21 matching lines...) Expand all Loading... | |
32 #include "base/stl_util.h" | 32 #include "base/stl_util.h" |
33 #include "base/strings/string_util.h" | 33 #include "base/strings/string_util.h" |
34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
35 #include "base/time/time.h" | 35 #include "base/time/time.h" |
36 #include "content/browser/appcache/appcache_interceptor.h" | 36 #include "content/browser/appcache/appcache_interceptor.h" |
37 #include "content/browser/appcache/chrome_appcache_service.h" | 37 #include "content/browser/appcache/chrome_appcache_service.h" |
38 #include "content/browser/bad_message.h" | 38 #include "content/browser/bad_message.h" |
39 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 39 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
40 #include "content/browser/cert_store_impl.h" | 40 #include "content/browser/cert_store_impl.h" |
41 #include "content/browser/child_process_security_policy_impl.h" | 41 #include "content/browser/child_process_security_policy_impl.h" |
42 #include "content/browser/download/download_resource_handler.h" | |
43 #include "content/browser/download/save_file_resource_handler.h" | |
scottmg
2016/08/18 17:38:08
And this one.
ananta
2016/08/18 22:27:09
Done.
| |
44 #include "content/browser/frame_host/frame_tree.h" | 42 #include "content/browser/frame_host/frame_tree.h" |
45 #include "content/browser/frame_host/navigation_request_info.h" | 43 #include "content/browser/frame_host/navigation_request_info.h" |
46 #include "content/browser/frame_host/navigator.h" | 44 #include "content/browser/frame_host/navigator.h" |
47 #include "content/browser/loader/async_resource_handler.h" | 45 #include "content/browser/loader/async_resource_handler.h" |
48 #include "content/browser/loader/async_revalidation_manager.h" | 46 #include "content/browser/loader/async_revalidation_manager.h" |
49 #include "content/browser/loader/cross_site_resource_handler.h" | 47 #include "content/browser/loader/cross_site_resource_handler.h" |
50 #include "content/browser/loader/detachable_resource_handler.h" | 48 #include "content/browser/loader/detachable_resource_handler.h" |
51 #include "content/browser/loader/loader_delegate.h" | 49 #include "content/browser/loader/loader_delegate.h" |
52 #include "content/browser/loader/mime_type_resource_handler.h" | 50 #include "content/browser/loader/mime_type_resource_handler.h" |
53 #include "content/browser/loader/mojo_async_resource_handler.h" | 51 #include "content/browser/loader/mojo_async_resource_handler.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 loaders_to_cancel.clear(); | 601 loaders_to_cancel.clear(); |
604 | 602 |
605 if (async_revalidation_manager_) { | 603 if (async_revalidation_manager_) { |
606 // Cancelling async revalidations should not result in the creation of new | 604 // Cancelling async revalidations should not result in the creation of new |
607 // requests. Do it before the CHECKs to ensure this does not happen. | 605 // requests. Do it before the CHECKs to ensure this does not happen. |
608 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext( | 606 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext( |
609 context); | 607 context); |
610 } | 608 } |
611 } | 609 } |
612 | 610 |
613 DownloadInterruptReason ResourceDispatcherHostImpl::BeginDownload( | |
614 std::unique_ptr<net::URLRequest> request, | |
615 const Referrer& referrer, | |
616 bool is_content_initiated, | |
617 ResourceContext* context, | |
618 int render_process_id, | |
619 int render_view_route_id, | |
620 int render_frame_route_id, | |
621 bool do_not_prompt_for_login) { | |
622 if (is_shutdown_) | |
623 return DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; | |
624 | |
625 const GURL& url = request->original_url(); | |
626 SetReferrerForRequest(request.get(), referrer); | |
627 | |
628 // We treat a download as a main frame load, and thus update the policy URL on | |
629 // redirects. | |
630 // | |
631 // TODO(davidben): Is this correct? If this came from a | |
632 // ViewHostMsg_DownloadUrl in a frame, should it have first-party URL set | |
633 // appropriately? | |
634 request->set_first_party_url_policy( | |
635 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
636 | |
637 // Check if the renderer is permitted to request the requested URL. | |
638 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> | |
639 CanRequestURL(render_process_id, url)) { | |
640 DVLOG(1) << "Denied unauthorized download request for " | |
641 << url.possibly_invalid_spec(); | |
642 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; | |
643 } | |
644 | |
645 request_id_--; | |
646 | |
647 const net::URLRequestContext* request_context = request->context(); | |
648 if (!request_context->job_factory()->IsHandledURL(url)) { | |
649 DVLOG(1) << "Download request for unsupported protocol: " | |
650 << url.possibly_invalid_spec(); | |
651 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; | |
Randy Smith (Not in Mondays)
2016/08/18 17:38:58
This check seems to have been removed in the refac
ananta
2016/08/18 22:27:09
Thanks for catching this. Fixed
| |
652 } | |
653 | |
654 ResourceRequestInfoImpl* extra_info = | |
655 CreateRequestInfo(render_process_id, render_view_route_id, | |
656 render_frame_route_id, true, context); | |
657 extra_info->set_do_not_prompt_for_login(do_not_prompt_for_login); | |
658 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | |
659 | |
660 if (request->url().SchemeIs(url::kBlobScheme) && | |
661 !storage::BlobProtocolHandler::GetRequestBlobDataHandle(request.get())) { | |
662 ChromeBlobStorageContext* blob_context = | |
663 GetChromeBlobStorageContextForResourceContext(context); | |
664 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | |
665 request.get(), | |
666 blob_context->context()->GetBlobDataFromPublicURL(request->url())); | |
667 } | |
668 | |
669 // From this point forward, the |DownloadResourceHandler| is responsible for | |
670 // |started_callback|. | |
671 std::unique_ptr<ResourceHandler> handler(CreateResourceHandlerForDownload( | |
672 request.get(), is_content_initiated, true)); | |
673 | |
674 BeginRequestInternal(std::move(request), std::move(handler)); | |
675 | |
676 return DOWNLOAD_INTERRUPT_REASON_NONE; | |
677 } | |
678 | |
679 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( | 611 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( |
680 net::URLRequest* request) { | 612 net::URLRequest* request) { |
681 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 613 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
682 if (info) { | 614 if (info) { |
683 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); | 615 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); |
684 if (loader) | 616 if (loader) |
685 loader->ClearLoginDelegate(); | 617 loader->ClearLoginDelegate(); |
686 } | 618 } |
687 } | 619 } |
688 | 620 |
(...skipping 20 matching lines...) Expand all Loading... | |
709 FROM_HERE, | 641 FROM_HERE, |
710 base::Bind(&ResourceDispatcherHostImpl::OnShutdown, | 642 base::Bind(&ResourceDispatcherHostImpl::OnShutdown, |
711 base::Unretained(this))); | 643 base::Unretained(this))); |
712 } | 644 } |
713 | 645 |
714 std::unique_ptr<ResourceHandler> | 646 std::unique_ptr<ResourceHandler> |
715 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( | 647 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( |
716 net::URLRequest* request, | 648 net::URLRequest* request, |
717 bool is_content_initiated, | 649 bool is_content_initiated, |
718 bool must_download) { | 650 bool must_download) { |
719 std::unique_ptr<ResourceHandler> handler( | 651 if (!create_download_handler_intercept_.is_null()) { |
720 new DownloadResourceHandler(request)); | 652 return create_download_handler_intercept_.Run(request, is_content_initiated, |
721 if (delegate_) { | 653 must_download); |
722 const ResourceRequestInfoImpl* request_info( | |
723 ResourceRequestInfoImpl::ForRequest(request)); | |
724 | |
725 ScopedVector<ResourceThrottle> throttles; | |
726 delegate_->DownloadStarting( | |
727 request, request_info->GetContext(), request_info->GetChildID(), | |
728 request_info->GetRouteID(), is_content_initiated, must_download, | |
729 &throttles); | |
730 if (!throttles.empty()) { | |
731 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | |
732 std::move(throttles))); | |
733 } | |
734 } | 654 } |
735 return handler; | 655 return std::unique_ptr<ResourceHandler>(); |
mmenke
2016/08/18 17:35:43
Returning a nullptr looks like it will result in a
Randy Smith (Not in Mondays)
2016/08/18 17:38:57
I'm uncomfortable with this change. Either we're
ananta
2016/08/18 22:27:09
Sure thing. Added a DCHECK here
ananta
2016/08/18 22:27:09
Added a DCHECK here
| |
736 } | 656 } |
737 | 657 |
738 std::unique_ptr<ResourceHandler> | 658 std::unique_ptr<ResourceHandler> |
739 ResourceDispatcherHostImpl::MaybeInterceptAsStream( | 659 ResourceDispatcherHostImpl::MaybeInterceptAsStream( |
740 const base::FilePath& plugin_path, | 660 const base::FilePath& plugin_path, |
741 net::URLRequest* request, | 661 net::URLRequest* request, |
742 ResourceResponse* response, | 662 ResourceResponse* response, |
743 std::string* payload) { | 663 std::string* payload) { |
744 payload->clear(); | 664 payload->clear(); |
745 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 665 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1439 new URLRequestServiceWorkerData()); | 1359 new URLRequestServiceWorkerData()); |
1440 } | 1360 } |
1441 | 1361 |
1442 // If the request is a MAIN_FRAME request, the first-party URL gets updated on | 1362 // If the request is a MAIN_FRAME request, the first-party URL gets updated on |
1443 // redirects. | 1363 // redirects. |
1444 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { | 1364 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
1445 new_request->set_first_party_url_policy( | 1365 new_request->set_first_party_url_policy( |
1446 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 1366 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
1447 } | 1367 } |
1448 | 1368 |
1449 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | |
1450 SetReferrerForRequest(new_request.get(), referrer); | |
1451 | |
1452 new_request->SetExtraRequestHeaders(headers); | 1369 new_request->SetExtraRequestHeaders(headers); |
1453 | 1370 |
1454 storage::BlobStorageContext* blob_context = | 1371 storage::BlobStorageContext* blob_context = |
1455 GetBlobStorageContext(filter_->blob_storage_context()); | 1372 GetBlobStorageContext(filter_->blob_storage_context()); |
1456 // Resolve elements from request_body and prepare upload data. | 1373 // Resolve elements from request_body and prepare upload data. |
1457 if (request_data.request_body.get()) { | 1374 if (request_data.request_body.get()) { |
1458 // |blob_context| could be null when the request is from the plugins because | 1375 // |blob_context| could be null when the request is from the plugins because |
1459 // ResourceMessageFilters created in PluginProcessHost don't have the blob | 1376 // ResourceMessageFilters created in PluginProcessHost don't have the blob |
1460 // context. | 1377 // context. |
1461 if (blob_context) { | 1378 if (blob_context) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1584 AppCacheInterceptor::SetExtraRequestInfo( | 1501 AppCacheInterceptor::SetExtraRequestInfo( |
1585 new_request.get(), filter_->appcache_service(), child_id, | 1502 new_request.get(), filter_->appcache_service(), child_id, |
1586 request_data.appcache_host_id, request_data.resource_type, | 1503 request_data.appcache_host_id, request_data.resource_type, |
1587 request_data.should_reset_appcache); | 1504 request_data.should_reset_appcache); |
1588 | 1505 |
1589 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( | 1506 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( |
1590 new_request.get(), request_data, sync_result, route_id, process_type, | 1507 new_request.get(), request_data, sync_result, route_id, process_type, |
1591 child_id, resource_context, std::move(mojo_request), | 1508 child_id, resource_context, std::move(mojo_request), |
1592 std::move(url_loader_client))); | 1509 std::move(url_loader_client))); |
1593 | 1510 |
1594 if (handler) | 1511 if (handler) { |
1595 BeginRequestInternal(std::move(new_request), std::move(handler)); | 1512 BeginURLRequest(std::move(new_request), |
1513 Referrer(request_data.referrer, | |
1514 request_data.referrer_policy), | |
mmenke
2016/08/18 17:35:43
Moving where we set the referrer seems concerning
ananta
2016/08/18 22:27:09
Thanks. Fixed this by bringing back the old BeginR
Randy Smith (Not in Mondays)
2016/08/21 23:32:57
This looks to me to still have been changed on the
ananta
2016/08/22 19:14:57
Yes this has changed. The current code for contex
Randy Smith (Not in Mondays)
2016/08/23 19:54:45
The issn't isn't about whether the code is current
| |
1515 std::move(handler)); | |
1516 } | |
1596 } | 1517 } |
1597 | 1518 |
1598 std::unique_ptr<ResourceHandler> | 1519 std::unique_ptr<ResourceHandler> |
1599 ResourceDispatcherHostImpl::CreateResourceHandler( | 1520 ResourceDispatcherHostImpl::CreateResourceHandler( |
1600 net::URLRequest* request, | 1521 net::URLRequest* request, |
1601 const ResourceRequest& request_data, | 1522 const ResourceRequest& request_data, |
1602 IPC::Message* sync_result, | 1523 IPC::Message* sync_result, |
1603 int route_id, | 1524 int route_id, |
1604 int process_type, | 1525 int process_type, |
1605 int child_id, | 1526 int child_id, |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1822 | 1743 |
1823 loader->CancelRequest(true); | 1744 loader->CancelRequest(true); |
1824 } | 1745 } |
1825 | 1746 |
1826 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( | 1747 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( |
1827 int child_id, | 1748 int child_id, |
1828 int render_view_route_id, | 1749 int render_view_route_id, |
1829 int render_frame_route_id, | 1750 int render_frame_route_id, |
1830 bool download, | 1751 bool download, |
1831 ResourceContext* context) { | 1752 ResourceContext* context) { |
1753 request_id_--; | |
1832 return new ResourceRequestInfoImpl( | 1754 return new ResourceRequestInfoImpl( |
1833 PROCESS_TYPE_RENDERER, | 1755 PROCESS_TYPE_RENDERER, |
1834 child_id, | 1756 child_id, |
1835 render_view_route_id, | 1757 render_view_route_id, |
1836 -1, // frame_tree_node_id | 1758 -1, // frame_tree_node_id |
1837 0, | 1759 0, |
1838 request_id_, | 1760 request_id_, |
1839 render_frame_route_id, | 1761 render_frame_route_id, |
1840 false, // is_main_frame | 1762 false, // is_main_frame |
1841 false, // parent_is_main_frame | 1763 false, // parent_is_main_frame |
(...skipping 12 matching lines...) Expand all Loading... | |
1854 context, | 1776 context, |
1855 base::WeakPtr<ResourceMessageFilter>(), // filter | 1777 base::WeakPtr<ResourceMessageFilter>(), // filter |
1856 false, // report_raw_headers | 1778 false, // report_raw_headers |
1857 true, // is_async | 1779 true, // is_async |
1858 false, // is_using_lofi | 1780 false, // is_using_lofi |
1859 std::string(), // original_headers | 1781 std::string(), // original_headers |
1860 nullptr, // body | 1782 nullptr, // body |
1861 false); // initiated_in_secure_context | 1783 false); // initiated_in_secure_context |
1862 } | 1784 } |
1863 | 1785 |
1786 void ResourceDispatcherHostImpl::RegisterCreateDownloadHandlerInterceptor( | |
1787 CreateDownloadHandlerIntercept intercept) { | |
1788 create_download_handler_intercept_ = intercept; | |
1789 } | |
1790 | |
1864 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, | 1791 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, |
1865 int route_id) { | 1792 int route_id) { |
1866 scheduler_->OnClientCreated(child_id, route_id); | 1793 scheduler_->OnClientCreated(child_id, route_id); |
1867 } | 1794 } |
1868 | 1795 |
1869 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, | 1796 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, |
1870 int route_id) { | 1797 int route_id) { |
1871 scheduler_->OnClientDeleted(child_id, route_id); | 1798 scheduler_->OnClientDeleted(child_id, route_id); |
1872 } | 1799 } |
1873 | 1800 |
1874 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, | 1801 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, |
1875 int route_id, | 1802 int route_id, |
1876 bool is_loading) { | 1803 bool is_loading) { |
1877 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); | 1804 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); |
1878 } | 1805 } |
1879 | 1806 |
1880 // This function is only used for saving feature. | |
1881 void ResourceDispatcherHostImpl::BeginSaveFile(const GURL& url, | |
1882 const Referrer& referrer, | |
1883 SaveItemId save_item_id, | |
1884 SavePackageId save_package_id, | |
1885 int child_id, | |
1886 int render_view_route_id, | |
1887 int render_frame_route_id, | |
1888 ResourceContext* context) { | |
1889 if (is_shutdown_) | |
1890 return; | |
1891 | |
1892 request_id_--; | |
1893 | |
1894 const net::URLRequestContext* request_context = context->GetRequestContext(); | |
1895 bool known_proto = | |
1896 request_context->job_factory()->IsHandledURL(url); | |
1897 if (!known_proto) { | |
1898 // Since any URLs which have non-standard scheme have been filtered | |
1899 // by save manager(see GURL::SchemeIsStandard). This situation | |
1900 // should not happen. | |
1901 NOTREACHED(); | |
1902 return; | |
1903 } | |
1904 | |
1905 std::unique_ptr<net::URLRequest> request( | |
1906 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | |
1907 request->set_method("GET"); | |
1908 SetReferrerForRequest(request.get(), referrer); | |
1909 | |
1910 // So far, for saving page, we need fetch content from cache, in the | |
1911 // future, maybe we can use a configuration to configure this behavior. | |
1912 request->SetLoadFlags(net::LOAD_PREFERRING_CACHE); | |
1913 | |
1914 // Since we're just saving some resources we need, disallow downloading. | |
1915 ResourceRequestInfoImpl* extra_info = | |
1916 CreateRequestInfo(child_id, render_view_route_id, | |
1917 render_frame_route_id, false, context); | |
1918 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | |
1919 | |
1920 // Check if the renderer is permitted to request the requested URL. | |
1921 using AuthorizationState = SaveFileResourceHandler::AuthorizationState; | |
1922 AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; | |
1923 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(child_id, | |
1924 url)) { | |
1925 DVLOG(1) << "Denying unauthorized save of " << url.possibly_invalid_spec(); | |
1926 authorization_state = AuthorizationState::NOT_AUTHORIZED; | |
1927 // No need to return here (i.e. okay to begin processing the request below), | |
1928 // because NOT_AUTHORIZED will cause the request to be cancelled. See also | |
1929 // doc comments for AuthorizationState enum. | |
1930 } | |
1931 | |
1932 std::unique_ptr<SaveFileResourceHandler> handler(new SaveFileResourceHandler( | |
1933 request.get(), save_item_id, save_package_id, child_id, | |
1934 render_frame_route_id, url, authorization_state)); | |
1935 | |
1936 BeginRequestInternal(std::move(request), std::move(handler)); | |
1937 } | |
1938 | |
1939 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( | 1807 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( |
1940 const GlobalRequestID& id, | 1808 const GlobalRequestID& id, |
1941 const scoped_refptr<ResourceResponse>& response) { | 1809 const scoped_refptr<ResourceResponse>& response) { |
1942 GetLoader(id)->MarkAsTransferring(response); | 1810 GetLoader(id)->MarkAsTransferring(response); |
1943 } | 1811 } |
1944 | 1812 |
1945 void ResourceDispatcherHostImpl::CancelTransferringNavigation( | 1813 void ResourceDispatcherHostImpl::CancelTransferringNavigation( |
1946 const GlobalRequestID& id) { | 1814 const GlobalRequestID& id) { |
1947 // Request should still exist and be in the middle of a transfer. | 1815 // Request should still exist and be in the middle of a transfer. |
1948 DCHECK(IsTransferredNavigation(id)); | 1816 DCHECK(IsTransferredNavigation(id)); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2205 | 2073 |
2206 new_request->set_method(info.common_params.method); | 2074 new_request->set_method(info.common_params.method); |
2207 new_request->set_first_party_for_cookies( | 2075 new_request->set_first_party_for_cookies( |
2208 info.first_party_for_cookies); | 2076 info.first_party_for_cookies); |
2209 new_request->set_initiator(info.request_initiator); | 2077 new_request->set_initiator(info.request_initiator); |
2210 if (info.is_main_frame) { | 2078 if (info.is_main_frame) { |
2211 new_request->set_first_party_url_policy( | 2079 new_request->set_first_party_url_policy( |
2212 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 2080 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
2213 } | 2081 } |
2214 | 2082 |
2215 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | |
2216 | |
2217 net::HttpRequestHeaders headers; | 2083 net::HttpRequestHeaders headers; |
2218 headers.AddHeadersFromString(info.begin_params.headers); | 2084 headers.AddHeadersFromString(info.begin_params.headers); |
2219 new_request->SetExtraRequestHeaders(headers); | 2085 new_request->SetExtraRequestHeaders(headers); |
2220 | 2086 |
2221 new_request->SetLoadFlags(load_flags); | 2087 new_request->SetLoadFlags(load_flags); |
2222 | 2088 |
2223 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | 2089 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
2224 GetChromeBlobStorageContextForResourceContext(resource_context)); | 2090 GetChromeBlobStorageContextForResourceContext(resource_context)); |
2225 | 2091 |
2226 // Resolve elements from request_body and prepare upload data. | 2092 // Resolve elements from request_body and prepare upload data. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2303 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2169 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2304 // currently it's a no-op. | 2170 // currently it's a no-op. |
2305 handler = | 2171 handler = |
2306 AddStandardHandlers(new_request.get(), resource_type, resource_context, | 2172 AddStandardHandlers(new_request.get(), resource_type, resource_context, |
2307 info.begin_params.request_context_type, | 2173 info.begin_params.request_context_type, |
2308 nullptr, // appcache_service | 2174 nullptr, // appcache_service |
2309 -1, // child_id | 2175 -1, // child_id |
2310 -1, // route_id | 2176 -1, // route_id |
2311 std::move(handler)); | 2177 std::move(handler)); |
2312 | 2178 |
2313 BeginRequestInternal(std::move(new_request), std::move(handler)); | 2179 BeginURLRequest(std::move(new_request), |
2180 info.common_params.referrer, | |
2181 std::move(handler)); | |
2314 } | 2182 } |
2315 | 2183 |
2316 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { | 2184 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { |
2317 if (!async_revalidation_manager_) | 2185 if (!async_revalidation_manager_) |
2318 async_revalidation_manager_.reset(new AsyncRevalidationManager); | 2186 async_revalidation_manager_.reset(new AsyncRevalidationManager); |
2319 } | 2187 } |
2320 | 2188 |
2321 void ResourceDispatcherHostImpl::SetLoaderDelegate( | 2189 void ResourceDispatcherHostImpl::SetLoaderDelegate( |
2322 LoaderDelegate* loader_delegate) { | 2190 LoaderDelegate* loader_delegate) { |
2323 loader_delegate_ = loader_delegate; | 2191 loader_delegate_ = loader_delegate; |
(...skipping 27 matching lines...) Expand all Loading... | |
2351 int strings_cost = request->extra_request_headers().ToString().size() + | 2219 int strings_cost = request->extra_request_headers().ToString().size() + |
2352 request->original_url().spec().size() + | 2220 request->original_url().spec().size() + |
2353 request->referrer().size() + | 2221 request->referrer().size() + |
2354 request->method().size(); | 2222 request->method().size(); |
2355 | 2223 |
2356 // Note that this expression will typically be dominated by: | 2224 // Note that this expression will typically be dominated by: |
2357 // |kAvgBytesPerOutstandingRequest|. | 2225 // |kAvgBytesPerOutstandingRequest|. |
2358 return kAvgBytesPerOutstandingRequest + strings_cost; | 2226 return kAvgBytesPerOutstandingRequest + strings_cost; |
2359 } | 2227 } |
2360 | 2228 |
2361 void ResourceDispatcherHostImpl::BeginRequestInternal( | 2229 void ResourceDispatcherHostImpl::BeginURLRequest( |
2362 std::unique_ptr<net::URLRequest> request, | 2230 std::unique_ptr<net::URLRequest> request, |
2231 const Referrer& referrer, | |
2363 std::unique_ptr<ResourceHandler> handler) { | 2232 std::unique_ptr<ResourceHandler> handler) { |
2233 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
2364 DCHECK(!request->is_pending()); | 2234 DCHECK(!request->is_pending()); |
2365 ResourceRequestInfoImpl* info = | 2235 ResourceRequestInfoImpl* info = |
2366 ResourceRequestInfoImpl::ForRequest(request.get()); | 2236 ResourceRequestInfoImpl::ForRequest(request.get()); |
2367 | 2237 |
2238 SetReferrerForRequest(request.get(), referrer); | |
2239 | |
2368 if ((TimeTicks::Now() - last_user_gesture_time_) < | 2240 if ((TimeTicks::Now() - last_user_gesture_time_) < |
2369 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { | 2241 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { |
2370 request->SetLoadFlags( | 2242 request->SetLoadFlags( |
2371 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); | 2243 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); |
2372 } | 2244 } |
2373 | 2245 |
2374 // Add the memory estimate that starting this request will consume. | 2246 // Add the memory estimate that starting this request will consume. |
2375 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); | 2247 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); |
2376 | 2248 |
2377 // If enqueing/starting this request will exceed our per-process memory | 2249 // If enqueing/starting this request will exceed our per-process memory |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2719 << iter->filesystem_url().spec(); | 2591 << iter->filesystem_url().spec(); |
2720 return false; | 2592 return false; |
2721 } | 2593 } |
2722 } | 2594 } |
2723 } | 2595 } |
2724 } | 2596 } |
2725 return true; | 2597 return true; |
2726 } | 2598 } |
2727 | 2599 |
2728 } // namespace content | 2600 } // namespace content |
OLD | NEW |