1 // Copyright 2015 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.
5 #ifndef SERVICES_PROXY_RESOLVER_HOST_RESOLVER_MOJO_H_
6 #define SERVICES_PROXY_RESOLVER_HOST_RESOLVER_MOJO_H_
11 #include "base/memory/raw_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h"
14 #include "net/proxy_resolution/proxy_resolve_dns_operation.h"
15 #include "services/proxy_resolver/proxy_host_resolver.h"
16 #include "services/proxy_resolver/proxy_host_resolver_cache.h"
17 #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
20 class NetworkAnonymizationKey;
23 namespace proxy_resolver {
25 // A ProxyHostResolver implementation that converts requests to mojo types and
26 // forwards them to a mojo Impl interface.
27 class HostResolverMojo : public ProxyHostResolver {
31 virtual ~Impl() = default;
32 virtual void ResolveDns(
33 const std::string& hostname,
34 net::ProxyResolveDnsOperation operation,
35 const net::NetworkAnonymizationKey& network_anonymization_key,
36 mojo::PendingRemote<mojom::HostResolverRequestClient> client) = 0;
39 // |impl| must outlive |this|.
40 explicit HostResolverMojo(Impl* impl);
42 HostResolverMojo(const HostResolverMojo&) = delete;
43 HostResolverMojo& operator=(const HostResolverMojo&) = delete;
45 ~HostResolverMojo() override;
47 // ProxyHostResolver overrides.
48 std::unique_ptr<Request> CreateRequest(
49 const std::string& hostname,
50 net::ProxyResolveDnsOperation operation,
51 const net::NetworkAnonymizationKey& network_anonymization_key) override;
57 const raw_ptr<Impl> impl_;
59 ProxyHostResolverCache host_cache_;
60 base::WeakPtrFactory<ProxyHostResolverCache> host_cache_weak_factory_{
63 base::ThreadChecker thread_checker_;
66 } // namespace proxy_resolver
68 #endif // SERVICES_PROXY_RESOLVER_HOST_RESOLVER_MOJO_H_