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

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

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing 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) 2011 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_host_tcp_server.h" 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" 10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
11 #include "content/common/p2p_messages.h" 11 #include "content/common/p2p_messages.h"
12 #include "net/base/address_list.h" 12 #include "net/base/address_list.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/base/sys_addrinfo.h"
16 #include "net/socket/stream_socket.h" 15 #include "net/socket/stream_socket.h"
17 16
18 namespace { 17 namespace {
19 const int kListenBacklog = 5; 18 const int kListenBacklog = 5;
20 } // namespace 19 } // namespace
21 20
22 namespace content { 21 namespace content {
23 22
24 P2PSocketHostTcpServer::P2PSocketHostTcpServer( 23 P2PSocketHostTcpServer::P2PSocketHostTcpServer(
25 IPC::Message::Sender* message_sender, 24 IPC::Message::Sender* message_sender,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 87 }
89 } 88 }
90 89
91 void P2PSocketHostTcpServer::HandleAcceptResult(int result) { 90 void P2PSocketHostTcpServer::HandleAcceptResult(int result) {
92 if (result < 0) { 91 if (result < 0) {
93 if (result != net::ERR_IO_PENDING) 92 if (result != net::ERR_IO_PENDING)
94 OnError(); 93 OnError();
95 return; 94 return;
96 } 95 }
97 96
98 net::IPEndPoint address;
99 net::AddressList addr_list; 97 net::AddressList addr_list;
100 if (accept_socket_->GetPeerAddress(&addr_list) != net::OK || 98 if (accept_socket_->GetPeerAddress(&addr_list) != net::OK) {
101 !address.FromSockAddr(addr_list.head()->ai_addr,
102 addr_list.head()->ai_addrlen)) {
103 LOG(ERROR) << "Failed to get address of an accepted socket."; 99 LOG(ERROR) << "Failed to get address of an accepted socket.";
104 accept_socket_.reset(); 100 accept_socket_.reset();
105 return; 101 return;
106 } 102 }
103 const net::IPEndPoint& address = addr_list.front();
107 AcceptedSocketsMap::iterator it = accepted_sockets_.find(address); 104 AcceptedSocketsMap::iterator it = accepted_sockets_.find(address);
108 if (it != accepted_sockets_.end()) { 105 if (it != accepted_sockets_.end())
109 delete it->second; 106 delete it->second;
110 } 107
111 accepted_sockets_[address] = accept_socket_.release(); 108 accepted_sockets_[address] = accept_socket_.release();
112 message_sender_->Send( 109 message_sender_->Send(
113 new P2PMsg_OnIncomingTcpConnection(routing_id_, id_, address)); 110 new P2PMsg_OnIncomingTcpConnection(routing_id_, id_, address));
114 } 111 }
115 112
116 void P2PSocketHostTcpServer::OnAccepted(int result) { 113 void P2PSocketHostTcpServer::OnAccepted(int result) {
117 HandleAcceptResult(result); 114 HandleAcceptResult(result);
118 if (result == net::OK) 115 if (result == net::OK)
119 DoAccept(); 116 DoAccept();
120 } 117 }
(...skipping 14 matching lines...) Expand all
135 accepted_sockets_.erase(it); 132 accepted_sockets_.erase(it);
136 scoped_ptr<P2PSocketHostTcp> result( 133 scoped_ptr<P2PSocketHostTcp> result(
137 new P2PSocketHostTcp(message_sender_, routing_id_, id)); 134 new P2PSocketHostTcp(message_sender_, routing_id_, id));
138 if (!result->InitAccepted(remote_address, socket)) 135 if (!result->InitAccepted(remote_address, socket))
139 return NULL; 136 return NULL;
140 137
141 return result.release(); 138 return result.release();
142 } 139 }
143 140
144 } // namespace content 141 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp.cc ('k') | content/browser/renderer_host/pepper_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698