blob: eb69d199abd0235cc0b37873ba4f6a6d593f38d3 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2019 The Chromium Authors
Lowell Manners0c04d632019-08-05 10:52:022// 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_LOADER_CACHED_NAVIGATION_URL_LOADER_H_
6#define CONTENT_BROWSER_LOADER_CACHED_NAVIGATION_URL_LOADER_H_
7
Keishi Hattori0e45c022021-11-27 09:25:528#include "base/memory/raw_ptr.h"
Lowell Manners0c04d632019-08-05 10:52:029#include "content/browser/loader/navigation_url_loader.h"
10
11namespace content {
12
Hiroki Nakagawa5034e1962020-11-12 09:11:3013// NavigationURLLoader for navigations that activate a back-forward cached or
14// prerendered page. Unlike a normal navigation, no actual URL loading occurs.
15// This is because loading already happened the first time this URL was
16// navigated to (before it was added to the back-forward cache or when it was
17// prerendered).
Lowell Manners0c04d632019-08-05 10:52:0218class CachedNavigationURLLoader : public NavigationURLLoader {
19 public:
Takashi Toyoshima2e8d61012021-06-07 10:31:2720 CachedNavigationURLLoader(
Hiroki Nakagawa6c5f39bd2021-07-13 00:22:3621 LoaderType loader_type,
Takashi Toyoshima2e8d61012021-06-07 10:31:2722 std::unique_ptr<NavigationRequestInfo> request_info,
23 NavigationURLLoaderDelegate* delegate,
24 network::mojom::URLResponseHeadPtr cached_response_head);
Lowell Manners0c04d632019-08-05 10:52:0225 ~CachedNavigationURLLoader() override;
26
27 static std::unique_ptr<NavigationURLLoader> Create(
Hiroki Nakagawa6c5f39bd2021-07-13 00:22:3628 LoaderType loader_type,
Lowell Manners0c04d632019-08-05 10:52:0229 std::unique_ptr<NavigationRequestInfo> request_info,
Takashi Toyoshima2e8d61012021-06-07 10:31:2730 NavigationURLLoaderDelegate* delegate,
31 network::mojom::URLResponseHeadPtr cached_response_head);
Lowell Manners0c04d632019-08-05 10:52:0232
33 // NavigationURLLoader implementation.
Hiroki Nakagawa6d377e4a2021-07-08 23:29:1134 void Start() override;
Takashi Toyoshimaeb2ba20c52020-04-27 16:34:5835 void FollowRedirect(
Hiroshige Hayashizaki62ef6082025-07-30 00:59:3836 std::vector<std::string> removed_headers,
37 net::HttpRequestHeaders modified_headers,
38 net::HttpRequestHeaders modified_cors_exempt_headers) override;
Chris Thompson066eed22021-10-07 20:20:4339 bool SetNavigationTimeout(base::TimeDelta timeout) override;
Mustafa Acer7b99ac22024-07-23 14:57:2840 void CancelNavigationTimeout() override;
Lowell Manners0c04d632019-08-05 10:52:0241
42 private:
43 void OnResponseStarted();
Hiroki Nakagawa6c5f39bd2021-07-13 00:22:3644
45 const LoaderType loader_type_;
Lowell Manners0c04d632019-08-05 10:52:0246 std::unique_ptr<NavigationRequestInfo> request_info_;
Keishi Hattori0e45c022021-11-27 09:25:5247 raw_ptr<NavigationURLLoaderDelegate> delegate_;
Takashi Toyoshima2e8d61012021-06-07 10:31:2748 network::mojom::URLResponseHeadPtr cached_response_head_;
Jeremy Roman2b7c9502019-08-21 22:34:0849 base::WeakPtrFactory<CachedNavigationURLLoader> weak_factory_{this};
Lowell Manners0c04d632019-08-05 10:52:0250};
51
52} // namespace content
53
54#endif // CONTENT_BROWSER_LOADER_CACHED_NAVIGATION_URL_LOADER_H_