Replace ASSERT by RTC_DCHECK in all non-test code.
Bulk of the changes were produced using
git grep -l ' ASSERT(' | grep -v test | grep -v 'common\.h' |\
xargs -n1 sed -i 's/ ASSERT(/ RTC_DCHECK(/'
followed by additional includes of base/checks.h in affected files,
and git cl format.
Also had to do some tweaks to #if !defined(NDEBUG) logic in the
taskrunner code (webrtc/base/task.cc, webrtc/base/taskparent.cc,
webrtc/base/taskparent.h, webrtc/base/taskrunner.cc), replaced to
consistently use RTC_DCHECK_IS_ON, and some of the checks needed
additional #if protection.
Test code was excluded, because it should probably use RTC_CHECK
rather than RTC_DCHECK.
BUG=webrtc:6424
Review-Url: https://codereview.webrtc.org/2620303003
Cr-Commit-Position: refs/heads/master@{#16030}
diff --git a/webrtc/api/datachannel.cc b/webrtc/api/datachannel.cc
index ad7cb57..c0bc3dc 100644
--- a/webrtc/api/datachannel.cc
+++ b/webrtc/api/datachannel.cc
@@ -14,6 +14,7 @@
#include <string>
#include "webrtc/api/sctputils.h"
+#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/refcount.h"
#include "webrtc/media/sctp/sctptransportinternal.h"
@@ -248,7 +249,7 @@
if (!queued_send_data_.Empty()) {
// Only SCTP DataChannel queues the outgoing data when the transport is
// blocked.
- ASSERT(data_channel_type_ == cricket::DCT_SCTP);
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP);
if (!QueueSendDataMessage(buffer)) {
Close();
}
@@ -265,7 +266,7 @@
}
void DataChannel::SetReceiveSsrc(uint32_t receive_ssrc) {
- ASSERT(data_channel_type_ == cricket::DCT_RTP);
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_RTP);
if (receive_ssrc_set_) {
return;
@@ -281,7 +282,8 @@
}
void DataChannel::SetSctpSid(int sid) {
- ASSERT(config_.id < 0 && sid >= 0 && data_channel_type_ == cricket::DCT_SCTP);
+ RTC_DCHECK(config_.id < 0 && sid >= 0 &&
+ data_channel_type_ == cricket::DCT_SCTP);
if (config_.id == sid) {
return;
}
@@ -291,7 +293,7 @@
}
void DataChannel::OnTransportChannelCreated() {
- ASSERT(data_channel_type_ == cricket::DCT_SCTP);
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP);
if (!connected_to_provider_) {
connected_to_provider_ = provider_->ConnectDataChannel(this);
}
@@ -311,7 +313,7 @@
}
void DataChannel::SetSendSsrc(uint32_t send_ssrc) {
- ASSERT(data_channel_type_ == cricket::DCT_RTP);
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_RTP);
if (send_ssrc_set_) {
return;
}
@@ -338,7 +340,7 @@
}
if (params.type == cricket::DMT_CONTROL) {
- ASSERT(data_channel_type_ == cricket::DCT_SCTP);
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP);
if (handshake_state_ != kHandshakeWaitingForAck) {
// Ignore it if we are not expecting an ACK message.
LOG(LS_WARNING) << "DataChannel received unexpected CONTROL message, "
@@ -357,8 +359,8 @@
return;
}
- ASSERT(params.type == cricket::DMT_BINARY ||
- params.type == cricket::DMT_TEXT);
+ RTC_DCHECK(params.type == cricket::DMT_BINARY ||
+ params.type == cricket::DMT_TEXT);
LOG(LS_VERBOSE) << "DataChannel received DATA message, sid = " << params.sid;
// We can send unordered as soon as we receive any DATA message since the
@@ -517,7 +519,7 @@
return;
}
- ASSERT(state_ == kOpen || state_ == kClosing);
+ RTC_DCHECK(state_ == kOpen || state_ == kClosing);
uint64_t start_buffered_amount = buffered_amount();
while (!queued_send_data_.Empty()) {
@@ -616,10 +618,8 @@
bool DataChannel::SendControlMessage(const rtc::CopyOnWriteBuffer& buffer) {
bool is_open_message = handshake_state_ == kHandshakeShouldSendOpen;
- ASSERT(data_channel_type_ == cricket::DCT_SCTP &&
- writable_ &&
- config_.id >= 0 &&
- (!is_open_message || !config_.negotiated));
+ RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP && writable_ &&
+ config_.id >= 0 && (!is_open_message || !config_.negotiated));
cricket::SendDataParams send_params;
send_params.sid = config_.id;