| 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_host_tcp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
| 6 | 6 |
| 7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
| 8 #include "content/common/p2p_messages.h" | 8 #include "content/common/p2p_messages.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return state_ != STATE_ERROR; | 43 return state_ != STATE_ERROR; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool P2PSocketHostTcp::Init(const net::IPEndPoint& local_address, | 46 bool P2PSocketHostTcp::Init(const net::IPEndPoint& local_address, |
| 47 const net::IPEndPoint& remote_address) { | 47 const net::IPEndPoint& remote_address) { |
| 48 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 48 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| 49 | 49 |
| 50 remote_address_ = remote_address; | 50 remote_address_ = remote_address; |
| 51 state_ = STATE_CONNECTING; | 51 state_ = STATE_CONNECTING; |
| 52 scoped_ptr<net::TCPClientSocket> tcp_socket(new net::TCPClientSocket( | 52 scoped_ptr<net::TCPClientSocket> tcp_socket(new net::TCPClientSocket( |
| 53 net::AddressList::CreateFromIPAddress( | 53 net::AddressList(remote_address), |
| 54 remote_address.address(), remote_address.port()), | |
| 55 NULL, net::NetLog::Source())); | 54 NULL, net::NetLog::Source())); |
| 56 if (tcp_socket->Bind(local_address) != net::OK) { | 55 if (tcp_socket->Bind(local_address) != net::OK) { |
| 57 OnError(); | 56 OnError(); |
| 58 return false; | 57 return false; |
| 59 } | 58 } |
| 60 socket_.reset(tcp_socket.release()); | 59 socket_.reset(tcp_socket.release()); |
| 61 | 60 |
| 62 int result = socket_->Connect( | 61 int result = socket_->Connect( |
| 63 base::Bind(&P2PSocketHostTcp::OnConnected, base::Unretained(this))); | 62 base::Bind(&P2PSocketHostTcp::OnConnected, base::Unretained(this))); |
| 64 if (result != net::ERR_IO_PENDING) { | 63 if (result != net::ERR_IO_PENDING) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 268 } |
| 270 | 269 |
| 271 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( | 270 P2PSocketHost* P2PSocketHostTcp::AcceptIncomingTcpConnection( |
| 272 const net::IPEndPoint& remote_address, int id) { | 271 const net::IPEndPoint& remote_address, int id) { |
| 273 NOTREACHED(); | 272 NOTREACHED(); |
| 274 OnError(); | 273 OnError(); |
| 275 return NULL; | 274 return NULL; |
| 276 } | 275 } |
| 277 | 276 |
| 278 } // namespace content | 277 } // namespace content |
| OLD | NEW |