OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
| 6 #define NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "net/interfaces/host_resolver_service.mojom.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 class HostResolver; |
| 17 |
| 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 { |
| 24 public: |
| 25 // |resolver| is expected to outlive |this|. |
| 26 explicit MojoHostResolverImpl(net::HostResolver* resolver); |
| 27 ~MojoHostResolverImpl() override; |
| 28 |
| 29 private: |
| 30 class Job; |
| 31 |
| 32 // Removes |job| from the set of pending jobs, and deletes it. |
| 33 void DeleteJob(Job* job); |
| 34 |
| 35 // Overridden from net::interfaces::HostResolver: |
| 36 void Resolve(interfaces::HostResolverRequestInfoPtr request_info, |
| 37 interfaces::HostResolverRequestClientPtr client) override; |
| 38 |
| 39 // Resolver for resolving incoming requests. Not owned. |
| 40 net::HostResolver* resolver_; |
| 41 |
| 42 // All pending jobs, so they can be cancelled when this service is destroyed. |
| 43 // Owns all jobs. |
| 44 std::set<Job*> pending_jobs_; |
| 45 |
| 46 base::ThreadChecker thread_checker_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(MojoHostResolverImpl); |
| 49 }; |
| 50 |
| 51 } // namespace net |
| 52 |
| 53 #endif // NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |