Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 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_LOADER_CACHED_NAVIGATION_URL_LOADER_H_ |
| 6 | #define CONTENT_BROWSER_LOADER_CACHED_NAVIGATION_URL_LOADER_H_ |
| 7 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 8 | #include "base/memory/raw_ptr.h" |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 9 | #include "content/browser/loader/navigation_url_loader.h" |
| 10 | |
| 11 | namespace content { |
| 12 | |
Hiroki Nakagawa | 5034e196 | 2020-11-12 09:11:30 | [diff] [blame] | 13 | // 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 Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 18 | class CachedNavigationURLLoader : public NavigationURLLoader { |
| 19 | public: |
Takashi Toyoshima | 2e8d6101 | 2021-06-07 10:31:27 | [diff] [blame] | 20 | CachedNavigationURLLoader( |
Hiroki Nakagawa | 6c5f39bd | 2021-07-13 00:22:36 | [diff] [blame] | 21 | LoaderType loader_type, |
Takashi Toyoshima | 2e8d6101 | 2021-06-07 10:31:27 | [diff] [blame] | 22 | std::unique_ptr<NavigationRequestInfo> request_info, |
| 23 | NavigationURLLoaderDelegate* delegate, |
| 24 | network::mojom::URLResponseHeadPtr cached_response_head); |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 25 | ~CachedNavigationURLLoader() override; |
| 26 | |
| 27 | static std::unique_ptr<NavigationURLLoader> Create( |
Hiroki Nakagawa | 6c5f39bd | 2021-07-13 00:22:36 | [diff] [blame] | 28 | LoaderType loader_type, |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 29 | std::unique_ptr<NavigationRequestInfo> request_info, |
Takashi Toyoshima | 2e8d6101 | 2021-06-07 10:31:27 | [diff] [blame] | 30 | NavigationURLLoaderDelegate* delegate, |
| 31 | network::mojom::URLResponseHeadPtr cached_response_head); |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 32 | |
| 33 | // NavigationURLLoader implementation. |
Hiroki Nakagawa | 6d377e4a | 2021-07-08 23:29:11 | [diff] [blame] | 34 | void Start() override; |
Takashi Toyoshima | eb2ba20c5 | 2020-04-27 16:34:58 | [diff] [blame] | 35 | void FollowRedirect( |
Hiroshige Hayashizaki | 62ef608 | 2025-07-30 00:59:38 | [diff] [blame] | 36 | std::vector<std::string> removed_headers, |
| 37 | net::HttpRequestHeaders modified_headers, |
| 38 | net::HttpRequestHeaders modified_cors_exempt_headers) override; |
Chris Thompson | 066eed2 | 2021-10-07 20:20:43 | [diff] [blame] | 39 | bool SetNavigationTimeout(base::TimeDelta timeout) override; |
Mustafa Acer | 7b99ac2 | 2024-07-23 14:57:28 | [diff] [blame] | 40 | void CancelNavigationTimeout() override; |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | void OnResponseStarted(); |
Hiroki Nakagawa | 6c5f39bd | 2021-07-13 00:22:36 | [diff] [blame] | 44 | |
| 45 | const LoaderType loader_type_; |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 46 | std::unique_ptr<NavigationRequestInfo> request_info_; |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 47 | raw_ptr<NavigationURLLoaderDelegate> delegate_; |
Takashi Toyoshima | 2e8d6101 | 2021-06-07 10:31:27 | [diff] [blame] | 48 | network::mojom::URLResponseHeadPtr cached_response_head_; |
Jeremy Roman | 2b7c950 | 2019-08-21 22:34:08 | [diff] [blame] | 49 | base::WeakPtrFactory<CachedNavigationURLLoader> weak_factory_{this}; |
Lowell Manners | 0c04d63 | 2019-08-05 10:52:02 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace content |
| 53 | |
| 54 | #endif // CONTENT_BROWSER_LOADER_CACHED_NAVIGATION_URL_LOADER_H_ |