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

Side by Side Diff: webrtc/p2p/base/tcpport.cc

Issue 1803833002: Stop using some scoped_ptr features that unique_ptr doesn't have (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.cc ('k') | 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 /* 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // upper layer it's ready to send again as previous EWOULDLBLOCK from socket 375 // upper layer it's ready to send again as previous EWOULDLBLOCK from socket
376 // would have stopped the outgoing stream. 376 // would have stopped the outgoing stream.
377 if (pretending_to_be_writable_) { 377 if (pretending_to_be_writable_) {
378 Connection::OnReadyToSend(); 378 Connection::OnReadyToSend();
379 } 379 }
380 pretending_to_be_writable_ = false; 380 pretending_to_be_writable_ = false;
381 ASSERT(write_state() == STATE_WRITABLE); 381 ASSERT(write_state() == STATE_WRITABLE);
382 } 382 }
383 383
384 void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) { 384 void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
385 ASSERT(socket == socket_); 385 ASSERT(socket == socket_.get());
386 // Do not use this connection if the socket bound to a different address than 386 // Do not use this connection if the socket bound to a different address than
387 // the one we asked for. This is seen in Chrome, where TCP sockets cannot be 387 // the one we asked for. This is seen in Chrome, where TCP sockets cannot be
388 // given a binding address, and the platform is expected to pick the 388 // given a binding address, and the platform is expected to pick the
389 // correct local address. 389 // correct local address.
390 const rtc::IPAddress& socket_ip = socket->GetLocalAddress().ipaddr(); 390 const rtc::IPAddress& socket_ip = socket->GetLocalAddress().ipaddr();
391 if (socket_ip == port()->ip() || IPIsAny(port()->ip())) { 391 if (socket_ip == port()->ip() || IPIsAny(port()->ip())) {
392 if (socket_ip == port()->ip()) { 392 if (socket_ip == port()->ip()) {
393 LOG_J(LS_VERBOSE, this) << "Connection established to " 393 LOG_J(LS_VERBOSE, this) << "Connection established to "
394 << socket->GetRemoteAddress().ToSensitiveString(); 394 << socket->GetRemoteAddress().ToSensitiveString();
395 } else { 395 } else {
396 LOG(LS_WARNING) << "Socket is bound to a different address:" 396 LOG(LS_WARNING) << "Socket is bound to a different address:"
397 << socket->GetLocalAddress().ipaddr().ToString() 397 << socket->GetLocalAddress().ipaddr().ToString()
398 << ", rather then the local port:" 398 << ", rather then the local port:"
399 << port()->ip().ToString() 399 << port()->ip().ToString()
400 << ". Still allowing it since it's any address" 400 << ". Still allowing it since it's any address"
401 << ", possibly caused by multi-routes being disabled."; 401 << ", possibly caused by multi-routes being disabled.";
402 } 402 }
403 set_connected(true); 403 set_connected(true);
404 connection_pending_ = false; 404 connection_pending_ = false;
405 } else { 405 } else {
406 LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP " 406 LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP "
407 << socket_ip.ToSensitiveString() 407 << socket_ip.ToSensitiveString()
408 << ", different from the local candidate IP " 408 << ", different from the local candidate IP "
409 << port()->ip().ToSensitiveString(); 409 << port()->ip().ToSensitiveString();
410 OnClose(socket, 0); 410 OnClose(socket, 0);
411 } 411 }
412 } 412 }
413 413
414 void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { 414 void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
415 ASSERT(socket == socket_); 415 ASSERT(socket == socket_.get());
416 LOG_J(LS_INFO, this) << "Connection closed with error " << error; 416 LOG_J(LS_INFO, this) << "Connection closed with error " << error;
417 417
418 // Guard against the condition where IPC socket will call OnClose for every 418 // Guard against the condition where IPC socket will call OnClose for every
419 // packet it can't send. 419 // packet it can't send.
420 if (connected()) { 420 if (connected()) {
421 set_connected(false); 421 set_connected(false);
422 422
423 // Prevent the connection from being destroyed by redundant SignalClose 423 // Prevent the connection from being destroyed by redundant SignalClose
424 // events. 424 // events.
425 pretending_to_be_writable_ = true; 425 pretending_to_be_writable_ = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 << "trying to reconnect"; 464 << "trying to reconnect";
465 465
466 CreateOutgoingTcpSocket(); 466 CreateOutgoingTcpSocket();
467 error_ = EPIPE; 467 error_ = EPIPE;
468 } 468 }
469 469
470 void TCPConnection::OnReadPacket( 470 void TCPConnection::OnReadPacket(
471 rtc::AsyncPacketSocket* socket, const char* data, size_t size, 471 rtc::AsyncPacketSocket* socket, const char* data, size_t size,
472 const rtc::SocketAddress& remote_addr, 472 const rtc::SocketAddress& remote_addr,
473 const rtc::PacketTime& packet_time) { 473 const rtc::PacketTime& packet_time) {
474 ASSERT(socket == socket_); 474 ASSERT(socket == socket_.get());
475 Connection::OnReadPacket(data, size, packet_time); 475 Connection::OnReadPacket(data, size, packet_time);
476 } 476 }
477 477
478 void TCPConnection::OnReadyToSend(rtc::AsyncPacketSocket* socket) { 478 void TCPConnection::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
479 ASSERT(socket == socket_); 479 ASSERT(socket == socket_.get());
480 Connection::OnReadyToSend(); 480 Connection::OnReadyToSend();
481 } 481 }
482 482
483 void TCPConnection::CreateOutgoingTcpSocket() { 483 void TCPConnection::CreateOutgoingTcpSocket() {
484 ASSERT(outgoing_); 484 ASSERT(outgoing_);
485 // TODO(guoweis): Handle failures here (unlikely since TCP). 485 // TODO(guoweis): Handle failures here (unlikely since TCP).
486 int opts = (remote_candidate().protocol() == SSLTCP_PROTOCOL_NAME) 486 int opts = (remote_candidate().protocol() == SSLTCP_PROTOCOL_NAME)
487 ? rtc::PacketSocketFactory::OPT_SSLTCP 487 ? rtc::PacketSocketFactory::OPT_SSLTCP
488 : 0; 488 : 0;
489 socket_.reset(port()->socket_factory()->CreateClientTcpSocket( 489 socket_.reset(port()->socket_factory()->CreateClientTcpSocket(
(...skipping 15 matching lines...) Expand all
505 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { 505 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) {
506 if (outgoing_) { 506 if (outgoing_) {
507 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); 507 socket->SignalConnect.connect(this, &TCPConnection::OnConnect);
508 } 508 }
509 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); 509 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket);
510 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); 510 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend);
511 socket->SignalClose.connect(this, &TCPConnection::OnClose); 511 socket->SignalClose.connect(this, &TCPConnection::OnClose);
512 } 512 }
513 513
514 } // namespace cricket 514 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698