| 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 #include "net/dns/mojo_host_resolver_impl.h" | 5 #include "net/dns/mojo_host_resolver_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 void OnResolveDone(int result); | 34 void OnResolveDone(int result); |
| 35 | 35 |
| 36 // Mojo error handler. | 36 // Mojo error handler. |
| 37 void OnConnectionError(); | 37 void OnConnectionError(); |
| 38 | 38 |
| 39 MojoHostResolverImpl* resolver_service_; | 39 MojoHostResolverImpl* resolver_service_; |
| 40 net::HostResolver* resolver_; | 40 net::HostResolver* resolver_; |
| 41 net::HostResolver::RequestInfo request_info_; | 41 net::HostResolver::RequestInfo request_info_; |
| 42 const BoundNetLog net_log_; | 42 const BoundNetLog net_log_; |
| 43 interfaces::HostResolverRequestClientPtr client_; | 43 interfaces::HostResolverRequestClientPtr client_; |
| 44 net::HostResolver::RequestHandle handle_; | 44 std::unique_ptr<net::HostResolver::Request> handle_; |
| 45 AddressList result_; | 45 AddressList result_; |
| 46 base::ThreadChecker thread_checker_; | 46 base::ThreadChecker thread_checker_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 MojoHostResolverImpl::MojoHostResolverImpl(net::HostResolver* resolver, | 49 MojoHostResolverImpl::MojoHostResolverImpl(net::HostResolver* resolver, |
| 50 const BoundNetLog& net_log) | 50 const BoundNetLog& net_log) |
| 51 : resolver_(resolver), net_log_(net_log) { | 51 : resolver_(resolver), net_log_(net_log) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 MojoHostResolverImpl::~MojoHostResolverImpl() { | 54 MojoHostResolverImpl::~MojoHostResolverImpl() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 base::Unretained(this)), | 105 base::Unretained(this)), |
| 106 &handle_, net_log_); | 106 &handle_, net_log_); |
| 107 | 107 |
| 108 if (result != ERR_IO_PENDING) | 108 if (result != ERR_IO_PENDING) |
| 109 OnResolveDone(result); | 109 OnResolveDone(result); |
| 110 } | 110 } |
| 111 | 111 |
| 112 MojoHostResolverImpl::Job::~Job() { | 112 MojoHostResolverImpl::Job::~Job() { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | 113 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 if (handle_) | 114 if (handle_) |
| 115 resolver_->CancelRequest(handle_); | 115 handle_.reset(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void MojoHostResolverImpl::Job::OnResolveDone(int result) { | 118 void MojoHostResolverImpl::Job::OnResolveDone(int result) { |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | 119 DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 handle_ = nullptr; | 120 handle_ = nullptr; |
| 121 DVLOG(1) << "Resolved " << request_info_.host_port_pair().ToString() | 121 DVLOG(1) << "Resolved " << request_info_.host_port_pair().ToString() |
| 122 << " with error " << result << " and " << result_.size() | 122 << " with error " << result << " and " << result_.size() |
| 123 << " results!"; | 123 << " results!"; |
| 124 for (const auto& address : result_) { | 124 for (const auto& address : result_) { |
| 125 DVLOG(1) << address.ToString(); | 125 DVLOG(1) << address.ToString(); |
| 126 } | 126 } |
| 127 if (result == OK) | 127 if (result == OK) |
| 128 client_->ReportResult(result, interfaces::AddressList::From(result_)); | 128 client_->ReportResult(result, interfaces::AddressList::From(result_)); |
| 129 else | 129 else |
| 130 client_->ReportResult(result, nullptr); | 130 client_->ReportResult(result, nullptr); |
| 131 | 131 |
| 132 resolver_service_->DeleteJob(this); | 132 resolver_service_->DeleteJob(this); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void MojoHostResolverImpl::Job::OnConnectionError() { | 135 void MojoHostResolverImpl::Job::OnConnectionError() { |
| 136 DCHECK(thread_checker_.CalledOnValidThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
| 137 // |resolver_service_| should always outlive us. | 137 // |resolver_service_| should always outlive us. |
| 138 DCHECK(resolver_service_); | 138 DCHECK(resolver_service_); |
| 139 DVLOG(1) << "Connection error on request for " | 139 DVLOG(1) << "Connection error on request for " |
| 140 << request_info_.host_port_pair().ToString(); | 140 << request_info_.host_port_pair().ToString(); |
| 141 resolver_service_->DeleteJob(this); | 141 resolver_service_->DeleteJob(this); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace net | 144 } // namespace net |
| OLD | NEW |