Commit 44727012 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Have no-state prefetch use PrefetchURLLoader

To delete WebURLLoaderImpl::SinkPeer, this CL has PrefetchURLLoader
to handle no-state prefetch requests.

Bug: 1112310
Change-Id: I2c13bd91969bdb41105f246d570f9ca100a63c4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041152Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795753}
parent 90ed689c
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_features.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
...@@ -557,13 +558,15 @@ class NoStatePrefetchBrowserTest ...@@ -557,13 +558,15 @@ class NoStatePrefetchBrowserTest
class NoStatePrefetchBrowserTestHttpCache class NoStatePrefetchBrowserTestHttpCache
: public NoStatePrefetchBrowserTest, : public NoStatePrefetchBrowserTest,
public testing::WithParamInterface<std::tuple<bool, bool>> { public testing::WithParamInterface<std::tuple<bool, bool, bool>> {
protected: protected:
void SetUp() override { void SetUp() override {
bool split_cache_by_network_isolation_key; bool split_cache_by_network_isolation_key;
bool append_frame_origin_to_network_isolation_key; bool append_frame_origin_to_network_isolation_key;
bool use_prefetch_loader;
std::tie(split_cache_by_network_isolation_key, std::tie(split_cache_by_network_isolation_key,
append_frame_origin_to_network_isolation_key) = GetParam(); append_frame_origin_to_network_isolation_key,
use_prefetch_loader) = GetParam();
std::vector<base::Feature> disabled_and_enabled_features[2]; std::vector<base::Feature> disabled_and_enabled_features[2];
...@@ -571,6 +574,8 @@ class NoStatePrefetchBrowserTestHttpCache ...@@ -571,6 +574,8 @@ class NoStatePrefetchBrowserTestHttpCache
.push_back(net::features::kSplitCacheByNetworkIsolationKey); .push_back(net::features::kSplitCacheByNetworkIsolationKey);
disabled_and_enabled_features[append_frame_origin_to_network_isolation_key] disabled_and_enabled_features[append_frame_origin_to_network_isolation_key]
.push_back(net::features::kAppendFrameOriginToNetworkIsolationKey); .push_back(net::features::kAppendFrameOriginToNetworkIsolationKey);
disabled_and_enabled_features[use_prefetch_loader].push_back(
features::kNoStatePrefetchUsingPrefetchLoader);
feature_list_.InitWithFeatures(disabled_and_enabled_features[true], feature_list_.InitWithFeatures(disabled_and_enabled_features[true],
disabled_and_enabled_features[false]); disabled_and_enabled_features[false]);
...@@ -591,8 +596,8 @@ IN_PROC_BROWSER_TEST_P( ...@@ -591,8 +596,8 @@ IN_PROC_BROWSER_TEST_P(
NoStatePrefetchBrowserTestHttpCache_DefaultAndAppendFrameOrigin, NoStatePrefetchBrowserTestHttpCache_DefaultAndAppendFrameOrigin,
PrefetchTwoCrossOriginFrames) { PrefetchTwoCrossOriginFrames) {
bool append_frame_origin_to_network_isolation_key; bool append_frame_origin_to_network_isolation_key;
std::tie(std::ignore, append_frame_origin_to_network_isolation_key) = std::tie(std::ignore, append_frame_origin_to_network_isolation_key,
GetParam(); std::ignore) = GetParam();
GURL image_src = GURL image_src =
embedded_test_server()->GetURL("/prerender/cacheable_image.png"); embedded_test_server()->GetURL("/prerender/cacheable_image.png");
...@@ -622,7 +627,9 @@ IN_PROC_BROWSER_TEST_P( ...@@ -622,7 +627,9 @@ IN_PROC_BROWSER_TEST_P(
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
All, All,
NoStatePrefetchBrowserTestHttpCache_DefaultAndAppendFrameOrigin, NoStatePrefetchBrowserTestHttpCache_DefaultAndAppendFrameOrigin,
::testing::Combine(::testing::Values(true), ::testing::Bool())); ::testing::Combine(::testing::Values(true),
::testing::Bool(),
::testing::Bool()));
// Checks that a page is correctly prefetched in the case of a // Checks that a page is correctly prefetched in the case of a
// <link rel=prerender> tag and the JavaScript on the page is not executed. // <link rel=prerender> tag and the JavaScript on the page is not executed.
...@@ -701,7 +708,9 @@ IN_PROC_BROWSER_TEST_P( ...@@ -701,7 +708,9 @@ IN_PROC_BROWSER_TEST_P(
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
All, All,
NoStatePrefetchBrowserTestHttpCache_DefaultAndDoubleKeyedHttpCache, NoStatePrefetchBrowserTestHttpCache_DefaultAndDoubleKeyedHttpCache,
::testing::Combine(::testing::Bool(), ::testing::Values(false))); ::testing::Combine(::testing::Bool(),
::testing::Values(false),
::testing::Bool()));
// Checks that the expected resource types are fetched via NoState Prefetch. // Checks that the expected resource types are fetched via NoState Prefetch.
IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchAllResourceTypes) { IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchAllResourceTypes) {
......
...@@ -117,8 +117,6 @@ void PrefetchURLLoaderService::CreateLoaderAndStart( ...@@ -117,8 +117,6 @@ void PrefetchURLLoaderService::CreateLoaderAndStart(
// request. // request.
network::ResourceRequest resource_request = resource_request_in; network::ResourceRequest resource_request = resource_request_in;
DCHECK_EQ(static_cast<int>(blink::mojom::ResourceType::kPrefetch),
resource_request.resource_type);
BindContext& current_context = *current_bind_context(); BindContext& current_context = *current_bind_context();
if (!current_context.render_frame_host) { if (!current_context.render_frame_host) {
......
...@@ -396,6 +396,12 @@ const base::Feature kNetworkServiceInProcess { ...@@ -396,6 +396,12 @@ const base::Feature kNetworkServiceInProcess {
const base::Feature kNeverSlowMode{"NeverSlowMode", const base::Feature kNeverSlowMode{"NeverSlowMode",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// A kill switch for the change for more code sharing between usual prefetch
// and no-state prefetch.
// TODO(yhirano): Remove this if M86 stable looks good.
const base::Feature kNoStatePrefetchUsingPrefetchLoader{
"NoStatePrefetchUsingPrefetchLoader", base::FEATURE_ENABLED_BY_DEFAULT};
// Kill switch for Web Notification content images. // Kill switch for Web Notification content images.
const base::Feature kNotificationContentImage{"NotificationContentImage", const base::Feature kNotificationContentImage{"NotificationContentImage",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -91,6 +91,7 @@ CONTENT_EXPORT extern const base::Feature kMouseSubframeNoImplicitCapture; ...@@ -91,6 +91,7 @@ CONTENT_EXPORT extern const base::Feature kMouseSubframeNoImplicitCapture;
CONTENT_EXPORT extern const base::Feature kNetworkQualityEstimatorWebHoldback; CONTENT_EXPORT extern const base::Feature kNetworkQualityEstimatorWebHoldback;
CONTENT_EXPORT extern const base::Feature kNetworkServiceInProcess; CONTENT_EXPORT extern const base::Feature kNetworkServiceInProcess;
CONTENT_EXPORT extern const base::Feature kNeverSlowMode; CONTENT_EXPORT extern const base::Feature kNeverSlowMode;
CONTENT_EXPORT extern const base::Feature kNoStatePrefetchUsingPrefetchLoader;
CONTENT_EXPORT extern const base::Feature kNotificationContentImage; CONTENT_EXPORT extern const base::Feature kNotificationContentImage;
CONTENT_EXPORT extern const base::Feature kNotificationTriggers; CONTENT_EXPORT extern const base::Feature kNotificationTriggers;
CONTENT_EXPORT extern const base::Feature kOriginIsolationHeader; CONTENT_EXPORT extern const base::Feature kOriginIsolationHeader;
......
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
#include "base/check.h" #include "base/check.h"
#include "base/debug/crash_logging.h" #include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h" #include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/optional.h" #include "base/optional.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/load_flags.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h" #include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h" #include "url/origin.h"
...@@ -293,6 +296,16 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart( ...@@ -293,6 +296,16 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
std::move(client), traffic_annotation); std::move(client), traffic_annotation);
return; return;
} }
if (base::FeatureList::IsEnabled(
features::kNoStatePrefetchUsingPrefetchLoader) &&
(request.load_flags & net::LOAD_PREFETCH) && prefetch_loader_factory_) {
// This is no-state prefetch (see
// WebURLRequest::GetLoadFlagsForWebUrlRequest).
prefetch_loader_factory_->CreateLoaderAndStart(
std::move(loader), routing_id, request_id, options, request,
std::move(client), traffic_annotation);
return;
}
URLLoaderFactoryBundle::CreateLoaderAndStart( URLLoaderFactoryBundle::CreateLoaderAndStart(
std::move(loader), routing_id, request_id, options, request, std::move(loader), routing_id, request_id, options, request,
......
...@@ -649,7 +649,9 @@ void WebURLLoaderImpl::Context::Start( ...@@ -649,7 +649,9 @@ void WebURLLoaderImpl::Context::Start(
extra_data->CopyToResourceRequest(request.get()); extra_data->CopyToResourceRequest(request.get());
std::unique_ptr<RequestPeer> peer; std::unique_ptr<RequestPeer> peer;
if (download_to_network_cache_only) { if (download_to_network_cache_only &&
!base::FeatureList::IsEnabled(
features::kNoStatePrefetchUsingPrefetchLoader)) {
peer = std::make_unique<SinkPeer>(this); peer = std::make_unique<SinkPeer>(this);
} else { } else {
peer = std::make_unique<WebURLLoaderImpl::RequestPeerImpl>(this); peer = std::make_unique<WebURLLoaderImpl::RequestPeerImpl>(this);
......
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