1 #ifndef COMPONENTS_IPFS_URL_LOADER_H_
2 #define COMPONENTS_IPFS_URL_LOADER_H_ 1
4 #include "virtual_optional.h"
6 #include "base/debug/debugging_buildflags.h"
7 #include "base/timer/timer.h"
8 #include "mojo/public/cpp/bindings/receiver_set.h"
9 #include "mojo/public/cpp/system/data_pipe.h"
10 #include "net/http/http_request_headers.h"
11 #include "services/network/public/cpp/resolve_host_client_base.h"
12 #include "services/network/public/cpp/resource_request.h"
13 #include "services/network/public/mojom/url_loader.mojom.h"
25 namespace network::mojom {
26 class URLLoaderFactory;
31 class SimpleURLLoader;
35 class InterRequestState;
39 std::vector<std::string>
const& removed_headers,
40 net::HttpRequestHeaders
const& modified_headers,
41 net::HttpRequestHeaders
const& modified_cors_exempt_headers,
42 VirtualOptional<::GURL>
const& new_url)
override;
43 void SetPriority(net::RequestPriority priority,
44 int32_t intra_priority_value)
override;
45 void PauseReadingBodyFromNet()
override;
46 void ResumeReadingBodyFromNet()
override;
49 explicit IpfsUrlLoader(network::mojom::URLLoaderFactory& handles_http,
50 InterRequestState& state);
53 using ptr = std::shared_ptr<IpfsUrlLoader>;
57 static void StartRequest(
59 network::ResourceRequest
const& resource_request,
60 mojo::PendingReceiver<network::mojom::URLLoader> receiver,
61 mojo::PendingRemote<network::mojom::URLLoaderClient> client);
63 void OverrideUrl(GURL);
64 void AddHeader(std::string_view,std::string_view);
65 void extra(std::shared_ptr<network::mojom::URLLoader> xtra) { extra_ = xtra; }
68 using RequestHandle = std::unique_ptr<network::SimpleURLLoader>;
70 raw_ref<InterRequestState> state_;
71 mojo::Receiver<network::mojom::URLLoader> receiver_{
this};
72 mojo::Remote<network::mojom::URLLoaderClient> client_;
73 raw_ref<network::mojom::URLLoaderFactory> lower_loader_factory_;
74 mojo::ScopedDataPipeProducerHandle pipe_prod_ = {};
75 mojo::ScopedDataPipeConsumerHandle pipe_cons_ = {};
76 bool complete_ =
false;
77 std::shared_ptr<Client> api_;
78 std::string original_url_;
79 std::string partial_block_;
80 std::shared_ptr<network::mojom::URLLoader> extra_;
81 std::unique_ptr<base::RepeatingTimer> stepper_;
84 std::string resp_loc_;
85 std::shared_ptr<IpfsRequest> ipfs_request_;
87 void ReceiveBlockBytes(std::string_view);
89 void DoesNotExist(std::string_view cid, std::string_view path);
Definition: ipfs_url_loader.h:37