1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_DNS_HOST_RESOLVER_MOJO_H_
6 #define NET_DNS_HOST_RESOLVER_MOJO_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/threading/thread_checker.h"
10 #include "net/dns/host_cache.h"
11 #include "net/dns/host_resolver.h"
12 #include "net/interfaces/host_resolver_service.mojom.h"
18 // A HostResolver implementation that converts requests to mojo types and
19 // forwards them to a mojo Impl interface.
20 class HostResolverMojo
: public HostResolver
{
24 virtual ~Impl() = default;
25 virtual void ResolveDns(interfaces::HostResolverRequestInfoPtr
,
26 interfaces::HostResolverRequestClientPtr
) = 0;
29 // |impl| must outlive |this|.
30 explicit HostResolverMojo(Impl
* impl
);
31 ~HostResolverMojo() override
;
33 // HostResolver overrides.
34 int Resolve(const RequestInfo
& info
,
35 RequestPriority priority
,
36 AddressList
* addresses
,
37 const CompletionCallback
& callback
,
38 RequestHandle
* request_handle
,
39 const BoundNetLog
& source_net_log
) override
;
40 int ResolveFromCache(const RequestInfo
& info
,
41 AddressList
* addresses
,
42 const BoundNetLog
& source_net_log
) override
;
43 void CancelRequest(RequestHandle req
) override
;
44 HostCache
* GetHostCache() override
;
49 int ResolveFromCacheInternal(const RequestInfo
& info
,
50 const HostCache::Key
& key
,
51 AddressList
* addresses
);
55 scoped_ptr
<HostCache
> host_cache_
;
56 base::WeakPtrFactory
<HostCache
> host_cache_weak_factory_
;
58 base::ThreadChecker thread_checker_
;
60 DISALLOW_COPY_AND_ASSIGN(HostResolverMojo
);
65 #endif // NET_DNS_HOST_RESOLVER_MOJO_H_