Commit 6e5c4298 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

Remove interceptor disabled path from NavigationURLLoaderImpl.

ServiceWorkerServicification is always enabled now, so
loader interceptors are always enabled.

Bug: 926114
Change-Id: I77855393a475da5636c7c855d6456b6819cd3e82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506062Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638478}
parent 08377ef0
...@@ -128,16 +128,6 @@ base::LazyInstance<NavigationURLLoaderImpl::BeginNavigationInterceptor>::Leaky ...@@ -128,16 +128,6 @@ base::LazyInstance<NavigationURLLoaderImpl::BeginNavigationInterceptor>::Leaky
base::LazyInstance<NavigationURLLoaderImpl::URLLoaderFactoryInterceptor>::Leaky base::LazyInstance<NavigationURLLoaderImpl::URLLoaderFactoryInterceptor>::Leaky
g_loader_factory_interceptor = LAZY_INSTANCE_INITIALIZER; g_loader_factory_interceptor = LAZY_INSTANCE_INITIALIZER;
// Returns true if interception by NavigationLoaderInterceptors is enabled.
// Both ServiceWorkerServicification and SignedExchange require the loader
// interception. So even if NetworkService is not enabled, returns true when one
// of them is enabled.
bool IsLoaderInterceptionEnabled() {
return base::FeatureList::IsEnabled(network::features::kNetworkService) ||
blink::ServiceWorkerUtils::IsServicificationEnabled() ||
signed_exchange_utils::IsSignedExchangeHandlingEnabled();
}
size_t GetCertificateChainsSizeInKB(const net::SSLInfo& ssl_info) { size_t GetCertificateChainsSizeInKB(const net::SSLInfo& ssl_info) {
base::Pickle cert_pickle; base::Pickle cert_pickle;
ssl_info.cert->Persist(&cert_pickle); ssl_info.cert->Persist(&cert_pickle);
...@@ -268,13 +258,11 @@ std::unique_ptr<network::ResourceRequest> CreateResourceRequest( ...@@ -268,13 +258,11 @@ std::unique_ptr<network::ResourceRequest> CreateResourceRequest(
return new_request; return new_request;
} }
// Used only when NetworkService is disabled but IsLoaderInterceptionEnabled() // Used only when NetworkService is disabled.
// is true.
std::unique_ptr<NavigationRequestInfo> CreateNavigationRequestInfoForRedirect( std::unique_ptr<NavigationRequestInfo> CreateNavigationRequestInfoForRedirect(
const NavigationRequestInfo& previous_request_info, const NavigationRequestInfo& previous_request_info,
const network::ResourceRequest& updated_resource_request) { const network::ResourceRequest& updated_resource_request) {
DCHECK(!base::FeatureList::IsEnabled(network::features::kNetworkService)); DCHECK(!base::FeatureList::IsEnabled(network::features::kNetworkService));
DCHECK(IsLoaderInterceptionEnabled());
CommonNavigationParams new_common_params = CommonNavigationParams new_common_params =
previous_request_info.common_params; previous_request_info.common_params;
...@@ -766,7 +754,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -766,7 +754,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
// This could be called multiple times to follow a chain of redirects. // This could be called multiple times to follow a chain of redirects.
void Restart() { void Restart() {
DCHECK(IsLoaderInterceptionEnabled());
// Clear |url_loader_| if it's not the default one (network). This allows // Clear |url_loader_| if it's not the default one (network). This allows
// the restarted request to use a new loader, instead of, e.g., reusing the // the restarted request to use a new loader, instead of, e.g., reusing the
// AppCache or service worker loader. For an optimization, we keep and reuse // AppCache or service worker loader. For an optimization, we keep and reuse
...@@ -795,7 +782,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -795,7 +782,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
NavigationLoaderInterceptor* interceptor, NavigationLoaderInterceptor* interceptor,
SingleRequestURLLoaderFactory::RequestHandler single_request_handler) { SingleRequestURLLoaderFactory::RequestHandler single_request_handler) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(IsLoaderInterceptionEnabled());
DCHECK(started_); DCHECK(started_);
if (single_request_handler) { if (single_request_handler) {
...@@ -1031,11 +1017,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -1031,11 +1017,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
common_params->method = redirect_info_.new_method; common_params->method = redirect_info_.new_method;
} }
if (!IsLoaderInterceptionEnabled()) {
url_loader_->FollowRedirect(removed_headers, modified_headers);
return;
}
// Update |resource_request_| and call Restart to give our |interceptors_| a // Update |resource_request_| and call Restart to give our |interceptors_| a
// chance at handling the new location. If no interceptor wants to take // chance at handling the new location. If no interceptor wants to take
// over, we'll use the existing url_loader to follow the redirect, see // over, we'll use the existing url_loader to follow the redirect, see
...@@ -1114,38 +1095,36 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -1114,38 +1095,36 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
std::unique_ptr<NavigationData> cloned_navigation_data; std::unique_ptr<NavigationData> cloned_navigation_data;
if (IsLoaderInterceptionEnabled()) { bool must_download =
bool must_download = download_utils::MustDownload( download_utils::MustDownload(url_, head.headers.get(), head.mime_type);
url_, head.headers.get(), head.mime_type); bool known_mime_type = blink::IsSupportedMimeType(head.mime_type);
bool known_mime_type = blink::IsSupportedMimeType(head.mime_type);
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
if (!head.intercepted_by_plugin && !must_download && !known_mime_type) { if (!head.intercepted_by_plugin && !must_download && !known_mime_type) {
// No plugin throttles intercepted the response. Ask if the plugin // No plugin throttles intercepted the response. Ask if the plugin
// registered to PluginService wants to handle the request. // registered to PluginService wants to handle the request.
CheckPluginAndContinueOnReceiveResponse( CheckPluginAndContinueOnReceiveResponse(
head, std::move(url_loader_client_endpoints), head, std::move(url_loader_client_endpoints),
true /* is_download_if_not_handled_by_plugin */, true /* is_download_if_not_handled_by_plugin */,
std::vector<WebPluginInfo>()); std::vector<WebPluginInfo>());
return; return;
} }
#endif #endif
// When a plugin intercepted the response, we don't want to download it. // When a plugin intercepted the response, we don't want to download it.
is_download = is_download =
!head.intercepted_by_plugin && (must_download || !known_mime_type); !head.intercepted_by_plugin && (must_download || !known_mime_type);
is_stream = false; is_stream = false;
// If NetworkService is on, or an interceptor handled the request, the // If NetworkService is on, or an interceptor handled the request, the
// request doesn't use ResourceDispatcherHost so // request doesn't use ResourceDispatcherHost so
// CallOnReceivedResponse and return here. // CallOnReceivedResponse and return here.
if (base::FeatureList::IsEnabled(network::features::kNetworkService) || if (base::FeatureList::IsEnabled(network::features::kNetworkService) ||
!default_loader_used_) { !default_loader_used_) {
CallOnReceivedResponse(head, std::move(url_loader_client_endpoints), CallOnReceivedResponse(head, std::move(url_loader_client_endpoints),
std::move(cloned_navigation_data), is_download, std::move(cloned_navigation_data), is_download,
is_stream); is_stream);
return; return;
}
} }
// NetworkService is off and an interceptor didn't handle the request, // NetworkService is off and an interceptor didn't handle the request,
...@@ -1353,9 +1332,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -1353,9 +1332,6 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
// different response. For e.g. AppCache may have fallback content. // different response. For e.g. AppCache may have fallback content.
bool MaybeCreateLoaderForResponse( bool MaybeCreateLoaderForResponse(
const network::ResourceResponseHead& response) { const network::ResourceResponseHead& response) {
if (!IsLoaderInterceptionEnabled())
return false;
if (!default_loader_used_) if (!default_loader_used_)
return false; return false;
...@@ -1508,7 +1484,7 @@ class NavigationURLLoaderImpl::URLLoaderRequestController ...@@ -1508,7 +1484,7 @@ class NavigationURLLoaderImpl::URLLoaderRequestController
// Generator of a request handler for sending request to the network. This // Generator of a request handler for sending request to the network. This
// captures all of parameters to create a // captures all of parameters to create a
// SingleRequestURLLoaderFactory::RequestHandler. Used only when // SingleRequestURLLoaderFactory::RequestHandler. Used only when
// NetworkService is disabled but IsLoaderInterceptionEnabled() is true. // NetworkService is disabled.
// Set |was_request_intercepted| to true if the request was intercepted by an // Set |was_request_intercepted| to true if the request was intercepted by an
// interceptor and the request is falling back to the network. In that case, // interceptor and the request is falling back to the network. In that case,
// any interceptors won't intercept the request. // any interceptors won't intercept the request.
......
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