| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ | 5 #ifndef NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
| 6 #define NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ | 6 #define NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "net/interfaces/host_resolver_service.mojom.h" | 12 #include "net/interfaces/host_resolver_service.mojom.h" |
| 13 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class HostResolver; | 17 class HostResolver; |
| 18 | 18 |
| 19 // MojoHostResolverImpl handles mojo host resolution requests. Inbound Mojo | 19 // MojoHostResolverImpl handles mojo host resolution requests. Inbound Mojo |
| 20 // requests are sent to the HostResolver passed into the constructor. When | 20 // requests are sent to the HostResolver passed into the constructor. When |
| 21 // destroyed, any outstanding resolver requests are cancelled. If a request's | 21 // destroyed, any outstanding resolver requests are cancelled. If a request's |
| 22 // HostResolverRequestClient is shut down, the associated resolver request is | 22 // HostResolverRequestClient is shut down, the associated resolver request is |
| 23 // cancelled. | 23 // cancelled. |
| 24 class MojoHostResolverImpl { | 24 class MojoHostResolverImpl { |
| 25 public: | 25 public: |
| 26 // |resolver| is expected to outlive |this|. | 26 // |resolver| is expected to outlive |this|. |
| 27 MojoHostResolverImpl(net::HostResolver* resolver, const BoundNetLog& net_log); | 27 MojoHostResolverImpl(net::HostResolver* resolver, const BoundNetLog& net_log); |
| 28 ~MojoHostResolverImpl(); | 28 ~MojoHostResolverImpl(); |
| 29 | 29 |
| 30 void Resolve(interfaces::HostResolverRequestInfoPtr request_info, | 30 void Resolve(std::unique_ptr<HostResolver::RequestInfo> request_info, |
| 31 interfaces::HostResolverRequestClientPtr client); | 31 interfaces::HostResolverRequestClientPtr client); |
| 32 | 32 |
| 33 bool request_in_progress() { return !pending_jobs_.empty(); } | 33 bool request_in_progress() { return !pending_jobs_.empty(); } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 class Job; | 36 class Job; |
| 37 | 37 |
| 38 // Removes |job| from the set of pending jobs, and deletes it. | 38 // Removes |job| from the set of pending jobs, and deletes it. |
| 39 void DeleteJob(Job* job); | 39 void DeleteJob(Job* job); |
| 40 | 40 |
| 41 // Resolver for resolving incoming requests. Not owned. | 41 // Resolver for resolving incoming requests. Not owned. |
| 42 net::HostResolver* resolver_; | 42 net::HostResolver* resolver_; |
| 43 | 43 |
| 44 // The BoundNetLog to be passed to |resolver_| for all requests. | 44 // The BoundNetLog to be passed to |resolver_| for all requests. |
| 45 const BoundNetLog net_log_; | 45 const BoundNetLog net_log_; |
| 46 | 46 |
| 47 // All pending jobs, so they can be cancelled when this service is destroyed. | 47 // All pending jobs, so they can be cancelled when this service is destroyed. |
| 48 // Owns all jobs. | 48 // Owns all jobs. |
| 49 std::set<Job*> pending_jobs_; | 49 std::set<Job*> pending_jobs_; |
| 50 | 50 |
| 51 base::ThreadChecker thread_checker_; | 51 base::ThreadChecker thread_checker_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(MojoHostResolverImpl); | 53 DISALLOW_COPY_AND_ASSIGN(MojoHostResolverImpl); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace net | 56 } // namespace net |
| 57 | 57 |
| 58 #endif // NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ | 58 #endif // NET_DNS_MOJO_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |