Commit d0a70f4b authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Remove some duplicate code between NavigationURLLoaderImpl and...

Remove some duplicate code between NavigationURLLoaderImpl and ResourceDispatcherHostImpl::BeginNavigationRequest.

Change-Id: I7befae9ca3d332d5d31a5d0424de8eeb355a8810
Reviewed-on: https://chromium-review.googlesource.com/c/1325151
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606372}
parent 89c69fe7
......@@ -489,6 +489,11 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
default_loader_used_ = true;
uint32_t options = GetURLLoaderOptions(request_info_->is_main_frame);
// A URLLoaderThrottle may have changed the headers.
request_info_->begin_params->headers =
resource_request_->headers.ToString();
request_info_->begin_params->load_flags = resource_request_->load_flags;
bool intercepted = false;
if (g_interceptor.Get()) {
// Recreate the ResourceRequest for the interceptor, in case a
......@@ -496,7 +501,8 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
auto latest_resource_request =
CreateResourceRequest(request_info_.get(), frame_tree_node_id_,
resource_request_->allow_download);
latest_resource_request->headers = resource_request_->headers;
latest_resource_request->headers.AddHeadersFromString(
request_info_->begin_params->headers);
intercepted = g_interceptor.Get().Run(
&url_loader, frame_tree_node_id_, 0 /* request_id */, options,
*latest_resource_request, &url_loader_client,
......@@ -504,10 +510,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
kNavigationUrlLoaderTrafficAnnotation));
}
// A URLLoaderThrottle may have changed the headers.
request_info_->begin_params->headers =
resource_request_->headers.ToString();
// The ResourceDispatcherHostImpl can be null in unit tests.
if (!intercepted && ResourceDispatcherHostImpl::Get()) {
ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
......@@ -515,7 +517,8 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
upload_file_system_context, *request_info_,
std::move(navigation_ui_data_), std::move(url_loader_client),
std::move(url_loader), service_worker_navigation_handle_core,
appcache_handle_core, options, global_request_id_);
appcache_handle_core, options, resource_request_->priority,
global_request_id_);
}
// TODO(arthursonzogni): Detect when the ResourceDispatcherHost didn't
......
......@@ -1428,6 +1428,7 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
ServiceWorkerNavigationHandleCore* service_worker_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core,
uint32_t url_loader_options,
net::RequestPriority net_priority,
const GlobalRequestID& global_request_id) {
DCHECK(url_loader_client.is_bound());
DCHECK(url_loader_request.is_pending());
......@@ -1456,20 +1457,7 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
return;
}
int load_flags = info.begin_params->load_flags;
if (info.is_main_frame)
load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED;
// Sync loads should have maximum priority and should be the only
// requests that have the ignore limits flag set.
DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS));
std::unique_ptr<net::URLRequest> new_request;
net::RequestPriority net_priority = net::HIGHEST;
if (!info.is_main_frame &&
base::FeatureList::IsEnabled(features::kLowPriorityIframes)) {
net_priority = net::LOWEST;
}
new_request = request_context->CreateRequest(
info.common_params.url, net_priority, nullptr, GetTrafficAnnotation());
......@@ -1491,18 +1479,9 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
net::HttpRequestHeaders headers;
headers.AddHeadersFromString(info.begin_params->headers);
std::string accept_value = network::kFrameAcceptHeader;
if (signed_exchange_utils::ShouldAdvertiseAcceptHeader(
url::Origin::Create(info.common_params.url))) {
DCHECK(!accept_value.empty());
accept_value.append(kAcceptHeaderSignedExchangeSuffix);
}
headers.SetHeader(network::kAcceptHeader, accept_value);
new_request->SetExtraRequestHeaders(headers);
new_request->SetLoadFlags(load_flags);
new_request->SetLoadFlags(info.begin_params->load_flags);
storage::BlobStorageContext* blob_context = GetBlobStorageContext(
GetChromeBlobStorageContextForResourceContext(resource_context));
......
......@@ -243,6 +243,7 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl
ServiceWorkerNavigationHandleCore* service_worker_handle_core,
AppCacheNavigationHandleCore* appcache_handle_core,
uint32_t url_loader_options,
net::RequestPriority net_priority,
const GlobalRequestID& global_request_id);
int num_in_flight_requests_for_testing() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment