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 19 matching lines...) Expand all Loading... | |
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/frame_host/navigator.h" | 35 #include "content/browser/frame_host/navigator.h" |
36 #include "content/browser/loader/async_resource_handler.h" | 36 #include "content/browser/loader/async_resource_handler.h" |
37 #include "content/browser/loader/buffered_resource_handler.h" | 37 #include "content/browser/loader/buffered_resource_handler.h" |
38 #include "content/browser/loader/cross_site_resource_handler.h" | 38 #include "content/browser/loader/cross_site_resource_handler.h" |
39 #include "content/browser/loader/detachable_resource_handler.h" | 39 #include "content/browser/loader/detachable_resource_handler.h" |
40 #include "content/browser/loader/navigation_resource_handler.h" | |
41 #include "content/browser/loader/navigation_url_loader_core.h" | |
40 #include "content/browser/loader/power_save_block_resource_throttle.h" | 42 #include "content/browser/loader/power_save_block_resource_throttle.h" |
41 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 43 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
42 #include "content/browser/loader/resource_message_filter.h" | 44 #include "content/browser/loader/resource_message_filter.h" |
43 #include "content/browser/loader/resource_request_info_impl.h" | 45 #include "content/browser/loader/resource_request_info_impl.h" |
44 #include "content/browser/loader/stream_resource_handler.h" | 46 #include "content/browser/loader/stream_resource_handler.h" |
45 #include "content/browser/loader/sync_resource_handler.h" | 47 #include "content/browser/loader/sync_resource_handler.h" |
46 #include "content/browser/loader/throttling_resource_handler.h" | 48 #include "content/browser/loader/throttling_resource_handler.h" |
47 #include "content/browser/loader/upload_data_stream_builder.h" | 49 #include "content/browser/loader/upload_data_stream_builder.h" |
48 #include "content/browser/renderer_host/render_view_host_delegate.h" | 50 #include "content/browser/renderer_host/render_view_host_delegate.h" |
49 #include "content/browser/renderer_host/render_view_host_impl.h" | 51 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 return; | 355 return; |
354 web_contents->DidGetResourceResponseStart(*details.get()); | 356 web_contents->DidGetResourceResponseStart(*details.get()); |
355 } | 357 } |
356 | 358 |
357 bool IsValidatedSCT( | 359 bool IsValidatedSCT( |
358 const net::SignedCertificateTimestampAndStatus& sct_status) { | 360 const net::SignedCertificateTimestampAndStatus& sct_status) { |
359 return sct_status.status == net::ct::SCT_STATUS_OK; | 361 return sct_status.status == net::ct::SCT_STATUS_OK; |
360 } | 362 } |
361 | 363 |
362 storage::BlobStorageContext* GetBlobStorageContext( | 364 storage::BlobStorageContext* GetBlobStorageContext( |
363 ResourceMessageFilter* filter) { | 365 ChromeBlobStorageContext* blob_storage_context) { |
364 if (!filter->blob_storage_context()) | 366 if (!blob_storage_context) |
365 return NULL; | 367 return NULL; |
366 return filter->blob_storage_context()->context(); | 368 return blob_storage_context->context(); |
367 } | 369 } |
368 | 370 |
369 void AttachRequestBodyBlobDataHandles( | 371 void AttachRequestBodyBlobDataHandles( |
370 ResourceRequestBody* body, | 372 ResourceRequestBody* body, |
371 storage::BlobStorageContext* blob_context) { | 373 storage::BlobStorageContext* blob_context) { |
372 DCHECK(blob_context); | 374 DCHECK(blob_context); |
373 for (size_t i = 0; i < body->elements()->size(); ++i) { | 375 for (size_t i = 0; i < body->elements()->size(); ++i) { |
374 const ResourceRequestBody::Element& element = (*body->elements())[i]; | 376 const ResourceRequestBody::Element& element = (*body->elements())[i]; |
375 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) | 377 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) |
376 continue; | 378 continue; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 delete loaders; | 537 delete loaders; |
536 } else { | 538 } else { |
537 ++i; | 539 ++i; |
538 } | 540 } |
539 } | 541 } |
540 | 542 |
541 #ifndef NDEBUG | 543 #ifndef NDEBUG |
542 for (LoaderList::iterator i = loaders_to_cancel.begin(); | 544 for (LoaderList::iterator i = loaders_to_cancel.begin(); |
543 i != loaders_to_cancel.end(); ++i) { | 545 i != loaders_to_cancel.end(); ++i) { |
544 // There is no strict requirement that this be the case, but currently | 546 // There is no strict requirement that this be the case, but currently |
545 // downloads, streams, detachable requests, and transferred requests are the | 547 // downloads, streams, detachable requests, transferred requests, and |
546 // only requests that aren't cancelled when the associated processes go | 548 // browser-owned requests are the only requests that aren't cancelled when |
547 // away. It may be OK for this invariant to change in the future, but if | 549 // the associated processes go away. It may be OK for this invariant to |
548 // this assertion fires without the invariant changing, then it's indicative | 550 // change in the future, but if this assertion fires without the invariant |
549 // of a leak. | 551 // changing, then it's indicative of a leak. |
550 DCHECK((*i)->GetRequestInfo()->IsDownload() || | 552 DCHECK((*i)->GetRequestInfo()->IsDownload() || |
551 (*i)->GetRequestInfo()->is_stream() || | 553 (*i)->GetRequestInfo()->is_stream() || |
552 ((*i)->GetRequestInfo()->detachable_handler() && | 554 ((*i)->GetRequestInfo()->detachable_handler() && |
553 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || | 555 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || |
556 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || | |
554 (*i)->is_transferring()); | 557 (*i)->is_transferring()); |
555 } | 558 } |
556 #endif | 559 #endif |
557 | 560 |
558 loaders_to_cancel.clear(); | 561 loaders_to_cancel.clear(); |
559 | 562 |
560 // Validate that no more requests for this context were added. | 563 // Validate that no more requests for this context were added. |
561 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 564 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
562 i != pending_loaders_.end(); ++i) { | 565 i != pending_loaders_.end(); ++i) { |
563 // http://crbug.com/90971 | 566 // http://crbug.com/90971 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1161 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1164 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
1162 SetReferrerForRequest(new_request.get(), referrer); | 1165 SetReferrerForRequest(new_request.get(), referrer); |
1163 | 1166 |
1164 net::HttpRequestHeaders headers; | 1167 net::HttpRequestHeaders headers; |
1165 headers.AddHeadersFromString(request_data.headers); | 1168 headers.AddHeadersFromString(request_data.headers); |
1166 new_request->SetExtraRequestHeaders(headers); | 1169 new_request->SetExtraRequestHeaders(headers); |
1167 | 1170 |
1168 new_request->SetLoadFlags(load_flags); | 1171 new_request->SetLoadFlags(load_flags); |
1169 | 1172 |
1170 storage::BlobStorageContext* blob_context = | 1173 storage::BlobStorageContext* blob_context = |
1171 GetBlobStorageContext(filter_); | 1174 GetBlobStorageContext(filter_->blob_storage_context()); |
1172 // Resolve elements from request_body and prepare upload data. | 1175 // Resolve elements from request_body and prepare upload data. |
1173 if (request_data.request_body.get()) { | 1176 if (request_data.request_body.get()) { |
1174 // |blob_context| could be null when the request is from the plugins because | 1177 // |blob_context| could be null when the request is from the plugins because |
1175 // ResourceMessageFilters created in PluginProcessHost don't have the blob | 1178 // ResourceMessageFilters created in PluginProcessHost don't have the blob |
1176 // context. | 1179 // context. |
1177 if (blob_context) { | 1180 if (blob_context) { |
1178 // Attaches the BlobDataHandles to request_body not to free the blobs and | 1181 // Attaches the BlobDataHandles to request_body not to free the blobs and |
1179 // any attached shareable files until upload completion. These data will | 1182 // any attached shareable files until upload completion. These data will |
1180 // be used in UploadDataStream and ServiceWorkerURLRequestJob. | 1183 // be used in UploadDataStream and ServiceWorkerURLRequestJob. |
1181 AttachRequestBodyBlobDataHandles( | 1184 AttachRequestBodyBlobDataHandles( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1293 } | 1296 } |
1294 | 1297 |
1295 // Prefetches and <a ping> requests outlive their child process. | 1298 // Prefetches and <a ping> requests outlive their child process. |
1296 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { | 1299 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { |
1297 handler.reset(new DetachableResourceHandler( | 1300 handler.reset(new DetachableResourceHandler( |
1298 request, | 1301 request, |
1299 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1302 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
1300 handler.Pass())); | 1303 handler.Pass())); |
1301 } | 1304 } |
1302 | 1305 |
1303 // Install a CrossSiteResourceHandler for all main frame requests. This will | 1306 // PlzNavigate: If using --enable-browser-side-navigation, the |
1304 // let us check whether a transfer is required and pause for the unload | 1307 // CrossSiteResourceHandler is not needed. This codepath is not used for the |
1305 // handler either if so or if a cross-process navigation is already under way. | 1308 // actual navigation request, but only the subsequent blob URL load. This does |
1306 bool is_swappable_navigation = | 1309 // not require request transfers. |
1307 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | 1310 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1308 // If we are using --site-per-process, install it for subframes as well. | 1311 switches::kEnableBrowserSideNavigation)) { |
1309 if (!is_swappable_navigation && | 1312 // Install a CrossSiteResourceHandler for all main frame requests. This will |
1310 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1313 // check whether a transfer is required and, if so, pause for the UI thread |
1311 switches::kSitePerProcess)) { | 1314 // to drive the transfer. |
1312 is_swappable_navigation = | 1315 bool is_swappable_navigation = |
1313 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | 1316 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; |
1317 // If we are using --site-per-process, install it for subframes as well. | |
1318 if (!is_swappable_navigation && | |
1319 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1320 switches::kSitePerProcess)) { | |
1321 is_swappable_navigation = | |
1322 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
1323 } | |
1324 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1325 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request)); | |
1314 } | 1326 } |
1315 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1316 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request)); | |
1317 | 1327 |
1328 return AddStandardHandlers(request, request_data.resource_type, | |
1329 resource_context, filter_->appcache_service(), | |
1330 child_id, route_id, handler.Pass()); | |
1331 } | |
1332 | |
1333 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers( | |
1334 net::URLRequest* request, | |
1335 ResourceType resource_type, | |
1336 ResourceContext* resource_context, | |
1337 AppCacheService* appcache_service, | |
1338 int child_id, | |
1339 int route_id, | |
1340 scoped_ptr<ResourceHandler> handler) { | |
1318 // Insert a buffered event handler before the actual one. | 1341 // Insert a buffered event handler before the actual one. |
1319 handler.reset( | 1342 handler.reset( |
1320 new BufferedResourceHandler(handler.Pass(), this, request)); | 1343 new BufferedResourceHandler(handler.Pass(), this, request)); |
1321 | 1344 |
1322 ScopedVector<ResourceThrottle> throttles; | 1345 ScopedVector<ResourceThrottle> throttles; |
1323 if (delegate_) { | 1346 if (delegate_) { |
1324 delegate_->RequestBeginning(request, | 1347 delegate_->RequestBeginning(request, |
1325 resource_context, | 1348 resource_context, |
1326 filter_->appcache_service(), | 1349 appcache_service, |
1327 request_data.resource_type, | 1350 resource_type, |
1328 &throttles); | 1351 &throttles); |
1329 } | 1352 } |
1330 | 1353 |
1331 if (request->has_upload()) { | 1354 if (request->has_upload()) { |
1332 // Block power save while uploading data. | 1355 // Block power save while uploading data. |
1333 throttles.push_back(new PowerSaveBlockResourceThrottle()); | 1356 throttles.push_back(new PowerSaveBlockResourceThrottle()); |
1334 } | 1357 } |
1335 | 1358 |
1336 throttles.push_back( | 1359 throttles.push_back( |
1337 scheduler_->ScheduleRequest(child_id, route_id, request).release()); | 1360 scheduler_->ScheduleRequest(child_id, route_id, request).release()); |
1338 | 1361 |
1339 handler.reset( | 1362 handler.reset( |
1340 new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); | 1363 new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); |
1341 | 1364 |
1365 | |
nasko
2014/10/20 13:52:18
nit: no need for an extra new line.
davidben
2014/10/22 01:32:37
Done.
| |
1342 return handler.Pass(); | 1366 return handler.Pass(); |
1343 } | 1367 } |
1344 | 1368 |
1345 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1369 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
1346 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1370 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
1347 } | 1371 } |
1348 | 1372 |
1349 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { | 1373 void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { |
1350 // TODO(michaeln): maybe throttle DataDownloaded messages | 1374 // TODO(michaeln): maybe throttle DataDownloaded messages |
1351 } | 1375 } |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 return true; | 1784 return true; |
1761 } | 1785 } |
1762 | 1786 |
1763 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1787 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
1764 const net::URLRequest* request_) { | 1788 const net::URLRequest* request_) { |
1765 const ResourceRequestInfoImpl* info = | 1789 const ResourceRequestInfoImpl* info = |
1766 ResourceRequestInfoImpl::ForRequest(request_); | 1790 ResourceRequestInfoImpl::ForRequest(request_); |
1767 IncrementOutstandingRequestsCount(-1, *info); | 1791 IncrementOutstandingRequestsCount(-1, *info); |
1768 } | 1792 } |
1769 | 1793 |
1770 void ResourceDispatcherHostImpl::StartNavigationRequest( | 1794 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
1795 ResourceContext* resource_context, | |
1796 int64 frame_tree_node_id, | |
1771 const CommonNavigationParams& params, | 1797 const CommonNavigationParams& params, |
1772 const NavigationRequestInfo& info, | 1798 const NavigationRequestInfo& info, |
1773 scoped_refptr<ResourceRequestBody> request_body, | 1799 scoped_refptr<ResourceRequestBody> request_body, |
1774 int64 navigation_request_id, | 1800 NavigationURLLoaderCore* loader) { |
1775 int64 frame_node_id) { | 1801 // BeginNavigationRequest currently should only be used for the browser-side |
nasko
2014/10/20 13:52:18
nit: prefix the comment with PlzNavigate
davidben
2014/10/22 01:32:37
Done.
| |
1776 NOTIMPLEMENTED(); | 1802 // navigations project. |
1777 } | 1803 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
1804 switches::kEnableBrowserSideNavigation)); | |
1778 | 1805 |
1779 void ResourceDispatcherHostImpl::CancelNavigationRequest( | 1806 ResourceType resource_type = info.is_main_frame ? |
1780 int64 navigation_request_id, | 1807 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
1781 int64 frame_node_id) { | 1808 |
1782 NOTIMPLEMENTED(); | 1809 if (is_shutdown_ || |
1810 // TODO(davidben): Check ShouldServiceRequest here. This is important; it | |
1811 // needs to be checked relative to the child that /requested/ the | |
1812 // navigation. It's where file upload checks, etc., come in. | |
1813 (delegate_ && !delegate_->ShouldBeginRequest( | |
1814 info.navigation_params.method, | |
1815 params.url, | |
1816 resource_type, | |
1817 resource_context))) { | |
1818 loader->RequestFailedOnIOThread(net::ERR_ABORTED); | |
1819 return; | |
1820 } | |
1821 | |
1822 // http://crbug.com/90971 | |
nasko
2014/10/20 13:52:18
nit: the comment should say a bit more than the bu
davidben
2014/10/22 01:32:37
Done. (Just copied that from elsewhere.)
| |
1823 char url_buf[128]; | |
1824 base::strlcpy(url_buf, params.url.spec().c_str(), arraysize(url_buf)); | |
1825 base::debug::Alias(url_buf); | |
1826 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | |
1827 | |
1828 const net::URLRequestContext* request_context = | |
1829 resource_context->GetRequestContext(); | |
1830 | |
1831 int load_flags = info.navigation_params.load_flags; | |
1832 load_flags |= net::LOAD_VERIFY_EV_CERT; | |
1833 if (info.is_main_frame) { | |
1834 load_flags |= net::LOAD_MAIN_FRAME; | |
1835 } else { | |
1836 load_flags |= net::LOAD_SUB_FRAME; | |
1837 } | |
1838 // Add a flag to selectively bypass the data reduction proxy if the resource | |
1839 // type is not an image. | |
1840 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | |
1841 | |
1842 // TODO(davidben): BuildLoadFlagsForRequest includes logic for | |
1843 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here? | |
1844 | |
1845 // Sync loads should have maximum priority and should be the only | |
1846 // requests that have the ignore limits flag set. | |
1847 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); | |
1848 | |
1849 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for | |
1850 // prerender. There isn't a renderer process yet, so we need to use the | |
nasko
2014/10/20 13:52:18
nit: There actually might be a process, right? We
davidben
2014/10/22 01:32:37
Done.
| |
1851 // ResourceContext or something. | |
1852 scoped_ptr<net::URLRequest> new_request; | |
1853 new_request = request_context->CreateRequest(params.url, net::HIGHEST, | |
1854 nullptr, nullptr); | |
1855 | |
1856 new_request->set_method(info.navigation_params.method); | |
1857 new_request->set_first_party_for_cookies( | |
1858 info.first_party_for_cookies); | |
1859 if (info.is_main_frame) { | |
1860 new_request->set_first_party_url_policy( | |
1861 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
1862 } | |
1863 | |
1864 SetReferrerForRequest(new_request.get(), params.referrer); | |
1865 | |
1866 net::HttpRequestHeaders headers; | |
1867 headers.AddHeadersFromString(info.navigation_params.headers); | |
1868 new_request->SetExtraRequestHeaders(headers); | |
1869 | |
1870 new_request->SetLoadFlags(load_flags); | |
1871 | |
1872 // Resolve elements from request_body and prepare upload data. | |
1873 if (info.navigation_params.request_body.get()) { | |
1874 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
1875 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
1876 AttachRequestBodyBlobDataHandles( | |
1877 info.navigation_params.request_body.get(), | |
1878 blob_context); | |
1879 // TODO(davidben): The FileSystemContext is null here. In the case where | |
1880 // another renderer requested this navigation, this should be the same | |
1881 // FileSystemContext passed into ShouldServiceRequest. | |
1882 new_request->set_upload(UploadDataStreamBuilder::Build( | |
1883 info.navigation_params.request_body.get(), | |
1884 blob_context, | |
1885 nullptr, // file_system_context | |
1886 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | |
1887 .get())); | |
1888 } | |
1889 | |
1890 request_id_--; | |
1891 | |
1892 // Make extra info and read footer (contains request ID). | |
1893 // | |
1894 // TODO(davidben): Associate the request with the FrameTreeNode or tab so that | |
nasko
2014/10/20 13:52:18
Should be FrameTreeNode, not tab, right? If we ass
davidben
2014/10/22 01:32:37
Well, I'm actually not sure if we have anything th
| |
1895 // IO thread -> UI thread hops will work. | |
1896 ResourceRequestInfoImpl* extra_info = | |
1897 new ResourceRequestInfoImpl( | |
1898 PROCESS_TYPE_BROWSER, | |
1899 -1, // child_id | |
1900 -1, // route_id | |
1901 -1, // request_data.origin_pid, | |
1902 request_id_, | |
1903 -1, // request_data.render_frame_id, | |
1904 info.is_main_frame, | |
1905 info.parent_is_main_frame, | |
1906 -1, // request_data.parent_render_frame_id, | |
1907 resource_type, | |
1908 params.transition, | |
1909 // should_replace_current_entry. This was only maintained at layer for | |
1910 // request transfers and isn't needed for browser-side navigations. | |
1911 false, | |
1912 false, // is download | |
1913 false, // is stream | |
1914 params.allow_download, | |
1915 info.navigation_params.has_user_gesture, | |
1916 true, | |
1917 params.referrer.policy, | |
1918 // TODO(davidben): This is only used for prerenders. Replace | |
1919 // is_showing with something for that. Or maybe it just comes from the | |
1920 // same mechanism as the cookie one. | |
1921 blink::WebPageVisibilityStateVisible, | |
1922 resource_context, | |
1923 base::WeakPtr<ResourceMessageFilter>(), // filter | |
1924 true); | |
1925 // Request takes ownership. | |
1926 extra_info->AssociateWithRequest(new_request.get()); | |
1927 | |
1928 if (new_request->url().SchemeIs(url::kBlobScheme)) { | |
1929 // Hang on to a reference to ensure the blob is not released prior | |
1930 // to the job being started. | |
1931 ChromeBlobStorageContext* blob_context = | |
1932 GetChromeBlobStorageContextForResourceContext(resource_context); | |
1933 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | |
1934 new_request.get(), | |
1935 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | |
1936 } | |
1937 | |
1938 // TODO(davidben): Attach ServiceWorkerRequestHandler. | |
1939 | |
1940 // TODO(davidben): Attach AppCacheInterceptor. | |
1941 | |
1942 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | |
1943 new_request.get(), loader)); | |
1944 | |
1945 handler = AddStandardHandlers(new_request.get(), resource_type, | |
1946 resource_context, | |
1947 nullptr, // TODO(davidben): appcache_service | |
1948 -1, // TODO(davidben): child_id | |
1949 -1, // TODO(davidben): route_id | |
1950 handler.Pass()); | |
1951 | |
1952 BeginRequestInternal(new_request.Pass(), handler.Pass()); | |
1783 } | 1953 } |
1784 | 1954 |
1785 // static | 1955 // static |
1786 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( | 1956 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( |
1787 net::URLRequest* request) { | 1957 net::URLRequest* request) { |
1788 // The following fields should be a minor size contribution (experimentally | 1958 // The following fields should be a minor size contribution (experimentally |
1789 // on the order of 100). However since they are variable length, it could | 1959 // on the order of 100). However since they are variable length, it could |
1790 // in theory be a sizeable contribution. | 1960 // in theory be a sizeable contribution. |
1791 int strings_cost = request->extra_request_headers().ToString().size() + | 1961 int strings_cost = request->extra_request_headers().ToString().size() + |
1792 request->original_url().spec().size() + | 1962 request->original_url().spec().size() + |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2156 | 2326 |
2157 // Add a flag to selectively bypass the data reduction proxy if the resource | 2327 // Add a flag to selectively bypass the data reduction proxy if the resource |
2158 // type is not an image. | 2328 // type is not an image. |
2159 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2329 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2160 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2330 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2161 | 2331 |
2162 return load_flags; | 2332 return load_flags; |
2163 } | 2333 } |
2164 | 2334 |
2165 } // namespace content | 2335 } // namespace content |
OLD | NEW |