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 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.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/url_constants.h"
#include "content/public/test/browser_test.h"
......@@ -557,13 +558,15 @@ class NoStatePrefetchBrowserTest
class NoStatePrefetchBrowserTestHttpCache
: public NoStatePrefetchBrowserTest,
public testing::WithParamInterface<std::tuple<bool, bool>> {
public testing::WithParamInterface<std::tuple<bool, bool, bool>> {
protected:
void SetUp() override {
bool split_cache_by_network_isolation_key;
bool append_frame_origin_to_network_isolation_key;
bool use_prefetch_loader;
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];
......@@ -571,6 +574,8 @@ class NoStatePrefetchBrowserTestHttpCache
.push_back(net::features::kSplitCacheByNetworkIsolationKey);
disabled_and_enabled_features[append_frame_origin_to_network_isolation_key]
.push_back(net::features::kAppendFrameOriginToNetworkIsolationKey);
disabled_and_enabled_features[use_prefetch_loader].push_back(
features::kNoStatePrefetchUsingPrefetchLoader);
feature_list_.InitWithFeatures(disabled_and_enabled_features[true],
disabled_and_enabled_features[false]);
......@@ -591,8 +596,8 @@ IN_PROC_BROWSER_TEST_P(
NoStatePrefetchBrowserTestHttpCache_DefaultAndAppendFrameOrigin,
PrefetchTwoCrossOriginFrames) {
bool append_frame_origin_to_network_isolation_key;
std::tie(std::ignore, append_frame_origin_to_network_isolation_key) =
GetParam();
std::tie(std::ignore, append_frame_origin_to_network_isolation_key,
std::ignore) = GetParam();
GURL image_src =
embedded_test_server()->GetURL("/prerender/cacheable_image.png");
......@@ -622,7 +627,9 @@ IN_PROC_BROWSER_TEST_P(
INSTANTIATE_TEST_SUITE_P(
All,
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
// <link rel=prerender> tag and the JavaScript on the page is not executed.
......@@ -701,7 +708,9 @@ IN_PROC_BROWSER_TEST_P(
INSTANTIATE_TEST_SUITE_P(
All,
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.
IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchAllResourceTypes) {
......
......@@ -117,8 +117,6 @@ void PrefetchURLLoaderService::CreateLoaderAndStart(
// request.
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();
if (!current_context.render_frame_host) {
......
......@@ -396,6 +396,12 @@ const base::Feature kNetworkServiceInProcess {
const base::Feature kNeverSlowMode{"NeverSlowMode",
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.
const base::Feature kNotificationContentImage{"NotificationContentImage",
base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -91,6 +91,7 @@ CONTENT_EXPORT extern const base::Feature kMouseSubframeNoImplicitCapture;
CONTENT_EXPORT extern const base::Feature kNetworkQualityEstimatorWebHoldback;
CONTENT_EXPORT extern const base::Feature kNetworkServiceInProcess;
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 kNotificationTriggers;
CONTENT_EXPORT extern const base::Feature kOriginIsolationHeader;
......
......@@ -12,8 +12,11 @@
#include "base/check.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/optional.h"
#include "content/public/common/content_features.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 "url/gurl.h"
#include "url/origin.h"
......@@ -293,6 +296,16 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
std::move(client), traffic_annotation);
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(
std::move(loader), routing_id, request_id, options, request,
......
......@@ -649,7 +649,9 @@ void WebURLLoaderImpl::Context::Start(
extra_data->CopyToResourceRequest(request.get());
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);
} else {
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