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

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

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanups. Created 5 years, 2 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
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 #include <algorithm> 10 #include <algorithm>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Called when a TCP connection is established or fails 137 // Called when a TCP connection is established or fails
138 void OnSocketConnect(rtc::AsyncPacketSocket* socket); 138 void OnSocketConnect(rtc::AsyncPacketSocket* socket);
139 void OnSocketClose(rtc::AsyncPacketSocket* socket, int error); 139 void OnSocketClose(rtc::AsyncPacketSocket* socket, int error);
140 140
141 // Called when a packet is received on this socket. 141 // Called when a packet is received on this socket.
142 void OnReadPacket( 142 void OnReadPacket(
143 rtc::AsyncPacketSocket* socket, 143 rtc::AsyncPacketSocket* socket,
144 const char* data, size_t size, 144 const char* data, size_t size,
145 const rtc::SocketAddress& remote_addr, 145 const rtc::SocketAddress& remote_addr,
146 const rtc::PacketTime& packet_time); 146 const rtc::PacketTime& packet_time);
147
148 void OnSentPacket(rtc::AsyncPacketSocket* socket,
149 const rtc::SentPacket& sent_packet);
150
147 // Called when the socket is currently able to send. 151 // Called when the socket is currently able to send.
148 void OnReadyToSend(rtc::AsyncPacketSocket* socket); 152 void OnReadyToSend(rtc::AsyncPacketSocket* socket);
149 153
150 // Sends the given data on the socket to the server with no wrapping. This 154 // Sends the given data on the socket to the server with no wrapping. This
151 // returns the number of bytes written or -1 if an error occurred. 155 // returns the number of bytes written or -1 if an error occurred.
152 int SendPacket(const void* data, size_t size, 156 int SendPacket(const void* data, size_t size,
153 const rtc::PacketOptions& options); 157 const rtc::PacketOptions& options);
154 }; 158 };
155 159
156 // Handles an allocate request for a particular RelayEntry. 160 // Handles an allocate request for a particular RelayEntry.
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 498 }
495 499
496 // If we failed to get a socket, move on to the next protocol. 500 // If we failed to get a socket, move on to the next protocol.
497 if (!socket) { 501 if (!socket) {
498 port()->thread()->Post(this, kMessageConnectTimeout); 502 port()->thread()->Post(this, kMessageConnectTimeout);
499 return; 503 return;
500 } 504 }
501 505
502 // Otherwise, create the new connection and configure any socket options. 506 // Otherwise, create the new connection and configure any socket options.
503 socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket); 507 socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket);
508 socket->SignalSentPacket.connect(this, &RelayEntry::OnSentPacket);
504 socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend); 509 socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend);
505 current_connection_ = new RelayConnection(ra, socket, port()->thread()); 510 current_connection_ = new RelayConnection(ra, socket, port()->thread());
506 for (size_t i = 0; i < port_->options().size(); ++i) { 511 for (size_t i = 0; i < port_->options().size(); ++i) {
507 current_connection_->SetSocketOption(port_->options()[i].first, 512 current_connection_->SetSocketOption(port_->options()[i].first,
508 port_->options()[i].second); 513 port_->options()[i].second);
509 } 514 }
510 515
511 // If we're trying UDP, start binding requests. 516 // If we're trying UDP, start binding requests.
512 // If we're trying TCP, wait for connection with a fixed timeout. 517 // If we're trying TCP, wait for connection with a fixed timeout.
513 if ((ra->proto == PROTO_TCP) || (ra->proto == PROTO_SSLTCP)) { 518 if ((ra->proto == PROTO_TCP) || (ra->proto == PROTO_SSLTCP)) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 if (!data_attr) { 738 if (!data_attr) {
734 LOG(INFO) << "Data indication has no data"; 739 LOG(INFO) << "Data indication has no data";
735 return; 740 return;
736 } 741 }
737 742
738 // Process the actual data and remote address in the normal manner. 743 // Process the actual data and remote address in the normal manner.
739 port_->OnReadPacket(data_attr->bytes(), data_attr->length(), remote_addr2, 744 port_->OnReadPacket(data_attr->bytes(), data_attr->length(), remote_addr2,
740 PROTO_UDP, packet_time); 745 PROTO_UDP, packet_time);
741 } 746 }
742 747
748 void RelayEntry::OnSentPacket(rtc::AsyncPacketSocket* socket,
749 const rtc::SentPacket& sent_packet) {
750 port_->OnSentPacket(sent_packet);
751 }
752
743 void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) { 753 void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
744 if (connected()) { 754 if (connected()) {
745 port_->OnReadyToSend(); 755 port_->OnReadyToSend();
746 } 756 }
747 } 757 }
748 758
749 int RelayEntry::SendPacket(const void* data, size_t size, 759 int RelayEntry::SendPacket(const void* data, size_t size,
750 const rtc::PacketOptions& options) { 760 const rtc::PacketOptions& options) {
751 int sent = 0; 761 int sent = 0;
752 if (current_connection_) { 762 if (current_connection_) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (rtc::TimeSince(start_time_) <= kRetryTimeout) 830 if (rtc::TimeSince(start_time_) <= kRetryTimeout)
821 entry_->ScheduleKeepAlive(); 831 entry_->ScheduleKeepAlive();
822 } 832 }
823 833
824 void AllocateRequest::OnTimeout() { 834 void AllocateRequest::OnTimeout() {
825 LOG(INFO) << "Allocate request timed out"; 835 LOG(INFO) << "Allocate request timed out";
826 entry_->HandleConnectFailure(connection_->socket()); 836 entry_->HandleConnectFailure(connection_->socket());
827 } 837 }
828 838
829 } // namespace cricket 839 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698