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_MOJO_HOST_RESOLVER_IMPL_H_
6 #define NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_
10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h"
12 #include "net/interfaces/host_resolver_service.mojom.h"
13 #include "net/log/net_log.h"
19 // MojoHostResolverImpl handles mojo host resolution requests. Inbound Mojo
20 // requests are sent to the HostResolver passed into the constructor. When
21 // destroyed, any outstanding resolver requests are cancelled. If a request's
22 // HostResolverRequestClient is shut down, the associated resolver request is
24 class MojoHostResolverImpl
{
26 // |resolver| is expected to outlive |this|.
27 MojoHostResolverImpl(net::HostResolver
* resolver
, const BoundNetLog
& net_log
);
28 ~MojoHostResolverImpl();
30 void Resolve(interfaces::HostResolverRequestInfoPtr request_info
,
31 interfaces::HostResolverRequestClientPtr client
);
33 bool request_in_progress() { return !pending_jobs_
.empty(); }
38 // Removes |job| from the set of pending jobs, and deletes it.
39 void DeleteJob(Job
* job
);
41 // Resolver for resolving incoming requests. Not owned.
42 net::HostResolver
* resolver_
;
44 // The BoundNetLog to be passed to |resolver_| for all requests.
45 const BoundNetLog net_log_
;
47 // All pending jobs, so they can be cancelled when this service is destroyed.
49 std::set
<Job
*> pending_jobs_
;
51 base::ThreadChecker thread_checker_
;
53 DISALLOW_COPY_AND_ASSIGN(MojoHostResolverImpl
);
58 #endif // NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_