Index: webrtc/p2p/base/turnserver.cc |
diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc |
index 3a574673c39a6c0a96e25ed3e065a4a83d1ae86b..eef12ead2d6054b0c6e4883dd909c090643371ea 100644 |
--- a/webrtc/p2p/base/turnserver.cc |
+++ b/webrtc/p2p/base/turnserver.cc |
@@ -18,6 +18,7 @@ |
#include "webrtc/p2p/base/stun.h" |
#include "webrtc/base/bind.h" |
#include "webrtc/base/bytebuffer.h" |
+#include "webrtc/base/checks.h" |
#include "webrtc/base/helpers.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/messagedigest.h" |
@@ -142,15 +143,15 @@ TurnServer::~TurnServer() { |
void TurnServer::AddInternalSocket(rtc::AsyncPacketSocket* socket, |
ProtocolType proto) { |
- ASSERT(server_sockets_.end() == server_sockets_.find(socket)); |
+ RTC_DCHECK(server_sockets_.end() == server_sockets_.find(socket)); |
server_sockets_[socket] = proto; |
socket->SignalReadPacket.connect(this, &TurnServer::OnInternalPacket); |
} |
void TurnServer::AddInternalServerSocket(rtc::AsyncSocket* socket, |
ProtocolType proto) { |
- ASSERT(server_listen_sockets_.end() == |
- server_listen_sockets_.find(socket)); |
+ RTC_DCHECK(server_listen_sockets_.end() == |
+ server_listen_sockets_.find(socket)); |
server_listen_sockets_[socket] = proto; |
socket->SignalReadEvent.connect(this, &TurnServer::OnNewInternalConnection); |
} |
@@ -163,7 +164,8 @@ void TurnServer::SetExternalSocketFactory( |
} |
void TurnServer::OnNewInternalConnection(rtc::AsyncSocket* socket) { |
- ASSERT(server_listen_sockets_.find(socket) != server_listen_sockets_.end()); |
+ RTC_DCHECK(server_listen_sockets_.find(socket) != |
+ server_listen_sockets_.end()); |
AcceptConnection(socket); |
} |
@@ -196,7 +198,7 @@ void TurnServer::OnInternalPacket(rtc::AsyncPacketSocket* socket, |
return; |
} |
InternalSocketMap::iterator iter = server_sockets_.find(socket); |
- ASSERT(iter != server_sockets_.end()); |
+ RTC_DCHECK(iter != server_sockets_.end()); |
TurnServerConnection conn(addr, iter->second, socket); |
uint16_t msg_type = rtc::GetBE16(data); |
if (!IsTurnChannelData(msg_type)) { |
@@ -290,7 +292,7 @@ bool TurnServer::CheckAuthorization(TurnServerConnection* conn, |
const char* data, size_t size, |
const std::string& key) { |
// RFC 5389, 10.2.2. |
- ASSERT(IsStunRequestType(msg->type())); |
+ RTC_DCHECK(IsStunRequestType(msg->type())); |
const StunByteStringAttribute* mi_attr = |
msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); |
const StunByteStringAttribute* username_attr = |
@@ -395,7 +397,7 @@ std::string TurnServer::GenerateNonce(int64_t now) const { |
std::string input(reinterpret_cast<const char*>(&now), sizeof(now)); |
std::string nonce = rtc::hex_encode(input.c_str(), input.size()); |
nonce += rtc::ComputeHmac(rtc::DIGEST_MD5, nonce_key_, input); |
- ASSERT(nonce.size() == kNonceSize); |
+ RTC_DCHECK(nonce.size() == kNonceSize); |
return nonce; |
} |
@@ -601,7 +603,7 @@ std::string TurnServerAllocation::ToString() const { |
} |
void TurnServerAllocation::HandleTurnMessage(const TurnMessage* msg) { |
- ASSERT(msg != NULL); |
+ RTC_DCHECK(msg != NULL); |
switch (msg->type()) { |
case STUN_ALLOCATE_REQUEST: |
HandleAllocateRequest(msg); |
@@ -630,7 +632,7 @@ void TurnServerAllocation::HandleAllocateRequest(const TurnMessage* msg) { |
transaction_id_ = msg->transaction_id(); |
const StunByteStringAttribute* username_attr = |
msg->GetByteString(STUN_ATTR_USERNAME); |
- ASSERT(username_attr != NULL); |
+ RTC_DCHECK(username_attr != NULL); |
username_ = username_attr->GetString(); |
const StunByteStringAttribute* origin_attr = |
msg->GetByteString(STUN_ATTR_ORIGIN); |
@@ -801,7 +803,7 @@ void TurnServerAllocation::OnExternalPacket( |
const char* data, size_t size, |
const rtc::SocketAddress& addr, |
const rtc::PacketTime& packet_time) { |
- ASSERT(external_socket_.get() == socket); |
+ RTC_DCHECK(external_socket_.get() == socket); |
Channel* channel = FindChannel(addr); |
if (channel) { |
// There is a channel bound to this address. Send as a channel message. |
@@ -906,21 +908,21 @@ void TurnServerAllocation::SendExternal(const void* data, size_t size, |
} |
void TurnServerAllocation::OnMessage(rtc::Message* msg) { |
- ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
+ RTC_DCHECK(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
SignalDestroyed(this); |
delete this; |
} |
void TurnServerAllocation::OnPermissionDestroyed(Permission* perm) { |
PermissionList::iterator it = std::find(perms_.begin(), perms_.end(), perm); |
- ASSERT(it != perms_.end()); |
+ RTC_DCHECK(it != perms_.end()); |
perms_.erase(it); |
} |
void TurnServerAllocation::OnChannelDestroyed(Channel* channel) { |
ChannelList::iterator it = |
std::find(channels_.begin(), channels_.end(), channel); |
- ASSERT(it != channels_.end()); |
+ RTC_DCHECK(it != channels_.end()); |
channels_.erase(it); |
} |
@@ -941,7 +943,7 @@ void TurnServerAllocation::Permission::Refresh() { |
} |
void TurnServerAllocation::Permission::OnMessage(rtc::Message* msg) { |
- ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
+ RTC_DCHECK(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
SignalDestroyed(this); |
delete this; |
} |
@@ -963,7 +965,7 @@ void TurnServerAllocation::Channel::Refresh() { |
} |
void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { |
- ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
+ RTC_DCHECK(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
SignalDestroyed(this); |
delete this; |
} |