Alex Yang | f8e231903 | 2025-01-14 00:28:51 | [diff] [blame] | 1 | // Copyright 2025 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_RENDERER_LOCAL_RESOURCE_URL_LOADER_FACTORY_H_ |
| 6 | #define CONTENT_RENDERER_LOCAL_RESOURCE_URL_LOADER_FACTORY_H_ |
| 7 | |
| 8 | #include <cstdint> |
| 9 | #include <memory> |
| 10 | |
| 11 | #include "base/memory/ref_counted.h" |
| 12 | #include "base/memory/scoped_refptr.h" |
| 13 | #include "base/task/sequenced_task_runner.h" |
| 14 | #include "base/threading/sequence_bound.h" |
| 15 | #include "content/common/content_export.h" |
| 16 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
| 17 | #include "mojo/public/cpp/bindings/pending_remote.h" |
| 18 | #include "mojo/public/cpp/bindings/receiver_set.h" |
| 19 | #include "mojo/public/cpp/bindings/remote.h" |
| 20 | #include "net/socket/socket.h" |
| 21 | #include "services/network/public/cpp/resource_request.h" |
| 22 | #include "services/network/public/mojom/url_loader.mojom.h" |
| 23 | #include "services/network/public/mojom/url_loader_factory.mojom.h" |
| 24 | #include "third_party/blink/public/mojom/loader/local_resource_loader_config.mojom.h" |
| 25 | #include "url/origin.h" |
| 26 | |
| 27 | namespace content { |
| 28 | |
| 29 | // LocalResourceURLLoaderFactory is a URLLoaderFactory that lives in the |
| 30 | // renderer process and fetches resources directly from the ResourceBundle, |
| 31 | // enabling renderers to load bundled resources entirely in-process. This can |
| 32 | // significantly reduce IPC overhead for WebUIs, whose resources come almost |
| 33 | // exclusively from the ResourceBundle. |
| 34 | class CONTENT_EXPORT LocalResourceURLLoaderFactory |
| 35 | : public network::mojom::URLLoaderFactory { |
| 36 | public: |
| 37 | struct Source { |
| 38 | Source(blink::mojom::LocalResourceSourcePtr source, |
Alex Yang | 690544aa3 | 2025-02-03 22:30:23 | [diff] [blame] | 39 | std::map<std::string, std::string> replacement_strings); |
Alex Yang | f8e231903 | 2025-01-14 00:28:51 | [diff] [blame] | 40 | Source(Source&& other); |
| 41 | Source& operator=(Source&& other); |
| 42 | ~Source(); |
| 43 | blink::mojom::LocalResourceSourcePtr source; |
Alex Yang | 690544aa3 | 2025-02-03 22:30:23 | [diff] [
|