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"
18 // This is the implementation of the HostResolver Mojo interface.
19 // Inbound Mojo requests are sent to the HostResolver passed into the
20 // constructor. When destroyed, any outstanding resolver requests are cancelled.
21 // If a request's HostResolverRequestClient is shut down, the associated
22 // resolver request is cancelled.
23 class MojoHostResolverImpl
: public interfaces::HostResolver
{
25 // |resolver| is expected to outlive |this|.
26 explicit MojoHostResolverImpl(net::HostResolver
* resolver
);
27 ~MojoHostResolverImpl() override
;
32 // Removes |job| from the set of pending jobs, and deletes it.
33 void DeleteJob(Job
* job
);
35 // Overridden from net::interfaces::HostResolver:
36 void Resolve(interfaces::HostResolverRequestInfoPtr request_info
,
37 interfaces::HostResolverRequestClientPtr client
) override
;
39 // Resolver for resolving incoming requests. Not owned.
40 net::HostResolver
* resolver_
;
42 // All pending jobs, so they can be cancelled when this service is destroyed.
44 std::set
<Job
*> pending_jobs_
;
46 base::ThreadChecker thread_checker_
;
48 DISALLOW_COPY_AND_ASSIGN(MojoHostResolverImpl
);
53 #endif // NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_