| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/p2p/socket_dispatcher_host.h" | 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/browser/renderer_host/p2p/socket_host.h" | 9 #include "content/browser/renderer_host/p2p/socket_host.h" |
| 10 #include "content/public/browser/resource_context.h" | 10 #include "content/public/browser/resource_context.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 void OnDone(int result) { | 67 void OnDone(int result) { |
| 68 if (result != net::OK) { | 68 if (result != net::OK) { |
| 69 LOG(ERROR) << "Failed to resolve address for " << host_name_ | 69 LOG(ERROR) << "Failed to resolve address for " << host_name_ |
| 70 << ", errorcode: " << result; | 70 << ", errorcode: " << result; |
| 71 done_callback_.Run(net::IPAddressNumber()); | 71 done_callback_.Run(net::IPAddressNumber()); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (addresses_.head() == NULL) { | 75 // TODO(szym): Redundant check. http://crbug.com/126211 |
| 76 if (addresses_.empty()) { |
| 76 LOG(ERROR) << "Received 0 addresses when trying to resolve address for " | 77 LOG(ERROR) << "Received 0 addresses when trying to resolve address for " |
| 77 << host_name_; | 78 << host_name_; |
| 78 done_callback_.Run(net::IPAddressNumber()); | 79 done_callback_.Run(net::IPAddressNumber()); |
| 79 return; | 80 return; |
| 80 } | 81 } |
| 81 | 82 |
| 82 net::IPEndPoint end_point; | 83 done_callback_.Run(addresses_.front().address()); |
| 83 if (!end_point.FromSockAddr(addresses_.head()->ai_addr, | |
| 84 addresses_.head()->ai_addrlen)) { | |
| 85 LOG(ERROR) << "Received invalid address for " << host_name_; | |
| 86 done_callback_.Run(net::IPAddressNumber()); | |
| 87 return; | |
| 88 } | |
| 89 | |
| 90 done_callback_.Run(end_point.address()); | |
| 91 } | 84 } |
| 92 | 85 |
| 93 int32 routing_id_; | 86 int32 routing_id_; |
| 94 int32 request_id_; | 87 int32 request_id_; |
| 95 net::AddressList addresses_; | 88 net::AddressList addresses_; |
| 96 | 89 |
| 97 std::string host_name_; | 90 std::string host_name_; |
| 98 net::SingleRequestHostResolver resolver_; | 91 net::SingleRequestHostResolver resolver_; |
| 99 | 92 |
| 100 DoneCallback done_callback_; | 93 DoneCallback done_callback_; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 DnsRequest* request, | 273 DnsRequest* request, |
| 281 const net::IPAddressNumber& result) { | 274 const net::IPAddressNumber& result) { |
| 282 Send(new P2PMsg_GetHostAddressResult( | 275 Send(new P2PMsg_GetHostAddressResult( |
| 283 request->routing_id(), request->request_id(), result)); | 276 request->routing_id(), request->request_id(), result)); |
| 284 | 277 |
| 285 dns_requests_.erase(request); | 278 dns_requests_.erase(request); |
| 286 delete request; | 279 delete request; |
| 287 } | 280 } |
| 288 | 281 |
| 289 } // namespace content | 282 } // namespace content |
| OLD | NEW |