| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket, | 252 void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket, |
| 253 rtc::AsyncPacketSocket* new_socket) { | 253 rtc::AsyncPacketSocket* new_socket) { |
| 254 ASSERT(socket == socket_); | 254 ASSERT(socket == socket_); |
| 255 | 255 |
| 256 Incoming incoming; | 256 Incoming incoming; |
| 257 incoming.addr = new_socket->GetRemoteAddress(); | 257 incoming.addr = new_socket->GetRemoteAddress(); |
| 258 incoming.socket = new_socket; | 258 incoming.socket = new_socket; |
| 259 incoming.socket->SignalReadPacket.connect(this, &TCPPort::OnReadPacket); | 259 incoming.socket->SignalReadPacket.connect(this, &TCPPort::OnReadPacket); |
| 260 incoming.socket->SignalReadyToSend.connect(this, &TCPPort::OnReadyToSend); | 260 incoming.socket->SignalReadyToSend.connect(this, &TCPPort::OnReadyToSend); |
| 261 incoming.socket->SignalSentPacket.connect(this, &TCPPort::OnSentPacket); | |
| 262 | 261 |
| 263 LOG_J(LS_VERBOSE, this) << "Accepted connection from " | 262 LOG_J(LS_VERBOSE, this) << "Accepted connection from " |
| 264 << incoming.addr.ToSensitiveString(); | 263 << incoming.addr.ToSensitiveString(); |
| 265 incoming_.push_back(incoming); | 264 incoming_.push_back(incoming); |
| 266 } | 265 } |
| 267 | 266 |
| 268 rtc::AsyncPacketSocket* TCPPort::GetIncoming( | 267 rtc::AsyncPacketSocket* TCPPort::GetIncoming( |
| 269 const rtc::SocketAddress& addr, bool remove) { | 268 const rtc::SocketAddress& addr, bool remove) { |
| 270 rtc::AsyncPacketSocket* socket = NULL; | 269 rtc::AsyncPacketSocket* socket = NULL; |
| 271 for (std::list<Incoming>::iterator it = incoming_.begin(); | 270 for (std::list<Incoming>::iterator it = incoming_.begin(); |
| 272 it != incoming_.end(); ++it) { | 271 it != incoming_.end(); ++it) { |
| 273 if (it->addr == addr) { | 272 if (it->addr == addr) { |
| 274 socket = it->socket; | 273 socket = it->socket; |
| 275 if (remove) | 274 if (remove) |
| 276 incoming_.erase(it); | 275 incoming_.erase(it); |
| 277 break; | 276 break; |
| 278 } | 277 } |
| 279 } | 278 } |
| 280 return socket; | 279 return socket; |
| 281 } | 280 } |
| 282 | 281 |
| 283 void TCPPort::OnReadPacket(rtc::AsyncPacketSocket* socket, | 282 void TCPPort::OnReadPacket(rtc::AsyncPacketSocket* socket, |
| 284 const char* data, size_t size, | 283 const char* data, size_t size, |
| 285 const rtc::SocketAddress& remote_addr, | 284 const rtc::SocketAddress& remote_addr, |
| 286 const rtc::PacketTime& packet_time) { | 285 const rtc::PacketTime& packet_time) { |
| 287 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); | 286 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); |
| 288 } | 287 } |
| 289 | 288 |
| 290 void TCPPort::OnSentPacket(rtc::AsyncPacketSocket* socket, | |
| 291 const rtc::SentPacket& sent_packet) { | |
| 292 ASSERT(socket == socket_); | |
| 293 PortInterface::SignalSentPacket(sent_packet); | |
| 294 } | |
| 295 | |
| 296 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { | 289 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { |
| 297 Port::OnReadyToSend(); | 290 Port::OnReadyToSend(); |
| 298 } | 291 } |
| 299 | 292 |
| 300 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, | 293 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, |
| 301 const rtc::SocketAddress& address) { | 294 const rtc::SocketAddress& address) { |
| 302 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", | 295 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", |
| 303 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, | 296 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, |
| 304 0, true); | 297 0, true); |
| 305 } | 298 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { | 499 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { |
| 507 if (outgoing_) { | 500 if (outgoing_) { |
| 508 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); | 501 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); |
| 509 } | 502 } |
| 510 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); | 503 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); |
| 511 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); | 504 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); |
| 512 socket->SignalClose.connect(this, &TCPConnection::OnClose); | 505 socket->SignalClose.connect(this, &TCPConnection::OnClose); |
| 513 } | 506 } |
| 514 | 507 |
| 515 } // namespace cricket | 508 } // namespace cricket |
| OLD | NEW |