Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 1 | // 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 McNee | 842eb0a | 2024-04-11 20:14:16 | [diff] [blame] | 8 | #include "content/browser/preloading/preloading_confidence.h" |
Iman Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 9 | #include "content/common/content_export.h" |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 10 | #include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h" |
| 11 | |
| 12 | namespace content { |
| 13 | |
Iman Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 14 | // Interface for speculation-rules based prerenderer. |
| 15 | class Prerenderer { |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 16 | public: |
Taiyo Mizuhashi | 295ccbdf | 2023-09-13 09:17:02 | [diff] [blame] | 17 | using PrerenderCancellationCallback = |
| 18 | base::RepeatingCallback<void(const GURL&)>; |
| 19 | |
Iman Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 20 | virtual ~Prerenderer() = default; |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 21 | |
Iman Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 22 | virtual void ProcessCandidatesForPrerender( |
Yoichi Osato | 29233c2e | 2025-10-08 05:04:58 | [diff] [blame] | 23 | const std::vector<blink::mojom::SpeculationCandidatePtr>& candidates, |
| 24 | bool enable_cross_origin_prerender_iframes = false) = 0; |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 25 | |
Yoichi Osato | fed56ff8 | 2024-02-29 01:13:45 | [diff] [blame] | 26 | // 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 Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 31 | virtual bool MaybePrerender( |
Kevin McNee | 98e068a | 2024-04-09 20:12:34 | [diff] [blame] | 32 | const blink::mojom::SpeculationCandidatePtr& candidate, |
Kevin McNee | 842eb0a | 2024-04-11 20:14:16 | [diff] [blame] | 33 | const PreloadingPredictor& enacting_predictor, |
| 34 | PreloadingConfidence confidence) = 0; |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 35 | |
Iman Saboori | 31bed87 | 2022-12-09 15:41:31 | [diff] [blame] | 36 | virtual bool ShouldWaitForPrerenderResult(const GURL& url) = 0; |
Taiyo Mizuhashi | 295ccbdf | 2023-09-13 09:17:02 | [diff] [blame] | 37 | |
| 38 | virtual void SetPrerenderCancellationCallback( |
| 39 | PrerenderCancellationCallback callback) = 0; |
Iman Saboori | 03a661d | 2022-11-17 04:37:59 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | } // namespace content |
| 43 | |
Lingqi Chi | 47f6000 | 2022-12-13 05:29:08 | [diff] [blame] | 44 | #endif // CONTENT_BROWSER_PRELOADING_PRERENDERER_H_ |