blob: 4aa55755963c12981e4b167d61530486ebb3e339 [file] [log] [blame]
Iman Saboori03a661d2022-11-17 04:37:591// Copyright 2022 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_PRELOADING_PRERENDERER_H_
6#define CONTENT_BROWSER_PRELOADING_PRERENDERER_H_
7
Kevin McNee842eb0a2024-04-11 20:14:168#include "content/browser/preloading/preloading_confidence.h"
Iman Saboori31bed872022-12-09 15:41:319#include "content/common/content_export.h"
Iman Saboori03a661d2022-11-17 04:37:5910#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h"
11
12namespace content {
13
Iman Saboori31bed872022-12-09 15:41:3114// Interface for speculation-rules based prerenderer.
15class Prerenderer {
Iman Saboori03a661d2022-11-17 04:37:5916 public:
Taiyo Mizuhashi295ccbdf2023-09-13 09:17:0217 using PrerenderCancellationCallback =
18 base::RepeatingCallback<void(const GURL&)>;
19
Iman Saboori31bed872022-12-09 15:41:3120 virtual ~Prerenderer() = default;
Iman Saboori03a661d2022-11-17 04:37:5921
Iman Saboori31bed872022-12-09 15:41:3122 virtual void ProcessCandidatesForPrerender(
Yoichi Osato29233c2e2025-10-08 05:04:5823 const std::vector<blink::mojom::SpeculationCandidatePtr>& candidates,
24 bool enable_cross_origin_prerender_iframes = false) = 0;
Iman Saboori03a661d2022-11-17 04:37:5925
Yoichi Osatofed56ff82024-02-29 01:13:4526 // Called when LCP is predicted.
27 // This is used to defer starting prerenders until LCP timing and is only
28 // used under LCPTimingPredictorPrerender2.
29 virtual void OnLCPPredicted() = 0;
30
Iman Saboori31bed872022-12-09 15:41:3131 virtual bool MaybePrerender(
Kevin McNee98e068a2024-04-09 20:12:3432 const blink::mojom::SpeculationCandidatePtr& candidate,
Kevin McNee842eb0a2024-04-11 20:14:1633 const PreloadingPredictor& enacting_predictor,
34 PreloadingConfidence confidence) = 0;
Iman Saboori03a661d2022-11-17 04:37:5935
Iman Saboori31bed872022-12-09 15:41:3136 virtual bool ShouldWaitForPrerenderResult(const GURL& url) = 0;
Taiyo Mizuhashi295ccbdf2023-09-13 09:17:0237
38 virtual void SetPrerenderCancellationCallback(
39 PrerenderCancellationCallback callback) = 0;
Iman Saboori03a661d2022-11-17 04:37:5940};
41
42} // namespace content
43
Lingqi Chi47f60002022-12-13 05:29:0844#endif // CONTENT_BROWSER_PRELOADING_PRERENDERER_H_