Reland Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket.
Chromium reported errors when building libjingle_nacl due to some methods used virtual instead of override when they were overriding the base class. My guess is that when one method starts using override, all other in the same class must too. R=tommi@webrtc.org TBR=pthatcher@webtrc.org BUG=4173 Review URL: https://codereview.webrtc.org/1589563003 . Cr-Commit-Position: refs/heads/master@{#11251}
This commit is contained in:
parent
31c8d2eac5
commit
55674ffb32
@ -1424,8 +1424,7 @@ void P2PTransportChannel::OnReadPacket(Connection* connection,
|
||||
}
|
||||
}
|
||||
|
||||
void P2PTransportChannel::OnSentPacket(PortInterface* port,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
void P2PTransportChannel::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
||||
ASSERT(worker_thread_ == rtc::Thread::Current());
|
||||
|
||||
SignalSentPacket(this, sent_packet);
|
||||
|
||||
@ -232,7 +232,7 @@ class P2PTransportChannel : public TransportChannelImpl,
|
||||
void OnConnectionStateChange(Connection* connection);
|
||||
void OnReadPacket(Connection *connection, const char *data, size_t len,
|
||||
const rtc::PacketTime& packet_time);
|
||||
void OnSentPacket(PortInterface* port, const rtc::SentPacket& sent_packet);
|
||||
void OnSentPacket(const rtc::SentPacket& sent_packet);
|
||||
void OnReadyToSend(Connection* connection);
|
||||
void OnConnectionDestroyed(Connection *connection);
|
||||
|
||||
|
||||
@ -310,10 +310,6 @@ void Port::OnReadPacket(
|
||||
}
|
||||
}
|
||||
|
||||
void Port::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
||||
PortInterface::SignalSentPacket(this, sent_packet);
|
||||
}
|
||||
|
||||
void Port::OnReadyToSend() {
|
||||
AddressMap::iterator iter = connections_.begin();
|
||||
for (; iter != connections_.end(); ++iter) {
|
||||
|
||||
@ -280,7 +280,11 @@ class Port : public PortInterface, public rtc::MessageHandler,
|
||||
const std::string& remote_ufrag);
|
||||
|
||||
// Called when a packet has been sent to the socket.
|
||||
void OnSentPacket(const rtc::SentPacket& sent_packet);
|
||||
// This is made pure virtual to notify subclasses of Port that they MUST
|
||||
// listen to AsyncPacketSocket::SignalSentPacket and then call
|
||||
// PortInterface::OnSentPacket.
|
||||
virtual void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) = 0;
|
||||
|
||||
// Called when the socket is currently able to send.
|
||||
void OnReadyToSend();
|
||||
|
||||
@ -204,6 +204,10 @@ class TestPort : public Port {
|
||||
}
|
||||
|
||||
private:
|
||||
void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
PortInterface::SignalSentPacket(sent_packet);
|
||||
}
|
||||
rtc::scoped_ptr<ByteBuffer> last_stun_buf_;
|
||||
rtc::scoped_ptr<IceMessage> last_stun_msg_;
|
||||
int type_preference_ = 0;
|
||||
|
||||
@ -116,7 +116,7 @@ class PortInterface {
|
||||
const rtc::SocketAddress&> SignalReadPacket;
|
||||
|
||||
// Emitted each time a packet is sent on this port.
|
||||
sigslot::signal2<PortInterface*, const rtc::SentPacket&> SignalSentPacket;
|
||||
sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
|
||||
|
||||
virtual std::string ToString() const = 0;
|
||||
|
||||
|
||||
@ -754,7 +754,7 @@ void RelayEntry::OnReadPacket(
|
||||
|
||||
void RelayEntry::OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
port_->OnSentPacket(sent_packet);
|
||||
port_->OnSentPacket(socket, sent_packet);
|
||||
}
|
||||
|
||||
void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
|
||||
|
||||
@ -29,7 +29,7 @@ class RelayConnection;
|
||||
// is created. The RelayEntry will try to reach the remote destination
|
||||
// by connecting to all available server addresses in a pre defined
|
||||
// order with a small delay in between. When a connection is
|
||||
// successful all other connection attemts are aborted.
|
||||
// successful all other connection attempts are aborted.
|
||||
class RelayPort : public Port {
|
||||
public:
|
||||
typedef std::pair<rtc::Socket::Option, int> OptionValue;
|
||||
@ -46,7 +46,7 @@ class RelayPort : public Port {
|
||||
return new RelayPort(thread, factory, network, ip, min_port, max_port,
|
||||
username, password);
|
||||
}
|
||||
virtual ~RelayPort();
|
||||
~RelayPort() override;
|
||||
|
||||
void AddServerAddress(const ProtocolAddress& addr);
|
||||
void AddExternalAddress(const ProtocolAddress& addr);
|
||||
@ -54,13 +54,13 @@ class RelayPort : public Port {
|
||||
const std::vector<OptionValue>& options() const { return options_; }
|
||||
bool HasMagicCookie(const char* data, size_t size);
|
||||
|
||||
virtual void PrepareAddress();
|
||||
virtual Connection* CreateConnection(const Candidate& address,
|
||||
CandidateOrigin origin);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual int GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int GetError();
|
||||
virtual bool SupportsProtocol(const std::string& protocol) const {
|
||||
void PrepareAddress() override;
|
||||
Connection* CreateConnection(const Candidate& address,
|
||||
CandidateOrigin origin) override;
|
||||
int SetOption(rtc::Socket::Option opt, int value) override;
|
||||
int GetOption(rtc::Socket::Option opt, int* value) override;
|
||||
int GetError() override;
|
||||
bool SupportsProtocol(const std::string& protocol) const override {
|
||||
// Relay port may create both TCP and UDP connections.
|
||||
return true;
|
||||
}
|
||||
@ -85,10 +85,11 @@ class RelayPort : public Port {
|
||||
|
||||
void SetReady();
|
||||
|
||||
virtual int SendTo(const void* data, size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload);
|
||||
int SendTo(const void* data,
|
||||
size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload) override;
|
||||
|
||||
// Dispatches the given packet to the port or connection as appropriate.
|
||||
void OnReadPacket(const char* data, size_t size,
|
||||
@ -96,6 +97,11 @@ class RelayPort : public Port {
|
||||
ProtocolType proto,
|
||||
const rtc::PacketTime& packet_time);
|
||||
|
||||
// The OnSentPacket callback is left empty here since they are handled by
|
||||
// RelayEntry.
|
||||
void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) override {}
|
||||
|
||||
private:
|
||||
friend class RelayEntry;
|
||||
|
||||
|
||||
@ -340,7 +340,7 @@ void UDPPort::OnReadPacket(rtc::AsyncPacketSocket* socket,
|
||||
|
||||
void UDPPort::OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
Port::OnSentPacket(sent_packet);
|
||||
PortInterface::SignalSentPacket(sent_packet);
|
||||
}
|
||||
|
||||
void UDPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
|
||||
|
||||
@ -258,6 +258,7 @@ void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket,
|
||||
incoming.socket = new_socket;
|
||||
incoming.socket->SignalReadPacket.connect(this, &TCPPort::OnReadPacket);
|
||||
incoming.socket->SignalReadyToSend.connect(this, &TCPPort::OnReadyToSend);
|
||||
incoming.socket->SignalSentPacket.connect(this, &TCPPort::OnSentPacket);
|
||||
|
||||
LOG_J(LS_VERBOSE, this) << "Accepted connection from "
|
||||
<< incoming.addr.ToSensitiveString();
|
||||
@ -286,6 +287,12 @@ void TCPPort::OnReadPacket(rtc::AsyncPacketSocket* socket,
|
||||
Port::OnReadPacket(data, size, remote_addr, PROTO_TCP);
|
||||
}
|
||||
|
||||
void TCPPort::OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
ASSERT(socket == socket_);
|
||||
PortInterface::SignalSentPacket(sent_packet);
|
||||
}
|
||||
|
||||
void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
|
||||
Port::OnReadyToSend();
|
||||
}
|
||||
|
||||
@ -45,17 +45,17 @@ class TCPPort : public Port {
|
||||
}
|
||||
return port;
|
||||
}
|
||||
virtual ~TCPPort();
|
||||
~TCPPort() override;
|
||||
|
||||
virtual Connection* CreateConnection(const Candidate& address,
|
||||
CandidateOrigin origin);
|
||||
Connection* CreateConnection(const Candidate& address,
|
||||
CandidateOrigin origin) override;
|
||||
|
||||
virtual void PrepareAddress();
|
||||
void PrepareAddress() override;
|
||||
|
||||
virtual int GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual int GetError();
|
||||
virtual bool SupportsProtocol(const std::string& protocol) const {
|
||||
int GetOption(rtc::Socket::Option opt, int* value) override;
|
||||
int SetOption(rtc::Socket::Option opt, int value) override;
|
||||
int GetError() override;
|
||||
bool SupportsProtocol(const std::string& protocol) const override {
|
||||
return protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME;
|
||||
}
|
||||
|
||||
@ -72,10 +72,11 @@ class TCPPort : public Port {
|
||||
bool Init();
|
||||
|
||||
// Handles sending using the local TCP socket.
|
||||
virtual int SendTo(const void* data, size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload);
|
||||
int SendTo(const void* data,
|
||||
size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload) override;
|
||||
|
||||
// Accepts incoming TCP connection.
|
||||
void OnNewConnection(rtc::AsyncPacketSocket* socket,
|
||||
@ -96,6 +97,9 @@ class TCPPort : public Port {
|
||||
const rtc::SocketAddress& remote_addr,
|
||||
const rtc::PacketTime& packet_time);
|
||||
|
||||
void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) override;
|
||||
|
||||
void OnReadyToSend(rtc::AsyncPacketSocket* socket);
|
||||
|
||||
void OnAddressReady(rtc::AsyncPacketSocket* socket,
|
||||
@ -116,15 +120,16 @@ class TCPConnection : public Connection {
|
||||
// Connection is outgoing unless socket is specified
|
||||
TCPConnection(TCPPort* port, const Candidate& candidate,
|
||||
rtc::AsyncPacketSocket* socket = 0);
|
||||
virtual ~TCPConnection();
|
||||
~TCPConnection() override;
|
||||
|
||||
virtual int Send(const void* data, size_t size,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual int GetError();
|
||||
int Send(const void* data,
|
||||
size_t size,
|
||||
const rtc::PacketOptions& options) override;
|
||||
int GetError() override;
|
||||
|
||||
rtc::AsyncPacketSocket* socket() { return socket_.get(); }
|
||||
|
||||
void OnMessage(rtc::Message* pmsg);
|
||||
void OnMessage(rtc::Message* pmsg) override;
|
||||
|
||||
// Allow test cases to overwrite the default timeout period.
|
||||
int reconnection_timeout() const { return reconnection_timeout_; }
|
||||
@ -139,8 +144,8 @@ class TCPConnection : public Connection {
|
||||
|
||||
// Set waiting_for_stun_binding_complete_ to false to allow data packets in
|
||||
// addition to what Port::OnConnectionRequestResponse does.
|
||||
virtual void OnConnectionRequestResponse(ConnectionRequest* req,
|
||||
StunMessage* response);
|
||||
void OnConnectionRequestResponse(ConnectionRequest* req,
|
||||
StunMessage* response) override;
|
||||
|
||||
private:
|
||||
// Helper function to handle the case when Ping or Send fails with error
|
||||
|
||||
@ -351,6 +351,8 @@ bool TurnPort::CreateTurnClientSocket() {
|
||||
|
||||
socket_->SignalReadyToSend.connect(this, &TurnPort::OnReadyToSend);
|
||||
|
||||
socket_->SignalSentPacket.connect(this, &TurnPort::OnSentPacket);
|
||||
|
||||
// TCP port is ready to send stun requests after the socket is connected,
|
||||
// while UDP port is ready to do so once the socket is created.
|
||||
if (server_address_.proto == PROTO_TCP) {
|
||||
@ -582,6 +584,11 @@ void TurnPort::OnReadPacket(
|
||||
}
|
||||
}
|
||||
|
||||
void TurnPort::OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet) {
|
||||
PortInterface::SignalSentPacket(sent_packet);
|
||||
}
|
||||
|
||||
void TurnPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
|
||||
if (ready()) {
|
||||
Port::OnReadyToSend();
|
||||
|
||||
@ -106,6 +106,8 @@ class TurnPort : public Port {
|
||||
const rtc::SocketAddress& remote_addr,
|
||||
const rtc::PacketTime& packet_time);
|
||||
|
||||
virtual void OnSentPacket(rtc::AsyncPacketSocket* socket,
|
||||
const rtc::SentPacket& sent_packet);
|
||||
virtual void OnReadyToSend(rtc::AsyncPacketSocket* socket);
|
||||
virtual bool SupportsProtocol(const std::string& protocol) const {
|
||||
// Turn port only connects to UDP candidates.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user