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 #include <algorithm> | 10 #include <algorithm> |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } else { | 499 } else { |
500 LOG(LS_WARNING) << "Unknown protocol (" << ra->proto << ")"; | 500 LOG(LS_WARNING) << "Unknown protocol (" << ra->proto << ")"; |
501 } | 501 } |
502 | 502 |
503 if (!socket) { | 503 if (!socket) { |
504 LOG(LS_WARNING) << "Socket creation failed"; | 504 LOG(LS_WARNING) << "Socket creation failed"; |
505 } | 505 } |
506 | 506 |
507 // If we failed to get a socket, move on to the next protocol. | 507 // If we failed to get a socket, move on to the next protocol. |
508 if (!socket) { | 508 if (!socket) { |
509 port()->thread()->Post(this, kMessageConnectTimeout); | 509 port()->thread()->Post(RTC_FROM_HERE, this, kMessageConnectTimeout); |
510 return; | 510 return; |
511 } | 511 } |
512 | 512 |
513 // Otherwise, create the new connection and configure any socket options. | 513 // Otherwise, create the new connection and configure any socket options. |
514 socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket); | 514 socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket); |
515 socket->SignalSentPacket.connect(this, &RelayEntry::OnSentPacket); | 515 socket->SignalSentPacket.connect(this, &RelayEntry::OnSentPacket); |
516 socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend); | 516 socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend); |
517 current_connection_ = new RelayConnection(ra, socket, port()->thread()); | 517 current_connection_ = new RelayConnection(ra, socket, port()->thread()); |
518 for (size_t i = 0; i < port_->options().size(); ++i) { | 518 for (size_t i = 0; i < port_->options().size(); ++i) { |
519 current_connection_->SetSocketOption(port_->options()[i].first, | 519 current_connection_->SetSocketOption(port_->options()[i].first, |
520 port_->options()[i].second); | 520 port_->options()[i].second); |
521 } | 521 } |
522 | 522 |
523 // If we're trying UDP, start binding requests. | 523 // If we're trying UDP, start binding requests. |
524 // If we're trying TCP, wait for connection with a fixed timeout. | 524 // If we're trying TCP, wait for connection with a fixed timeout. |
525 if ((ra->proto == PROTO_TCP) || (ra->proto == PROTO_SSLTCP)) { | 525 if ((ra->proto == PROTO_TCP) || (ra->proto == PROTO_SSLTCP)) { |
526 socket->SignalClose.connect(this, &RelayEntry::OnSocketClose); | 526 socket->SignalClose.connect(this, &RelayEntry::OnSocketClose); |
527 socket->SignalConnect.connect(this, &RelayEntry::OnSocketConnect); | 527 socket->SignalConnect.connect(this, &RelayEntry::OnSocketConnect); |
528 port()->thread()->PostDelayed(kSoftConnectTimeoutMs, this, | 528 port()->thread()->PostDelayed(RTC_FROM_HERE, kSoftConnectTimeoutMs, this, |
529 kMessageConnectTimeout); | 529 kMessageConnectTimeout); |
530 } else { | 530 } else { |
531 current_connection_->SendAllocateRequest(this, 0); | 531 current_connection_->SendAllocateRequest(this, 0); |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 int RelayEntry::GetError() { | 535 int RelayEntry::GetError() { |
536 if (current_connection_ != NULL) { | 536 if (current_connection_ != NULL) { |
537 return current_connection_->GetError(); | 537 return current_connection_->GetError(); |
538 } | 538 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 if (rtc::TimeMillis() - start_time_ <= kRetryTimeout) | 837 if (rtc::TimeMillis() - start_time_ <= kRetryTimeout) |
838 entry_->ScheduleKeepAlive(); | 838 entry_->ScheduleKeepAlive(); |
839 } | 839 } |
840 | 840 |
841 void AllocateRequest::OnTimeout() { | 841 void AllocateRequest::OnTimeout() { |
842 LOG(INFO) << "Allocate request timed out"; | 842 LOG(INFO) << "Allocate request timed out"; |
843 entry_->HandleConnectFailure(connection_->socket()); | 843 entry_->HandleConnectFailure(connection_->socket()); |
844 } | 844 } |
845 | 845 |
846 } // namespace cricket | 846 } // namespace cricket |
OLD | NEW |