Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_EXPORT to *PortOnAddressList. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 if (addresses_.empty()) {
eroman 2012/05/04 01:08:41 Yuck. I am surprised to keep seeing these checks.
76 LOG(ERROR) << "Received 0 addresses when trying to resolve address for " 76 LOG(ERROR) << "Received 0 addresses when trying to resolve address for "
77 << host_name_; 77 << host_name_;
78 done_callback_.Run(net::IPAddressNumber()); 78 done_callback_.Run(net::IPAddressNumber());
79 return; 79 return;
80 } 80 }
81 81
82 net::IPEndPoint end_point; 82 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 } 83 }
92 84
93 int32 routing_id_; 85 int32 routing_id_;
94 int32 request_id_; 86 int32 request_id_;
95 net::AddressList addresses_; 87 net::AddressList addresses_;
96 88
97 std::string host_name_; 89 std::string host_name_;
98 net::SingleRequestHostResolver resolver_; 90 net::SingleRequestHostResolver resolver_;
99 91
100 DoneCallback done_callback_; 92 DoneCallback done_callback_;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DnsRequest* request, 272 DnsRequest* request,
281 const net::IPAddressNumber& result) { 273 const net::IPAddressNumber& result) {
282 Send(new P2PMsg_GetHostAddressResult( 274 Send(new P2PMsg_GetHostAddressResult(
283 request->routing_id(), request->request_id(), result)); 275 request->routing_id(), request->request_id(), result));
284 276
285 dns_requests_.erase(request); 277 dns_requests_.erase(request);
286 delete request; 278 delete request;
287 } 279 }
288 280
289 } // namespace content 281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698