Index: webrtc/p2p/base/relayserver.cc |
diff --git a/webrtc/p2p/base/relayserver.cc b/webrtc/p2p/base/relayserver.cc |
index 2c14a2b541b51b727584970606d82b801b1ff177..442f343e024395f9978f3bb76158be12c047a6ae 100644 |
--- a/webrtc/p2p/base/relayserver.cc |
+++ b/webrtc/p2p/base/relayserver.cc |
@@ -101,8 +101,9 @@ RelayServer::~RelayServer() { |
} |
void RelayServer::AddInternalSocket(rtc::AsyncPacketSocket* socket) { |
- ASSERT(internal_sockets_.end() == |
- std::find(internal_sockets_.begin(), internal_sockets_.end(), socket)); |
+ RTC_DCHECK(internal_sockets_.end() == std::find(internal_sockets_.begin(), |
+ internal_sockets_.end(), |
+ socket)); |
internal_sockets_.push_back(socket); |
socket->SignalReadPacket.connect(this, &RelayServer::OnInternalPacket); |
} |
@@ -110,15 +111,16 @@ void RelayServer::AddInternalSocket(rtc::AsyncPacketSocket* socket) { |
void RelayServer::RemoveInternalSocket(rtc::AsyncPacketSocket* socket) { |
SocketList::iterator iter = |
std::find(internal_sockets_.begin(), internal_sockets_.end(), socket); |
- ASSERT(iter != internal_sockets_.end()); |
+ RTC_DCHECK(iter != internal_sockets_.end()); |
internal_sockets_.erase(iter); |
removed_sockets_.push_back(socket); |
socket->SignalReadPacket.disconnect(this); |
} |
void RelayServer::AddExternalSocket(rtc::AsyncPacketSocket* socket) { |
- ASSERT(external_sockets_.end() == |
- std::find(external_sockets_.begin(), external_sockets_.end(), socket)); |
+ RTC_DCHECK(external_sockets_.end() == std::find(external_sockets_.begin(), |
+ external_sockets_.end(), |
+ socket)); |
external_sockets_.push_back(socket); |
socket->SignalReadPacket.connect(this, &RelayServer::OnExternalPacket); |
} |
@@ -126,7 +128,7 @@ void RelayServer::AddExternalSocket(rtc::AsyncPacketSocket* socket) { |
void RelayServer::RemoveExternalSocket(rtc::AsyncPacketSocket* socket) { |
SocketList::iterator iter = |
std::find(external_sockets_.begin(), external_sockets_.end(), socket); |
- ASSERT(iter != external_sockets_.end()); |
+ RTC_DCHECK(iter != external_sockets_.end()); |
external_sockets_.erase(iter); |
removed_sockets_.push_back(socket); |
socket->SignalReadPacket.disconnect(this); |
@@ -134,8 +136,7 @@ void RelayServer::RemoveExternalSocket(rtc::AsyncPacketSocket* socket) { |
void RelayServer::AddInternalServerSocket(rtc::AsyncSocket* socket, |
cricket::ProtocolType proto) { |
- ASSERT(server_sockets_.end() == |
- server_sockets_.find(socket)); |
+ RTC_DCHECK(server_sockets_.end() == server_sockets_.find(socket)); |
server_sockets_[socket] = proto; |
socket->SignalReadEvent.connect(this, &RelayServer::OnReadEvent); |
} |
@@ -143,7 +144,7 @@ void RelayServer::AddInternalServerSocket(rtc::AsyncSocket* socket, |
void RelayServer::RemoveInternalServerSocket( |
rtc::AsyncSocket* socket) { |
ServerSocketMap::iterator iter = server_sockets_.find(socket); |
- ASSERT(iter != server_sockets_.end()); |
+ RTC_DCHECK(iter != server_sockets_.end()); |
server_sockets_.erase(iter); |
socket->SignalReadEvent.disconnect(this); |
} |
@@ -175,7 +176,7 @@ bool RelayServer::HasConnection(const rtc::SocketAddress& address) const { |
} |
void RelayServer::OnReadEvent(rtc::AsyncSocket* socket) { |
- ASSERT(server_sockets_.find(socket) != server_sockets_.end()); |
+ RTC_DCHECK(server_sockets_.find(socket) != server_sockets_.end()); |
AcceptConnection(socket); |
} |
@@ -186,7 +187,7 @@ void RelayServer::OnInternalPacket( |
// Get the address of the connection we just received on. |
rtc::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); |
- ASSERT(!ap.destination().IsNil()); |
+ RTC_DCHECK(!ap.destination().IsNil()); |
// If this did not come from an existing connection, it should be a STUN |
// allocate request. |
@@ -231,7 +232,7 @@ void RelayServer::OnExternalPacket( |
// Get the address of the connection we just received on. |
rtc::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); |
- ASSERT(!ap.destination().IsNil()); |
+ RTC_DCHECK(!ap.destination().IsNil()); |
// If this connection already exists, then forward the traffic. |
ConnectionMap::iterator piter = connections_.find(ap); |
@@ -241,7 +242,7 @@ void RelayServer::OnExternalPacket( |
RelayServerConnection* int_conn = |
ext_conn->binding()->GetInternalConnection( |
ext_conn->addr_pair().source()); |
- ASSERT(int_conn != NULL); |
+ RTC_DCHECK(int_conn != NULL); |
int_conn->Send(bytes, size, ext_conn->addr_pair().source()); |
ext_conn->Lock(); // allow outgoing packets |
return; |
@@ -289,7 +290,7 @@ void RelayServer::OnExternalPacket( |
// Send this message on the appropriate internal connection. |
RelayServerConnection* int_conn = ext_conn->binding()->GetInternalConnection( |
ext_conn->addr_pair().source()); |
- ASSERT(int_conn != NULL); |
+ RTC_DCHECK(int_conn != NULL); |
int_conn->Send(bytes, size, ext_conn->addr_pair().source()); |
} |
@@ -471,7 +472,7 @@ void RelayServer::HandleStunSend( |
int_conn->binding()->GetExternalConnection(ext_addr); |
if (!ext_conn) { |
// Create a new connection to establish the relationship with this binding. |
- ASSERT(external_sockets_.size() == 1); |
+ RTC_DCHECK(external_sockets_.size() == 1); |
rtc::AsyncPacketSocket* socket = external_sockets_[0]; |
rtc::SocketAddressPair ap(ext_addr, socket->GetLocalAddress()); |
ext_conn = new RelayServerConnection(int_conn->binding(), ap, socket); |
@@ -509,19 +510,19 @@ void RelayServer::HandleStunSend( |
} |
void RelayServer::AddConnection(RelayServerConnection* conn) { |
- ASSERT(connections_.find(conn->addr_pair()) == connections_.end()); |
+ RTC_DCHECK(connections_.find(conn->addr_pair()) == connections_.end()); |
connections_[conn->addr_pair()] = conn; |
} |
void RelayServer::RemoveConnection(RelayServerConnection* conn) { |
ConnectionMap::iterator iter = connections_.find(conn->addr_pair()); |
- ASSERT(iter != connections_.end()); |
+ RTC_DCHECK(iter != connections_.end()); |
connections_.erase(iter); |
} |
void RelayServer::RemoveBinding(RelayServerBinding* binding) { |
BindingMap::iterator iter = bindings_.find(binding->username()); |
- ASSERT(iter != bindings_.end()); |
+ RTC_DCHECK(iter != bindings_.end()); |
bindings_.erase(iter); |
if (log_bindings_) { |
@@ -531,10 +532,9 @@ void RelayServer::RemoveBinding(RelayServerBinding* binding) { |
} |
void RelayServer::OnMessage(rtc::Message *pmsg) { |
-#if ENABLE_DEBUG |
static const uint32_t kMessageAcceptConnection = 1; |
- ASSERT(pmsg->message_id == kMessageAcceptConnection); |
-#endif |
+ RTC_DCHECK(pmsg->message_id == kMessageAcceptConnection); |
+ |
rtc::MessageData* data = pmsg->pdata; |
rtc::AsyncSocket* socket = |
static_cast <rtc::TypedMessageData<rtc::AsyncSocket*>*> |
@@ -557,8 +557,8 @@ void RelayServer::AcceptConnection(rtc::AsyncSocket* server_socket) { |
if (accepted_socket != NULL) { |
// We had someone trying to connect, now check which protocol to |
// use and create a packet socket. |
- ASSERT(server_sockets_[server_socket] == cricket::PROTO_TCP || |
- server_sockets_[server_socket] == cricket::PROTO_SSLTCP); |
+ RTC_DCHECK(server_sockets_[server_socket] == cricket::PROTO_TCP || |
+ server_sockets_[server_socket] == cricket::PROTO_SSLTCP); |
if (server_sockets_[server_socket] == cricket::PROTO_SSLTCP) { |
accepted_socket = new rtc::AsyncSSLServerSocket(accepted_socket); |
} |
@@ -617,7 +617,7 @@ void RelayServerConnection::Send( |
StunByteStringAttribute* data_attr = |
StunAttribute::CreateByteString(STUN_ATTR_DATA); |
- ASSERT(size <= 65536); |
+ RTC_DCHECK(size <= 65536); |
data_attr->CopyBytes(data, uint16_t(size)); |
msg.AddAttribute(data_attr); |
@@ -718,7 +718,7 @@ RelayServerConnection* RelayServerBinding::GetInternalConnection( |
} |
// If one was not found, we send to the first connection. |
- ASSERT(internal_connections_.size() > 0); |
+ RTC_DCHECK(internal_connections_.size() > 0); |
return internal_connections_[0]; |
} |
@@ -733,7 +733,7 @@ RelayServerConnection* RelayServerBinding::GetExternalConnection( |
void RelayServerBinding::OnMessage(rtc::Message *pmsg) { |
if (pmsg->message_id == MSG_LIFETIME_TIMER) { |
- ASSERT(!pmsg->pdata); |
+ RTC_DCHECK(!pmsg->pdata); |
// If the lifetime timeout has been exceeded, then send a signal. |
// Otherwise, just keep waiting. |