Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 519533002: Initial PlzNavigate RDH-side logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 10 matching lines...) Expand all
60 #include "content/common/view_messages.h" 62 #include "content/common/view_messages.h"
61 #include "content/public/browser/browser_thread.h" 63 #include "content/public/browser/browser_thread.h"
62 #include "content/public/browser/content_browser_client.h" 64 #include "content/public/browser/content_browser_client.h"
63 #include "content/public/browser/download_manager.h" 65 #include "content/public/browser/download_manager.h"
64 #include "content/public/browser/download_url_parameters.h" 66 #include "content/public/browser/download_url_parameters.h"
65 #include "content/public/browser/global_request_id.h" 67 #include "content/public/browser/global_request_id.h"
66 #include "content/public/browser/resource_dispatcher_host_delegate.h" 68 #include "content/public/browser/resource_dispatcher_host_delegate.h"
67 #include "content/public/browser/resource_request_details.h" 69 #include "content/public/browser/resource_request_details.h"
68 #include "content/public/browser/resource_throttle.h" 70 #include "content/public/browser/resource_throttle.h"
69 #include "content/public/browser/stream_handle.h" 71 #include "content/public/browser/stream_handle.h"
72 #include "content/public/browser/stream_info.h"
70 #include "content/public/browser/user_metrics.h" 73 #include "content/public/browser/user_metrics.h"
71 #include "content/public/common/content_switches.h" 74 #include "content/public/common/content_switches.h"
72 #include "content/public/common/process_type.h" 75 #include "content/public/common/process_type.h"
73 #include "ipc/ipc_message_macros.h" 76 #include "ipc/ipc_message_macros.h"
74 #include "ipc/ipc_message_start.h" 77 #include "ipc/ipc_message_start.h"
75 #include "net/base/auth.h" 78 #include "net/base/auth.h"
76 #include "net/base/load_flags.h" 79 #include "net/base/load_flags.h"
77 #include "net/base/mime_util.h" 80 #include "net/base/mime_util.h"
78 #include "net/base/net_errors.h" 81 #include "net/base/net_errors.h"
79 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 82 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return; 355 return;
353 web_contents->DidGetResourceResponseStart(*details.get()); 356 web_contents->DidGetResourceResponseStart(*details.get());
354 } 357 }
355 358
356 bool IsValidatedSCT( 359 bool IsValidatedSCT(
357 const net::SignedCertificateTimestampAndStatus& sct_status) { 360 const net::SignedCertificateTimestampAndStatus& sct_status) {
358 return sct_status.status == net::ct::SCT_STATUS_OK; 361 return sct_status.status == net::ct::SCT_STATUS_OK;
359 } 362 }
360 363
361 storage::BlobStorageContext* GetBlobStorageContext( 364 storage::BlobStorageContext* GetBlobStorageContext(
362 ResourceMessageFilter* filter) { 365 ChromeBlobStorageContext* blob_storage_context) {
363 if (!filter->blob_storage_context()) 366 if (!blob_storage_context)
364 return NULL; 367 return NULL;
365 return filter->blob_storage_context()->context(); 368 return blob_storage_context->context();
366 } 369 }
367 370
368 void AttachRequestBodyBlobDataHandles( 371 void AttachRequestBodyBlobDataHandles(
369 ResourceRequestBody* body, 372 ResourceRequestBody* body,
370 storage::BlobStorageContext* blob_context) { 373 storage::BlobStorageContext* blob_context) {
371 DCHECK(blob_context); 374 DCHECK(blob_context);
372 for (size_t i = 0; i < body->elements()->size(); ++i) { 375 for (size_t i = 0; i < body->elements()->size(); ++i) {
373 const ResourceRequestBody::Element& element = (*body->elements())[i]; 376 const ResourceRequestBody::Element& element = (*body->elements())[i];
374 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) 377 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB)
375 continue; 378 continue;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 delete loaders; 537 delete loaders;
535 } else { 538 } else {
536 ++i; 539 ++i;
537 } 540 }
538 } 541 }
539 542
540 #ifndef NDEBUG 543 #ifndef NDEBUG
541 for (LoaderList::iterator i = loaders_to_cancel.begin(); 544 for (LoaderList::iterator i = loaders_to_cancel.begin();
542 i != loaders_to_cancel.end(); ++i) { 545 i != loaders_to_cancel.end(); ++i) {
543 // 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
544 // downloads, streams, detachable requests, and transferred requests are the 547 // downloads, streams, detachable requests, transferred requests, and
545 // only requests that aren't cancelled when the associated processes go 548 // browser-owned requests are the only requests that aren't cancelled when
546 // 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
547 // this assertion fires without the invariant changing, then it's indicative 550 // change in the future, but if this assertion fires without the invariant
548 // of a leak. 551 // changing, then it's indicative of a leak.
549 DCHECK((*i)->GetRequestInfo()->IsDownload() || 552 DCHECK((*i)->GetRequestInfo()->IsDownload() ||
550 (*i)->GetRequestInfo()->is_stream() || 553 (*i)->GetRequestInfo()->is_stream() ||
551 ((*i)->GetRequestInfo()->detachable_handler() && 554 ((*i)->GetRequestInfo()->detachable_handler() &&
552 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || 555 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) ||
556 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER ||
553 (*i)->is_transferring()); 557 (*i)->is_transferring());
554 } 558 }
555 #endif 559 #endif
556 560
557 loaders_to_cancel.clear(); 561 loaders_to_cancel.clear();
558 562
559 // Validate that no more requests for this context were added. 563 // Validate that no more requests for this context were added.
560 for (LoaderMap::const_iterator i = pending_loaders_.begin(); 564 for (LoaderMap::const_iterator i = pending_loaders_.begin();
561 i != pending_loaders_.end(); ++i) { 565 i != pending_loaders_.end(); ++i) {
562 // http://crbug.com/90971 566 // http://crbug.com/90971
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 734
731 StreamContext* stream_context = 735 StreamContext* stream_context =
732 GetStreamContextForResourceContext(info->GetContext()); 736 GetStreamContextForResourceContext(info->GetContext());
733 737
734 scoped_ptr<StreamResourceHandler> handler( 738 scoped_ptr<StreamResourceHandler> handler(
735 new StreamResourceHandler(request, 739 new StreamResourceHandler(request,
736 stream_context->registry(), 740 stream_context->registry(),
737 origin)); 741 origin));
738 742
739 info->set_is_stream(true); 743 info->set_is_stream(true);
740 delegate_->OnStreamCreated( 744 scoped_ptr<StreamInfo> stream_info(new StreamInfo);
741 request, 745 stream_info->handle = handler->stream()->CreateHandle();
742 handler->stream()->CreateHandle( 746 stream_info->original_url = request->url();
743 request->url(), 747 stream_info->mime_type = mime_type;
744 mime_type, 748 // Make a copy of the response headers so it is safe to pass across threads;
745 response->head.headers)); 749 // the old handler (AsyncResourceHandler) may modify it in parallel via the
750 // ResourceDispatcherHostDelegate.
751 stream_info->response_headers =
752 new net::HttpResponseHeaders(response->head.headers->raw_headers());
753 delegate_->OnStreamCreated(request, stream_info.Pass());
746 return handler.PassAs<ResourceHandler>(); 754 return handler.PassAs<ResourceHandler>();
747 } 755 }
748 756
749 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest( 757 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest(
750 net::URLRequest* request) { 758 net::URLRequest* request) {
751 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 759 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
752 if (info) { 760 if (info) {
753 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); 761 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
754 if (loader) 762 if (loader)
755 loader->ClearSSLClientAuthHandler(); 763 loader->ClearSSLClientAuthHandler();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 const Referrer referrer(request_data.referrer, request_data.referrer_policy); 1174 const Referrer referrer(request_data.referrer, request_data.referrer_policy);
1167 SetReferrerForRequest(new_request.get(), referrer); 1175 SetReferrerForRequest(new_request.get(), referrer);
1168 1176
1169 net::HttpRequestHeaders headers; 1177 net::HttpRequestHeaders headers;
1170 headers.AddHeadersFromString(request_data.headers); 1178 headers.AddHeadersFromString(request_data.headers);
1171 new_request->SetExtraRequestHeaders(headers); 1179 new_request->SetExtraRequestHeaders(headers);
1172 1180
1173 new_request->SetLoadFlags(load_flags); 1181 new_request->SetLoadFlags(load_flags);
1174 1182
1175 storage::BlobStorageContext* blob_context = 1183 storage::BlobStorageContext* blob_context =
1176 GetBlobStorageContext(filter_); 1184 GetBlobStorageContext(filter_->blob_storage_context());
1177 // Resolve elements from request_body and prepare upload data. 1185 // Resolve elements from request_body and prepare upload data.
1178 if (request_data.request_body.get()) { 1186 if (request_data.request_body.get()) {
1179 // Attaches the BlobDataHandles to request_body not to free the blobs and 1187 // Attaches the BlobDataHandles to request_body not to free the blobs and
1180 // any attached shareable files until upload completion. These data will be 1188 // any attached shareable files until upload completion. These data will be
1181 // used in UploadDataStream and ServiceWorkerURLRequestJob. 1189 // used in UploadDataStream and ServiceWorkerURLRequestJob.
1182 AttachRequestBodyBlobDataHandles( 1190 AttachRequestBodyBlobDataHandles(
1183 request_data.request_body.get(), 1191 request_data.request_body.get(),
1184 blob_context); 1192 blob_context);
1185 new_request->set_upload(UploadDataStreamBuilder::Build( 1193 new_request->set_upload(UploadDataStreamBuilder::Build(
1186 request_data.request_body.get(), 1194 request_data.request_body.get(),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 } 1297 }
1290 1298
1291 // Prefetches and <a ping> requests outlive their child process. 1299 // Prefetches and <a ping> requests outlive their child process.
1292 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { 1300 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) {
1293 handler.reset(new DetachableResourceHandler( 1301 handler.reset(new DetachableResourceHandler(
1294 request, 1302 request,
1295 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), 1303 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1296 handler.Pass())); 1304 handler.Pass()));
1297 } 1305 }
1298 1306
1299 // Install a CrossSiteResourceHandler for all main frame requests. This will 1307 // If using --enable-browser-side-navigation, the CrossSiteResourceHandler is
1300 // let us check whether a transfer is required and pause for the unload 1308 // not needed.
1301 // handler either if so or if a cross-process navigation is already under way. 1309 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1302 bool is_swappable_navigation = 1310 switches::kEnableBrowserSideNavigation)) {
1303 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; 1311 // Install a CrossSiteResourceHandler for all main frame requests. This
1304 // If we are using --site-per-process, install it for subframes as well. 1312 // will let us check whether a transfer is required and pause for the unload
1305 if (!is_swappable_navigation && 1313 // handler either if so or if a cross-process navigation is already under
1306 base::CommandLine::ForCurrentProcess()->HasSwitch( 1314 // way.
1307 switches::kSitePerProcess)) { 1315 bool is_swappable_navigation =
1308 is_swappable_navigation = 1316 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME;
1309 request_data.resource_type == RESOURCE_TYPE_SUB_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));
1310 } 1326 }
1311 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER)
1312 handler.reset(new CrossSiteResourceHandler(handler.Pass(), request));
1313 1327
1314 // Insert a buffered event handler before the actual one. 1328 // Insert a buffered event handler before the actual one.
1315 handler.reset( 1329 handler.reset(
1316 new BufferedResourceHandler(handler.Pass(), this, request)); 1330 new BufferedResourceHandler(handler.Pass(), this, request));
1317 1331
1318 ScopedVector<ResourceThrottle> throttles; 1332 ScopedVector<ResourceThrottle> throttles;
1319 if (delegate_) { 1333 if (delegate_) {
1320 delegate_->RequestBeginning(request, 1334 delegate_->RequestBeginning(request,
1321 resource_context, 1335 resource_context,
1322 filter_->appcache_service(), 1336 filter_->appcache_service(),
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 return true; 1763 return true;
1750 } 1764 }
1751 1765
1752 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1766 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1753 const net::URLRequest* request_) { 1767 const net::URLRequest* request_) {
1754 const ResourceRequestInfoImpl* info = 1768 const ResourceRequestInfoImpl* info =
1755 ResourceRequestInfoImpl::ForRequest(request_); 1769 ResourceRequestInfoImpl::ForRequest(request_);
1756 IncrementOutstandingRequestsCount(-1, *info); 1770 IncrementOutstandingRequestsCount(-1, *info);
1757 } 1771 }
1758 1772
1759 void ResourceDispatcherHostImpl::StartNavigationRequest( 1773 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1774 ResourceContext* resource_context,
1775 int64 frame_tree_node_id,
1760 const CommonNavigationParams& params, 1776 const CommonNavigationParams& params,
1761 const NavigationRequestInfo& info, 1777 const NavigationRequestInfo& info,
1762 scoped_refptr<ResourceRequestBody> request_body, 1778 scoped_refptr<ResourceRequestBody> request_body,
1763 int64 navigation_request_id, 1779 NavigationURLLoaderCore* loader) {
1764 int64 frame_node_id) { 1780 // BeginNavigationRequest currently should only be used for the browser-side
1765 NOTIMPLEMENTED(); 1781 // navigations project.
1766 } 1782 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1783 switches::kEnableBrowserSideNavigation));
1767 1784
1768 void ResourceDispatcherHostImpl::CancelNavigationRequest( 1785 ResourceType resource_type = info.is_main_frame ?
1769 int64 navigation_request_id, 1786 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1770 int64 frame_node_id) { 1787
1771 NOTIMPLEMENTED(); 1788 if (is_shutdown_ ||
1789 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
1790 // needs to be checked relative to the child that /requested/ the
1791 // navigation. It's where file upload checks, etc., come in.
1792 (delegate_ && !delegate_->ShouldBeginRequest(
1793 info.navigation_params.method,
1794 params.url,
1795 resource_type,
1796 resource_context))) {
1797 loader->RequestFailedOnIOThread(net::ERR_ABORTED);
1798 return;
1799 }
1800
1801 // http://crbug.com/90971
1802 char url_buf[128];
1803 base::strlcpy(url_buf, params.url.spec().c_str(), arraysize(url_buf));
1804 base::debug::Alias(url_buf);
1805 CHECK(ContainsKey(active_resource_contexts_, resource_context));
1806
1807 const net::URLRequestContext* request_context =
1808 resource_context->GetRequestContext();
1809
1810 int load_flags = info.navigation_params.load_flags;
1811 load_flags |= net::LOAD_VERIFY_EV_CERT;
1812 if (info.is_main_frame) {
1813 load_flags |= net::LOAD_MAIN_FRAME;
1814 } else {
1815 load_flags |= net::LOAD_SUB_FRAME;
1816 }
1817 // Add a flag to selectively bypass the data reduction proxy if the resource
1818 // type is not an image.
1819 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
1820
1821 // TODO(davidben): BuildLoadFlagsForRequest includes logic for
1822 // CanSendCookiesForOrigin and CanReadRawCookies. Is this needed here?
1823
1824 // Sync loads should have maximum priority and should be the only
1825 // requests that have the ignore limits flag set.
1826 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1827
1828 // TODO(davidben): OverrideCookieStoreForRenderProcess handling for
1829 // prerender. There isn't a renderer process yet, so we need to use the
1830 // ResourceContext or something.
1831 scoped_ptr<net::URLRequest> new_request;
1832 new_request =
1833 request_context->CreateRequest(params.url, net::HIGHEST, NULL, NULL);
1834
1835 new_request->set_method(info.navigation_params.method);
1836 new_request->set_first_party_for_cookies(
1837 info.first_party_for_cookies);
1838 if (info.is_main_frame) {
1839 new_request->set_first_party_url_policy(
1840 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1841 }
1842
1843 SetReferrerForRequest(new_request.get(), params.referrer);
1844
1845 net::HttpRequestHeaders headers;
1846 headers.AddHeadersFromString(info.navigation_params.headers);
1847 new_request->SetExtraRequestHeaders(headers);
1848
1849 new_request->SetLoadFlags(load_flags);
1850
1851 // Resolve elements from request_body and prepare upload data.
1852 if (info.navigation_params.request_body.get()) {
1853 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1854 GetChromeBlobStorageContextForResourceContext(resource_context));
1855 AttachRequestBodyBlobDataHandles(
1856 info.navigation_params.request_body.get(),
1857 blob_context);
1858 // TODO(davidben): The FileSystemContext is NULL here. In the case where
1859 // another renderer requested this navigation, this should be the same
1860 // FileSystemContext passed into ShouldServiceRequest.
1861 new_request->set_upload(UploadDataStreamBuilder::Build(
1862 info.navigation_params.request_body.get(),
1863 blob_context,
1864 NULL, // file_system_context
1865 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1866 .get()));
1867 }
1868
1869 request_id_--;
1870
1871 // Make extra info and read footer (contains request ID).
1872 //
1873 // TODO(davidben): Associate the request with the FrameTreeNode or tab so that
1874 // IO thread -> UI thread hops will work.
1875 ResourceRequestInfoImpl* extra_info =
1876 new ResourceRequestInfoImpl(
1877 PROCESS_TYPE_BROWSER,
1878 -1, // child_id
1879 -1, // route_id
1880 -1, // request_data.origin_pid,
1881 request_id_,
1882 -1, // request_data.render_frame_id,
1883 info.is_main_frame,
1884 info.parent_is_main_frame,
1885 -1, // request_data.parent_render_frame_id,
1886 resource_type,
1887 params.transition,
1888 // should_replace_current_entry. This was only maintained at layer for
1889 // request transfers and isn't needed for browser-side navigations.
1890 false,
1891 false, // is download
1892 false, // is stream
1893 params.allow_download,
1894 info.navigation_params.has_user_gesture,
1895 true,
1896 params.referrer.policy,
1897 // TODO(davidben): This is only used for prerenders. Replace
1898 // is_showing with something for that. Or maybe it just comes from the
1899 // same mechanism as the cookie one.
1900 blink::WebPageVisibilityStateVisible,
1901 resource_context,
1902 base::WeakPtr<ResourceMessageFilter>(), // filter
1903 true);
1904 // Request takes ownership.
1905 extra_info->AssociateWithRequest(new_request.get());
1906
1907 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1908 // Hang on to a reference to ensure the blob is not released prior
1909 // to the job being started.
1910 ChromeBlobStorageContext* blob_context =
1911 GetChromeBlobStorageContextForResourceContext(resource_context);
1912 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1913 new_request.get(),
1914 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
1915 }
1916
1917 // TODO(davidben): Attach ServiceWorkerRequestHandler.
1918
1919 // TODO(davidben): Attach AppCacheInterceptor.
1920
1921 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
1922 new_request.get(), loader));
1923
1924 // Insert a buffered event handler before the actual one.
1925 handler.reset(
1926 new BufferedResourceHandler(handler.Pass(), this, new_request.get()));
1927
1928 ScopedVector<ResourceThrottle> throttles;
1929 if (delegate_) {
1930 // TODO(davidben): appcache_service is currently NULL.
1931 delegate_->RequestBeginning(new_request.get(),
1932 resource_context,
1933 NULL,
1934 resource_type,
1935 &throttles);
1936 }
1937
1938 if (new_request->has_upload()) {
1939 // Block power save while uploading data.
1940 throttles.push_back(new PowerSaveBlockResourceThrottle());
1941 }
1942
1943 // TODO(davidben): Attach ResourceScheduler's throttle.
1944
1945 handler.reset(new ThrottlingResourceHandler(
1946 handler.Pass(), new_request.get(), throttles.Pass()));
1947
1948 BeginRequestInternal(new_request.Pass(), handler.Pass());
1772 } 1949 }
1773 1950
1774 // static 1951 // static
1775 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 1952 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
1776 net::URLRequest* request) { 1953 net::URLRequest* request) {
1777 // The following fields should be a minor size contribution (experimentally 1954 // The following fields should be a minor size contribution (experimentally
1778 // on the order of 100). However since they are variable length, it could 1955 // on the order of 100). However since they are variable length, it could
1779 // in theory be a sizeable contribution. 1956 // in theory be a sizeable contribution.
1780 int strings_cost = request->extra_request_headers().ToString().size() + 1957 int strings_cost = request->extra_request_headers().ToString().size() +
1781 request->original_url().spec().size() + 1958 request->original_url().spec().size() +
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 2322
2146 // Add a flag to selectively bypass the data reduction proxy if the resource 2323 // Add a flag to selectively bypass the data reduction proxy if the resource
2147 // type is not an image. 2324 // type is not an image.
2148 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2325 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2149 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2326 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2150 2327
2151 return load_flags; 2328 return load_flags;
2152 } 2329 }
2153 2330
2154 } // namespace content 2331 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/stream_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698