DsePreload2: Make PreloadPipelineInfo //content public
This CL is a preparation of https://crbug.com/394215571. We need PreloadPipelineInfo in //chrome to start prefetch from DSE. Bug: 394215571 Change-Id: Id5218b40b8aa5054d5c8d43ded499f431a7ef43b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6232385 Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Commit-Queue: Ken Okada <kenoss@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Cr-Commit-Position: refs/heads/main@{#1428912}
This commit is contained in:
content
browser
BUILD.gn
preloading
prefetch
no_vary_search_helper_unittest.ccprefetch_container.ccprefetch_container.hprefetch_container_unittest.ccprefetch_document_manager.ccprefetch_document_manager.hprefetch_service_unittest.ccprefetch_url_loader_interceptor_unittest.cc
preload_pipeline_info.ccpreload_pipeline_info.hpreload_pipeline_info_impl.ccpreload_pipeline_info_impl.hprerender
prerender_attributes.ccprerender_attributes.hprerender_host_registry_unittest.ccprerender_host_unittest.cc
prerenderer_impl.ccweb_contents
public
test
@ -1611,8 +1611,8 @@ source_set("browser") {
|
||||
"preloading/prefetch/proxy_lookup_client_impl.h",
|
||||
"preloading/prefetcher.cc",
|
||||
"preloading/prefetcher.h",
|
||||
"preloading/preload_pipeline_info.cc",
|
||||
"preloading/preload_pipeline_info.h",
|
||||
"preloading/preload_pipeline_info_impl.cc",
|
||||
"preloading/preload_pipeline_info_impl.h",
|
||||
"preloading/preloading.cc",
|
||||
"preloading/preloading.h",
|
||||
"preloading/preloading_attempt_impl.cc",
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include "content/browser/preloading/prefetch/prefetch_container.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_test_util_internal.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/test/test_renderer_host.h"
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
@ -108,9 +108,8 @@ class NoVarySearchHelperTester final {
|
||||
blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<
|
||||
PreloadPipelineInfo>(/*planned_max_preloading_type=*/
|
||||
PreloadingType::kPrefetch));
|
||||
PreloadPipelineInfo::Create(/*planned_max_preloading_type=*/
|
||||
PreloadingType::kPrefetch));
|
||||
|
||||
prefetch_container->SimulatePrefetchEligibleForTest();
|
||||
MakeServableStreamingURLLoaderForTest(prefetch_container.get(),
|
||||
|
@ -307,7 +307,7 @@ void RecordAfterClickRedirectChainSize(size_t redirect_chain_size) {
|
||||
}
|
||||
|
||||
bool CalculateIsLikelyAheadOfPrerender(
|
||||
const PreloadPipelineInfo& preload_pipeline_info) {
|
||||
const PreloadPipelineInfoImpl& preload_pipeline_info) {
|
||||
if (!base::FeatureList::IsEnabled(
|
||||
features::kPrerender2FallbackPrefetchSpecRules)) {
|
||||
return false;
|
||||
@ -443,7 +443,7 @@ PrefetchContainer::PrefetchContainer(
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
referring_web_contents.GetBrowserContext()->GetWeakPtr(),
|
||||
ukm::kInvalidSourceId,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch),
|
||||
std::move(attempt),
|
||||
holdback_status_override,
|
||||
@ -481,7 +481,7 @@ PrefetchContainer::PrefetchContainer(
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
browser_context->GetWeakPtr(),
|
||||
ukm::kInvalidSourceId,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch),
|
||||
std::move(attempt),
|
||||
/*holdback_status_override=*/std::nullopt,
|
||||
@ -524,7 +524,8 @@ PrefetchContainer::PrefetchContainer(
|
||||
browser_context_(std::move(browser_context)),
|
||||
ukm_source_id_(ukm_source_id),
|
||||
request_id_(base::UnguessableToken::Create().ToString()),
|
||||
preload_pipeline_info_(std::move(preload_pipeline_info)),
|
||||
preload_pipeline_info_(base::WrapRefCounted(
|
||||
static_cast<PreloadPipelineInfoImpl*>(preload_pipeline_info.get()))),
|
||||
attempt_(std::move(attempt)),
|
||||
holdback_status_override_(holdback_status_override),
|
||||
initiator_devtools_navigation_token_(
|
||||
|
@ -19,10 +19,11 @@
|
||||
#include "content/browser/preloading/prefetch/prefetch_status.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_streaming_url_loader_common_types.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_type.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/public/browser/global_routing_id.h"
|
||||
#include "content/public/browser/prefetch_request_status_listener.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
#include "content/public/browser/preloading_data.h"
|
||||
#include "net/http/http_no_vary_search_data.h"
|
||||
@ -982,8 +983,8 @@ class CONTENT_EXPORT PrefetchContainer {
|
||||
//
|
||||
// Note that we distinguish the primary one and inherited ones because we send
|
||||
// CDP events with id of `preload_pipeline_info_`.
|
||||
scoped_refptr<PreloadPipelineInfo> preload_pipeline_info_;
|
||||
std::vector<scoped_refptr<PreloadPipelineInfo>>
|
||||
scoped_refptr<PreloadPipelineInfoImpl> preload_pipeline_info_;
|
||||
std::vector<scoped_refptr<PreloadPipelineInfoImpl>>
|
||||
inherited_preload_pipeline_infos_;
|
||||
|
||||
// `PreloadingAttempt` is used to track the lifecycle of the preloading event,
|
||||
|
@ -16,10 +16,10 @@
|
||||
#include "content/browser/preloading/prefetch/prefetch_status.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_test_util_internal.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_type.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/global_routing_id.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
@ -78,7 +78,7 @@ class PrefetchContainerTestBase : public RenderViewHostTestHarness {
|
||||
blink::mojom::SpeculationEagerness::kEager),
|
||||
blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt, prefetch_document_manager,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ TEST_P(PrefetchContainerTest, CreatePrefetchContainer) {
|
||||
blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
|
||||
EXPECT_EQ(prefetch_container.GetReferringRenderFrameHostId(),
|
||||
@ -894,7 +894,7 @@ TEST_P(PrefetchContainerTest, BlockUntilHeadHistograms) {
|
||||
blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
|
||||
prefetch_container.OnGetPrefetchToServe(test_case.block_until_head);
|
||||
@ -970,7 +970,7 @@ TEST_P(PrefetchContainerTest, BlockUntilHeadHistograms2) {
|
||||
blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
|
||||
prefetch_container.OnUnregisterCandidate(
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "content/browser/preloading/prefetch/prefetch_container.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_params.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_service.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
#include "content/browser/preloading/preloading.h"
|
||||
#include "content/browser/preloading/preloading_attempt_impl.h"
|
||||
#include "content/browser/preloading/preloading_data_impl.h"
|
||||
@ -196,7 +197,7 @@ void PrefetchDocumentManager::ProcessCandidates(
|
||||
GetPredictorForPreloadingTriggerType(prefetch_type.trigger_type());
|
||||
PrefetchUrl(prefetch_url, prefetch_type, enacting_predictor, referrer,
|
||||
no_vary_search_hint,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
}
|
||||
|
||||
@ -216,7 +217,7 @@ bool PrefetchDocumentManager::MaybePrefetch(
|
||||
SpeculationCandidateToPrefetchUrlParams(candidate);
|
||||
PrefetchUrl(prefetch_url, prefetch_type, enacting_predictor, referrer,
|
||||
no_vary_search_hint,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch));
|
||||
return true;
|
||||
}
|
||||
@ -239,7 +240,8 @@ void PrefetchDocumentManager::PrefetchUrl(
|
||||
const network::mojom::NoVarySearchPtr& mojo_no_vary_search_hint,
|
||||
scoped_refptr<PreloadPipelineInfo> preload_pipeline_info) {
|
||||
const std::pair<GURL, PreloadingType> all_prefetches_key =
|
||||
std::make_pair(url, preload_pipeline_info->planned_max_preloading_type());
|
||||
std::make_pair(url, PreloadPipelineInfoImpl::From(*preload_pipeline_info)
|
||||
.planned_max_preloading_type());
|
||||
|
||||
// Skip prefetches that have already been requested.
|
||||
auto prefetch_container_iter = all_prefetches_.find(all_prefetches_key);
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_type.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/common/features.h"
|
||||
#include "content/public/browser/document_user_data.h"
|
||||
#include "content/public/browser/prefetch_metrics.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "net/http/http_no_vary_search_data.h"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "content/browser/preloading/prefetch/prefetch_streaming_url_loader.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_test_util_internal.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_type.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preloading.h"
|
||||
#include "content/browser/preloading/preloading_attempt_impl.h"
|
||||
#include "content/browser/preloading/preloading_config.h"
|
||||
@ -46,6 +45,7 @@
|
||||
#include "content/public/browser/frame_accept_header.h"
|
||||
#include "content/public/browser/prefetch_request_status_listener.h"
|
||||
#include "content/public/browser/prefetch_service_delegate.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
@ -449,7 +449,7 @@ class PrefetchServiceTestBase : public PrefetchingMetricsTestBase {
|
||||
prefetch_url, prefetch_type,
|
||||
GetPredictorForPreloadingTriggerType(prefetch_type.trigger_type()),
|
||||
referrer, no_vary_search_hint,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(planned_max_preloading_type));
|
||||
PreloadPipelineInfo::Create(planned_max_preloading_type));
|
||||
}
|
||||
|
||||
void MakePrefetchFromEmbedder(
|
||||
@ -7141,7 +7141,7 @@ class PrefetchServiceAddPrefetchContainerTest : public PrefetchServiceTestBase {
|
||||
prefetch_url, std::move(prefetch_type), blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(planned_max_preloading_type),
|
||||
PreloadPipelineInfo::Create(planned_max_preloading_type),
|
||||
attempt->GetWeakPtr());
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ class PrefetchURLLoaderInterceptorTestBase : public PrefetchingMetricsTestBase {
|
||||
std::move(prefetch_type), blink::mojom::Referrer(),
|
||||
/*no_vary_search_hint=*/std::nullopt,
|
||||
/*prefetch_document_manager=*/nullptr,
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfo::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrefetch),
|
||||
attempt->GetWeakPtr());
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
PreloadPipelineInfo::PreloadPipelineInfo(
|
||||
PreloadingType planned_max_preloading_type)
|
||||
: id_(base::UnguessableToken::Create()),
|
||||
planned_max_preloading_type_(planned_max_preloading_type) {}
|
||||
|
||||
PreloadPipelineInfo::~PreloadPipelineInfo() = default;
|
||||
|
||||
void PreloadPipelineInfo::SetPrefetchEligibility(
|
||||
PreloadingEligibility eligibility) {
|
||||
prefetch_eligibility_ = eligibility;
|
||||
}
|
||||
|
||||
void PreloadPipelineInfo::SetPrefetchStatus(PrefetchStatus prefetch_status) {
|
||||
prefetch_status_ = prefetch_status;
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,82 +0,0 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_H_
|
||||
#define CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_status.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
// Holds immutable/mutable attributes of a preload pipeline.
|
||||
//
|
||||
// The information are used for, e.g. CDP and failure propagation.
|
||||
//
|
||||
// Each prefetch and prerender belongs to a pipeline.
|
||||
//
|
||||
// Ownership: At most, this is owend by a `PrefetchContainer` and
|
||||
// `PrerenderAttributes`, which is owned by `PrefetchContainer` (except for
|
||||
// transferring it to start preloads). Note that this can be moved from a
|
||||
// `PrefetchContainer` to another `PrefetchContainer`. See
|
||||
// `PrefetchContainer::MigrateNewlyAdded()`.
|
||||
class CONTENT_EXPORT PreloadPipelineInfo final
|
||||
: public base::RefCounted<PreloadPipelineInfo> {
|
||||
public:
|
||||
// `planned_max_preloading_type` is used to determine appropriate HTTP header
|
||||
// value `Sec-Purpose`. A caller must designate max preloading type that it
|
||||
// can trigger with this pipeline. That said, it is possible that other
|
||||
// triggers can use already triggered preloads.
|
||||
//
|
||||
// For example, if a pipeline is triggering prerender, it must create
|
||||
// `PreloadingPipelineInfo` with `kPrerender`, and then trigger prefetch and
|
||||
// prerender with this.
|
||||
//
|
||||
// Currently, only this type of pipeline is allowed: kPrefetch -> kPrerender.
|
||||
explicit PreloadPipelineInfo(PreloadingType planned_max_preloading_type);
|
||||
|
||||
// Not movable nor copyable.
|
||||
PreloadPipelineInfo(PreloadPipelineInfo&& other) = delete;
|
||||
PreloadPipelineInfo& operator=(PreloadPipelineInfo&& other) = delete;
|
||||
PreloadPipelineInfo(const PreloadPipelineInfo&) = delete;
|
||||
PreloadPipelineInfo& operator=(const PreloadPipelineInfo&) = delete;
|
||||
|
||||
// TODO(crbug.com/342089492): Add `const base::UnguessableToken& id() const {
|
||||
// return id_; }`
|
||||
|
||||
PreloadingType planned_max_preloading_type() const {
|
||||
return planned_max_preloading_type_;
|
||||
}
|
||||
|
||||
PreloadingEligibility prefetch_eligibility() const {
|
||||
return prefetch_eligibility_;
|
||||
}
|
||||
void SetPrefetchEligibility(PreloadingEligibility eligibility);
|
||||
|
||||
const std::optional<PrefetchStatus>& prefetch_status() const {
|
||||
return prefetch_status_;
|
||||
}
|
||||
void SetPrefetchStatus(PrefetchStatus prefetch_status);
|
||||
|
||||
const base::UnguessableToken& id() const { return id_; }
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<PreloadPipelineInfo>;
|
||||
~PreloadPipelineInfo();
|
||||
|
||||
const base::UnguessableToken id_;
|
||||
|
||||
const PreloadingType planned_max_preloading_type_;
|
||||
|
||||
PreloadingEligibility prefetch_eligibility_ =
|
||||
PreloadingEligibility::kUnspecified;
|
||||
std::optional<PrefetchStatus> prefetch_status_ = std::nullopt;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_H_
|
45
content/browser/preloading/preload_pipeline_info_impl.cc
Normal file
45
content/browser/preloading/preload_pipeline_info_impl.cc
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
// static
|
||||
scoped_refptr<PreloadPipelineInfo> PreloadPipelineInfo::Create(
|
||||
PreloadingType planned_max_preloading_type) {
|
||||
return PreloadPipelineInfoImpl::Create(planned_max_preloading_type);
|
||||
}
|
||||
|
||||
// static
|
||||
scoped_refptr<PreloadPipelineInfoImpl> PreloadPipelineInfoImpl::Create(
|
||||
PreloadingType planned_max_preloading_type) {
|
||||
return base::MakeRefCounted<PreloadPipelineInfoImpl>(
|
||||
planned_max_preloading_type);
|
||||
}
|
||||
|
||||
// static
|
||||
PreloadPipelineInfoImpl& PreloadPipelineInfoImpl::From(
|
||||
PreloadPipelineInfo& pipeline_info) {
|
||||
return static_cast<PreloadPipelineInfoImpl&>(pipeline_info);
|
||||
}
|
||||
|
||||
PreloadPipelineInfoImpl::PreloadPipelineInfoImpl(
|
||||
PreloadingType planned_max_preloading_type)
|
||||
: id_(base::UnguessableToken::Create()),
|
||||
planned_max_preloading_type_(planned_max_preloading_type) {}
|
||||
|
||||
PreloadPipelineInfoImpl::~PreloadPipelineInfoImpl() = default;
|
||||
|
||||
void PreloadPipelineInfoImpl::SetPrefetchEligibility(
|
||||
PreloadingEligibility eligibility) {
|
||||
prefetch_eligibility_ = eligibility;
|
||||
}
|
||||
|
||||
void PreloadPipelineInfoImpl::SetPrefetchStatus(
|
||||
PrefetchStatus prefetch_status) {
|
||||
prefetch_status_ = prefetch_status;
|
||||
}
|
||||
|
||||
} // namespace content
|
64
content/browser/preloading/preload_pipeline_info_impl.h
Normal file
64
content/browser/preloading/preload_pipeline_info_impl.h
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_IMPL_H_
|
||||
#define CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_IMPL_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_status.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class CONTENT_EXPORT PreloadPipelineInfoImpl final
|
||||
: public PreloadPipelineInfo {
|
||||
public:
|
||||
static scoped_refptr<PreloadPipelineInfoImpl> Create(
|
||||
PreloadingType planned_max_preloading_type);
|
||||
static PreloadPipelineInfoImpl& From(PreloadPipelineInfo& pipeline_info);
|
||||
|
||||
explicit PreloadPipelineInfoImpl(PreloadingType planned_max_preloading_type);
|
||||
|
||||
// Not movable nor copyable.
|
||||
PreloadPipelineInfoImpl(PreloadPipelineInfoImpl&& other) = delete;
|
||||
PreloadPipelineInfoImpl& operator=(PreloadPipelineInfoImpl&& other) = delete;
|
||||
PreloadPipelineInfoImpl(const PreloadPipelineInfoImpl&) = delete;
|
||||
PreloadPipelineInfoImpl& operator=(const PreloadPipelineInfoImpl&) = delete;
|
||||
|
||||
const base::UnguessableToken& id() const { return id_; }
|
||||
|
||||
PreloadingType planned_max_preloading_type() const {
|
||||
return planned_max_preloading_type_;
|
||||
}
|
||||
|
||||
PreloadingEligibility prefetch_eligibility() const {
|
||||
return prefetch_eligibility_;
|
||||
}
|
||||
void SetPrefetchEligibility(PreloadingEligibility eligibility);
|
||||
|
||||
const std::optional<PrefetchStatus>& prefetch_status() const {
|
||||
return prefetch_status_;
|
||||
}
|
||||
void SetPrefetchStatus(PrefetchStatus prefetch_status);
|
||||
|
||||
private:
|
||||
friend class base::RefCounted<PreloadPipelineInfo>;
|
||||
|
||||
~PreloadPipelineInfoImpl() override;
|
||||
|
||||
const base::UnguessableToken id_;
|
||||
|
||||
const PreloadingType planned_max_preloading_type_;
|
||||
|
||||
PreloadingEligibility prefetch_eligibility_ =
|
||||
PreloadingEligibility::kUnspecified;
|
||||
std::optional<PrefetchStatus> prefetch_status_ = std::nullopt;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_PRELOADING_PRELOAD_PIPELINE_INFO_IMPL_H_
|
@ -37,7 +37,7 @@ PrerenderAttributes::PrerenderAttributes(
|
||||
url_match_predicate,
|
||||
base::RepeatingCallback<void(NavigationHandle&)>
|
||||
prerender_navigation_handle_callback,
|
||||
scoped_refptr<PreloadPipelineInfo> preload_pipeline_info)
|
||||
scoped_refptr<PreloadPipelineInfoImpl> preload_pipeline_info)
|
||||
: prerendering_url(prerendering_url),
|
||||
trigger_type(trigger_type),
|
||||
embedder_histogram_suffix(embedder_histogram_suffix),
|
||||
|
@ -8,9 +8,10 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/public/browser/frame_tree_node_id.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
#include "content/public/browser/preloading_trigger_type.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
@ -55,7 +56,7 @@ struct CONTENT_EXPORT PrerenderAttributes {
|
||||
url_match_predicate,
|
||||
base::RepeatingCallback<void(NavigationHandle&)>
|
||||
prerender_navigation_handle_callback,
|
||||
scoped_refptr<PreloadPipelineInfo> preload_pipeline_info);
|
||||
scoped_refptr<PreloadPipelineInfoImpl> preload_pipeline_info);
|
||||
|
||||
~PrerenderAttributes();
|
||||
PrerenderAttributes(const PrerenderAttributes&);
|
||||
@ -141,7 +142,7 @@ struct CONTENT_EXPORT PrerenderAttributes {
|
||||
prerender_navigation_handle_callback;
|
||||
|
||||
// Information of preload pipeline that this prerender belongs to.
|
||||
scoped_refptr<PreloadPipelineInfo> preload_pipeline_info;
|
||||
scoped_refptr<PreloadPipelineInfoImpl> preload_pipeline_info;
|
||||
|
||||
// This is std::nullopt when prerendering is initiated by the browser.
|
||||
std::optional<base::UnguessableToken> initiator_devtools_navigation_token;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "base/test/bind.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
#include "content/browser/preloading/preloading.h"
|
||||
#include "content/browser/preloading/preloading_confidence.h"
|
||||
#include "content/browser/preloading/preloading_config.h"
|
||||
@ -19,6 +19,7 @@
|
||||
#include "content/browser/preloading/speculation_rules/speculation_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
||||
#include "content/browser/site_instance_impl.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "content/public/test/preloading_test_util.h"
|
||||
@ -202,9 +203,8 @@ class PrerenderHostRegistryTest : public RenderViewHostImplTestHarness {
|
||||
/*should_prepare_paint_tree=*/false,
|
||||
/*url_match_predicate=*/{},
|
||||
/*prerender_navigation_handle_callback=*/{},
|
||||
base::MakeRefCounted<
|
||||
PreloadPipelineInfo>(/*planned_max_preloading_type=*/
|
||||
PreloadingType::kPrerender));
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender));
|
||||
case PreloadingTriggerType::kEmbedder:
|
||||
return PrerenderAttributes(
|
||||
url, trigger_type, embedder_histogram_suffix,
|
||||
@ -218,9 +218,8 @@ class PrerenderHostRegistryTest : public RenderViewHostImplTestHarness {
|
||||
/*should_prepare_paint_tree=*/false,
|
||||
/*url_match_predicate=*/{},
|
||||
/*prerender_navigation_handle_callback=*/{},
|
||||
base::MakeRefCounted<
|
||||
PreloadPipelineInfo>(/*planned_max_preloading_type=*/
|
||||
PreloadingType::kPrerender));
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/ukm/test_ukm_recorder.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info_impl.h"
|
||||
#include "content/browser/preloading/preloading.h"
|
||||
#include "content/browser/preloading/prerender/prerender_attributes.h"
|
||||
#include "content/browser/preloading/prerender/prerender_features.h"
|
||||
@ -21,6 +21,7 @@
|
||||
#include "content/browser/preloading/prerender/prerender_host.h"
|
||||
#include "content/browser/preloading/prerender/prerender_host_registry.h"
|
||||
#include "content/browser/preloading/prerender/prerender_metrics.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
#include "content/public/browser/preloading_data.h"
|
||||
#include "content/public/test/mock_web_contents_observer.h"
|
||||
@ -291,7 +292,7 @@ class PrerenderHostTest : public RenderViewHostImplTestHarness {
|
||||
/*should_warm_up_compositor=*/false,
|
||||
/*should_prepare_paint_tree=*/false, std::move(url_match_predicate),
|
||||
/*prerender_navigation_handle_callback=*/{},
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender));
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ bool PrerendererImpl::MaybePrerender(
|
||||
/*should_prepare_paint_tree=*/false,
|
||||
/*url_match_predicate=*/{},
|
||||
/*prerender_navigation_handle_callback=*/{},
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender));
|
||||
|
||||
PreloadingTriggerType trigger_type =
|
||||
|
@ -92,7 +92,6 @@
|
||||
#include "content/browser/permissions/permission_controller_impl.h"
|
||||
#include "content/browser/permissions/permission_util.h"
|
||||
#include "content/browser/preloading/prefetch/prefetch_service.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/preloading.h"
|
||||
#include "content/browser/preloading/prerender/prerender_final_status.h"
|
||||
#include "content/browser/preloading/prerender/prerender_host_registry.h"
|
||||
@ -154,6 +153,7 @@
|
||||
#include "content/public/browser/javascript_dialog_manager.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/navigation_details.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/browser/preview_cancel_reason.h"
|
||||
#include "content/public/browser/render_widget_host_iterator.h"
|
||||
#include "content/public/browser/render_widget_host_observer.h"
|
||||
@ -11723,7 +11723,7 @@ std::unique_ptr<PrerenderHandle> WebContentsImpl::StartPrerendering(
|
||||
should_warm_up_compositor, should_prepare_paint_tree,
|
||||
std::move(url_match_predicate),
|
||||
std::move(prerender_navigation_handle_callback),
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender));
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
attributes.additional_headers = std::move(additional_headers);
|
||||
|
@ -331,6 +331,7 @@ source_set("browser_sources") {
|
||||
"prefetch_request_status_listener.h",
|
||||
"prefetch_service_delegate.cc",
|
||||
"prefetch_service_delegate.h",
|
||||
"preload_pipeline_info.h",
|
||||
"preloading.h",
|
||||
"preloading_data.h",
|
||||
"preloading_trigger_type.h",
|
||||
|
55
content/public/browser/preload_pipeline_info.h
Normal file
55
content/public/browser/preload_pipeline_info.h
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_PUBLIC_BROWSER_PRELOAD_PIPELINE_INFO_H_
|
||||
#define CONTENT_PUBLIC_BROWSER_PRELOAD_PIPELINE_INFO_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "content/public/browser/preloading.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
// Holds immutable/mutable attributes of a preload pipeline.
|
||||
//
|
||||
// The information are used for, e.g. CDP and failure propagation.
|
||||
//
|
||||
// Each prefetch and prerender belongs to a pipeline.
|
||||
//
|
||||
// Ownership: Only the followings are allowed to own this:
|
||||
//
|
||||
// - Pipelines triggering associated preloads
|
||||
// - `PrefetchContainer`
|
||||
// - `PerrenderAttributes`, which is owned by `PrerenderHost`.
|
||||
// - (Exception: Paths transferring it to start preloads.)
|
||||
//
|
||||
// Note that this can be moved from a `PrefetchContainer` to another
|
||||
// `PrefetchContainer`. See `PrefetchContainer::MigrateNewlyAdded()`.
|
||||
class CONTENT_EXPORT PreloadPipelineInfo
|
||||
: public base::RefCounted<PreloadPipelineInfo> {
|
||||
public:
|
||||
// Creates `PreloadPipelineInfo`.
|
||||
//
|
||||
// `planned_max_preloading_type` is used to determine appropriate HTTP header
|
||||
// value `Sec-Purpose`. A caller must designate max preloading type that it
|
||||
// can trigger with this pipeline. That said, it is possible that other
|
||||
// triggers can use already triggered preloads.
|
||||
//
|
||||
// For example, if a pipeline is triggering prerender, it must create
|
||||
// `PreloadingPipelineInfo` with `kPrerender`, and then trigger prefetch and
|
||||
// prerender with this.
|
||||
//
|
||||
// Currently, only this type of pipeline is allowed: kPrefetch -> kPrerender.
|
||||
static scoped_refptr<PreloadPipelineInfo> Create(
|
||||
PreloadingType planned_max_preloading_type);
|
||||
|
||||
protected:
|
||||
friend class base::RefCounted<PreloadPipelineInfo>;
|
||||
|
||||
virtual ~PreloadPipelineInfo() = default;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_PUBLIC_BROWSER_PRELOAD_PIPELINE_INFO_H_
|
@ -11,7 +11,6 @@
|
||||
#include "base/no_destructor.h"
|
||||
#include "content/browser/browser_url_handler_impl.h"
|
||||
#include "content/browser/display_cutout/display_cutout_host_impl.h"
|
||||
#include "content/browser/preloading/preload_pipeline_info.h"
|
||||
#include "content/browser/preloading/prerender/prerender_host.h"
|
||||
#include "content/browser/preloading/prerender/prerender_host_registry.h"
|
||||
#include "content/browser/renderer_host/cross_process_frame_connector.h"
|
||||
@ -24,6 +23,7 @@
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/site_instance_impl.h"
|
||||
#include "content/common/render_message_filter.mojom.h"
|
||||
#include "content/public/browser/preload_pipeline_info.h"
|
||||
#include "content/public/common/referrer_type_converters.h"
|
||||
#include "content/public/common/url_utils.h"
|
||||
#include "content/public/test/mock_render_process_host.h"
|
||||
@ -496,7 +496,7 @@ FrameTreeNodeId TestWebContents::AddPrerender(const GURL& url) {
|
||||
/*should_prepare_paint_tree=*/false,
|
||||
/*url_match_predicate=*/{},
|
||||
/*prerender_navigation_handle_callback=*/{},
|
||||
base::MakeRefCounted<PreloadPipelineInfo>(
|
||||
PreloadPipelineInfoImpl::Create(
|
||||
/*planned_max_preloading_type=*/PreloadingType::kPrerender)));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user