ipfs-chromium
dns_txt_request.h
1 #ifndef IPFS_DNS_TXT_REQUEST_H_
2 #define IPFS_DNS_TXT_REQUEST_H_
3 
4 #include "virtual_optional.h"
5 
6 #include <ipfs_client/client.h>
7 
8 #include <mojo/public/cpp/bindings/receiver.h>
9 #include <services/network/public/cpp/resolve_host_client_base.h>
10 
11 namespace network::mojom {
12 class NetworkContext;
13 }
14 
15 namespace ipfs {
16 class DnsTxtRequest final : public network::ResolveHostClientBase {
17  public:
18  using DnsTextResultsCallback = ctx::DnsTxtLookup::DnsTextResultsCallback;
19  using DnsTextCompleteCallback = ctx::DnsTxtLookup::DnsTextCompleteCallback;
20 
21  private:
22  DnsTextResultsCallback results_callback_;
23  DnsTextCompleteCallback completion_callback_;
24  mojo::Receiver<network::mojom::ResolveHostClient> recv_{this};
25 
26  using Endpoints = std::vector<::net::HostResolverEndpointResult>;
27  void OnTextResults(std::vector<std::string> const&) override;
28  void OnComplete(int32_t result,
29  ::net::ResolveErrorInfo const&,
30  VirtualOptional<::net::AddressList> const&,
31  VirtualOptional<Endpoints> const&) override;
32 
33  public:
34  DnsTxtRequest(std::string,
35  DnsTextResultsCallback,
36  DnsTextCompleteCallback,
37  network::mojom::NetworkContext*);
38  DnsTxtRequest(DnsTxtRequest&&) = delete;
39  ~DnsTxtRequest() noexcept override;
40 };
41 } // namespace ipfs
42 
43 #endif // IPFS_DNS_TXT_REQUEST_H_
Definition: dns_txt_request.h:16