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

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

Issue 7633036: Return DNS addresses when address can be resolved synchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/resource_context.h" 10 #include "content/browser/resource_context.h"
(...skipping 30 matching lines...) Expand all
41 done_callback_.Run(net::IPAddressNumber()); 41 done_callback_.Run(net::IPAddressNumber());
42 return; 42 return;
43 } 43 }
44 44
45 // Add period at the end to make sure that we only resolve 45 // Add period at the end to make sure that we only resolve
46 // fully-qualified names. 46 // fully-qualified names.
47 if (host_name_.at(host_name_.size() - 1) != '.') 47 if (host_name_.at(host_name_.size() - 1) != '.')
48 host_name_ = host_name_ + '.'; 48 host_name_ = host_name_ + '.';
49 49
50 net::HostResolver::RequestInfo info(net::HostPortPair(host_name_, 0)); 50 net::HostResolver::RequestInfo info(net::HostPortPair(host_name_, 0));
51 resolver_.Resolve(info, &addresses_, &completion_callback_, 51 int result = resolver_.Resolve(info, &addresses_, &completion_callback_,
52 net::BoundNetLog()); 52 net::BoundNetLog());
53 if (result != net::ERR_IO_PENDING)
54 OnDone(result);
53 } 55 }
54 56
55 int32 routing_id() { return routing_id_; } 57 int32 routing_id() { return routing_id_; }
56 int32 request_id() { return request_id_; } 58 int32 request_id() { return request_id_; }
57 59
58 private: 60 private:
59 void OnDone(int result) { 61 void OnDone(int result) {
60 if (result != net::OK) { 62 if (result != net::OK) {
61 LOG(ERROR) << "Failed to resolve address for " << host_name_ 63 LOG(ERROR) << "Failed to resolve address for " << host_name_
62 << ", errorcode: " << result; 64 << ", errorcode: " << result;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 it != notifications_routing_ids_.end(); ++it) { 194 it != notifications_routing_ids_.end(); ++it) {
193 Send(new P2PMsg_NetworkListChanged(*it, list)); 195 Send(new P2PMsg_NetworkListChanged(*it, list));
194 } 196 }
195 } 197 }
196 198
197 void P2PSocketDispatcherHost::OnGetHostAddress(const IPC::Message& msg, 199 void P2PSocketDispatcherHost::OnGetHostAddress(const IPC::Message& msg,
198 const std::string& host_name, 200 const std::string& host_name,
199 int32 request_id) { 201 int32 request_id) {
200 DnsRequest* request = new DnsRequest( 202 DnsRequest* request = new DnsRequest(
201 msg.routing_id(), request_id, resource_context_->host_resolver()); 203 msg.routing_id(), request_id, resource_context_->host_resolver());
204 dns_requests_.insert(request);
202 request->Resolve(host_name, base::Bind( 205 request->Resolve(host_name, base::Bind(
203 &P2PSocketDispatcherHost::OnAddressResolved, 206 &P2PSocketDispatcherHost::OnAddressResolved,
204 base::Unretained(this), request)); 207 base::Unretained(this), request));
205 dns_requests_.insert(request);
206 } 208 }
207 209
208 void P2PSocketDispatcherHost::OnAddressResolved( 210 void P2PSocketDispatcherHost::OnAddressResolved(
209 DnsRequest* request, 211 DnsRequest* request,
210 const net::IPAddressNumber& result) { 212 const net::IPAddressNumber& result) {
211 Send(new P2PMsg_GetHostAddressResult( 213 Send(new P2PMsg_GetHostAddressResult(
212 request->routing_id(), request->request_id(), result)); 214 request->routing_id(), request->request_id(), result));
213 215
214 dns_requests_.erase(request); 216 dns_requests_.erase(request);
215 delete request; 217 delete request;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 int socket_id) { 274 int socket_id) {
273 SocketsMap::iterator it = sockets_.find( 275 SocketsMap::iterator it = sockets_.find(
274 ExtendedSocketId(msg.routing_id(), socket_id)); 276 ExtendedSocketId(msg.routing_id(), socket_id));
275 if (it != sockets_.end()) { 277 if (it != sockets_.end()) {
276 delete it->second; 278 delete it->second;
277 sockets_.erase(it); 279 sockets_.erase(it);
278 } else { 280 } else {
279 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id."; 281 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id.";
280 } 282 }
281 } 283 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698