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}
This commit is contained in:
nisse 2017-01-12 05:15:36 -08:00 committed by Commit bot
parent 59e99b76da
commit ede5da4960
88 changed files with 686 additions and 631 deletions

View File

@ -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 @@ bool DataChannel::Send(const DataBuffer& buffer) {
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 @@ bool DataChannel::Send(const DataBuffer& buffer) {
}
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::RemotePeerRequestClose() {
}
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::SetSctpSid(int sid) {
}
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::OnTransportChannelDestroyed() {
}
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 @@ void DataChannel::OnDataReceived(const cricket::ReceiveDataParams& params,
}
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 @@ void DataChannel::OnDataReceived(const cricket::ReceiveDataParams& params,
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 @@ void DataChannel::SendQueuedDataMessages() {
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 @@ void DataChannel::QueueControlMessage(const rtc::CopyOnWriteBuffer& buffer) {
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;

View File

@ -81,12 +81,12 @@ DtmfSender::DtmfSender(AudioTrackInterface* track,
provider_(provider),
duration_(kDtmfDefaultDurationMs),
inter_tone_gap_(kDtmfDefaultGapMs) {
ASSERT(track_ != NULL);
ASSERT(signaling_thread_ != NULL);
RTC_DCHECK(track_ != NULL);
RTC_DCHECK(signaling_thread_ != NULL);
// TODO(deadbeef): Once we can use shared_ptr and weak_ptr,
// do that instead of relying on a "destroyed" signal.
if (provider_) {
ASSERT(provider_->GetOnDestroyedSignal() != NULL);
RTC_DCHECK(provider_->GetOnDestroyedSignal() != NULL);
provider_->GetOnDestroyedSignal()->connect(
this, &DtmfSender::OnProviderDestroyed);
}
@ -105,7 +105,7 @@ void DtmfSender::UnregisterObserver() {
}
bool DtmfSender::CanInsertDtmf() {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
if (!provider_) {
return false;
}
@ -114,7 +114,7 @@ bool DtmfSender::CanInsertDtmf() {
bool DtmfSender::InsertDtmf(const std::string& tones, int duration,
int inter_tone_gap) {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
if (duration > kDtmfMaxDurationMs ||
duration < kDtmfMinDurationMs ||
@ -172,7 +172,7 @@ void DtmfSender::OnMessage(rtc::Message* msg) {
}
void DtmfSender::DoInsertDtmf() {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
// Get the first DTMF tone from the tone buffer. Unrecognized characters will
// be ignored and skipped.

View File

@ -9,6 +9,7 @@
*/
#include "webrtc/api/mediastream.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
namespace webrtc {
@ -81,7 +82,7 @@ bool MediaStream::AddTrack(TrackVector* tracks, Track* track) {
template <typename TrackVector>
bool MediaStream::RemoveTrack(TrackVector* tracks,
MediaStreamTrackInterface* track) {
ASSERT(tracks != NULL);
RTC_DCHECK(tracks != NULL);
if (!track)
return false;
typename TrackVector::iterator it = FindTrack(tracks, track->id());

View File

@ -14,6 +14,7 @@
#include <list>
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
namespace webrtc {
@ -26,7 +27,7 @@ class Notifier : public T {
}
virtual void RegisterObserver(ObserverInterface* observer) {
ASSERT(observer != NULL);
RTC_DCHECK(observer != NULL);
observers_.push_back(observer);
}

View File

@ -2072,7 +2072,7 @@ void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label,
stream->RemoveTrack(video_track);
}
} else {
ASSERT(false && "Invalid media type");
RTC_NOTREACHED() << "Invalid media type";
}
}

View File

@ -25,6 +25,7 @@
#include "webrtc/api/videosourceproxy.h"
#include "webrtc/api/videotrack.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
#include "webrtc/media/engine/webrtcmediaengine.h"
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
@ -129,7 +130,7 @@ PeerConnectionFactory::PeerConnectionFactory(
RTC_DCHECK(signaling_thread);
// TODO: Currently there is no way creating an external adm in
// libjingle source tree. So we can 't currently assert if this is NULL.
// ASSERT(default_adm != NULL);
// RTC_DCHECK(default_adm != NULL);
}
PeerConnectionFactory::~PeerConnectionFactory() {
@ -345,7 +346,7 @@ rtc::Thread* PeerConnectionFactory::network_thread() {
}
cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
return cricket::WebRtcMediaEngineFactory::Create(
default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(),
video_decoder_factory_.get(), external_audio_mixer_);

View File

@ -12,6 +12,7 @@
#include "webrtc/api/localaudiosource.h"
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/trace_event.h"
@ -39,7 +40,7 @@ void LocalAudioSinkAdapter::OnData(const void* audio_data,
void LocalAudioSinkAdapter::SetSink(cricket::AudioSource::Sink* sink) {
rtc::CritScope lock(&lock_);
ASSERT(!sink || !sink_);
RTC_DCHECK(!sink || !sink_);
sink_ = sink;
}

View File

@ -16,6 +16,7 @@
#include "webrtc/api/mediaconstraintsinterface.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
using cricket::CaptureState;
using webrtc::MediaConstraintsInterface;
@ -50,7 +51,7 @@ MediaSourceInterface::SourceState GetReadyState(cricket::CaptureState state) {
case cricket::CS_STOPPED:
return MediaSourceInterface::kEnded;
default:
ASSERT(false && "GetReadyState unknown state");
RTC_NOTREACHED() << "GetReadyState unknown state";
}
return MediaSourceInterface::kEnded;
}
@ -101,7 +102,7 @@ bool NewFormatWithConstraints(
const cricket::VideoFormat& format_in,
bool mandatory,
cricket::VideoFormat* format_out) {
ASSERT(format_out != NULL);
RTC_DCHECK(format_out != NULL);
*format_out = format_in;
if (constraint.key == MediaConstraintsInterface::kMinWidth) {
@ -215,7 +216,7 @@ std::vector<cricket::VideoFormat> FilterFormats(
// default and still meets the contraints.
const cricket::VideoFormat& GetBestCaptureFormat(
const std::vector<cricket::VideoFormat>& formats) {
ASSERT(formats.size() > 0);
RTC_DCHECK(formats.size() > 0);
int default_area = kDefaultFormat.width * kDefaultFormat.height;

View File

@ -581,8 +581,8 @@ void CreateTracksFromSsrcInfos(const SsrcInfoVec& ssrc_infos,
const std::string& msid_stream_id,
const std::string& msid_track_id,
StreamParamsVec* tracks) {
ASSERT(tracks != NULL);
ASSERT(msid_stream_id.empty() == msid_track_id.empty());
RTC_DCHECK(tracks != NULL);
RTC_DCHECK(msid_stream_id.empty() == msid_track_id.empty());
for (SsrcInfoVec::const_iterator ssrc_info = ssrc_infos.begin();
ssrc_info != ssrc_infos.end(); ++ssrc_info) {
if (ssrc_info->cname.empty()) {
@ -831,7 +831,7 @@ std::string SdpSerialize(const JsepSessionDescription& jdesc,
std::string group_line = kAttrGroup;
const cricket::ContentGroup* group =
desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
ASSERT(group != NULL);
RTC_DCHECK(group != NULL);
const cricket::ContentNames& content_names = group->content_names();
for (cricket::ContentNames::const_iterator it = content_names.begin();
it != content_names.end(); ++it) {
@ -888,9 +888,9 @@ std::string SdpSerializeCandidate(const cricket::Candidate& candidate) {
BuildCandidate(candidates, true, &message);
// From WebRTC draft section 4.8.1.1 candidate-attribute will be
// just candidate:<candidate> not a=candidate:<blah>CRLF
ASSERT(message.find("a=") == 0);
RTC_DCHECK(message.find("a=") == 0);
message.erase(0, 2);
ASSERT(message.find(kLineBreak) == message.size() - 2);
RTC_DCHECK(message.find(kLineBreak) == message.size() - 2);
message.resize(message.size() - 2);
return message;
}
@ -938,7 +938,7 @@ bool SdpDeserialize(const std::string& message,
bool SdpDeserializeCandidate(const std::string& message,
JsepIceCandidate* jcandidate,
SdpParseError* error) {
ASSERT(jcandidate != NULL);
RTC_DCHECK(jcandidate != NULL);
Candidate candidate;
if (!ParseCandidate(message, &candidate, error, true)) {
return false;
@ -951,7 +951,7 @@ bool SdpDeserializeCandidate(const std::string& transport_name,
const std::string& message,
cricket::Candidate* candidate,
SdpParseError* error) {
ASSERT(candidate != nullptr);
RTC_DCHECK(candidate != nullptr);
if (!ParseCandidate(message, candidate, error, true)) {
return false;
}
@ -961,7 +961,7 @@ bool SdpDeserializeCandidate(const std::string& transport_name,
bool ParseCandidate(const std::string& message, Candidate* candidate,
SdpParseError* error, bool is_raw) {
ASSERT(candidate != NULL);
RTC_DCHECK(candidate != NULL);
// Get the first line from |message|.
std::string first_line = message;
@ -1215,7 +1215,7 @@ void BuildMediaDescription(const ContentInfo* content_info,
const std::vector<Candidate>& candidates,
bool unified_plan_sdp,
std::string* message) {
ASSERT(message != NULL);
RTC_DCHECK(message != NULL);
if (content_info == NULL || message == NULL) {
return;
}
@ -1227,7 +1227,7 @@ void BuildMediaDescription(const ContentInfo* content_info,
const MediaContentDescription* media_desc =
static_cast<const MediaContentDescription*>(
content_info->description);
ASSERT(media_desc != NULL);
RTC_DCHECK(media_desc != NULL);
int sctp_port = cricket::kSctpDefaultPort;
@ -1719,8 +1719,8 @@ bool GetParameter(const std::string& name,
void BuildRtpMap(const MediaContentDescription* media_desc,
const MediaType media_type,
std::string* message) {
ASSERT(message != NULL);
ASSERT(media_desc != NULL);
RTC_DCHECK(message != NULL);
RTC_DCHECK(media_desc != NULL);
std::ostringstream os;
if (media_type == cricket::MEDIA_TYPE_VIDEO) {
const VideoContentDescription* video_desc =
@ -1749,7 +1749,7 @@ void BuildRtpMap(const MediaContentDescription* media_desc,
for (std::vector<cricket::AudioCodec>::const_iterator it =
audio_desc->codecs().begin();
it != audio_desc->codecs().end(); ++it) {
ASSERT(!it->name.empty());
RTC_DCHECK(!it->name.empty());
// RFC 4566
// a=rtpmap:<payload type> <encoding name>/<clock rate>
// [/<encodingparameters>]
@ -1781,7 +1781,7 @@ void BuildRtpMap(const MediaContentDescription* media_desc,
if (GetMinValue(maxptimes, &min_maxptime)) {
AddAttributeLine(kCodecParamMaxPTime, min_maxptime, message);
}
ASSERT(min_maxptime > max_minptime);
RTC_DCHECK(min_maxptime > max_minptime);
// Populate the ptime attribute with the smallest ptime or the largest
// minptime, whichever is the largest, for all codecs under the same m-line.
int ptime = INT_MAX;
@ -2057,7 +2057,7 @@ bool ParseSessionDescription(const std::string& message, size_t* pos,
bool ParseGroupAttribute(const std::string& line,
cricket::SessionDescription* desc,
SdpParseError* error) {
ASSERT(desc != NULL);
RTC_DCHECK(desc != NULL);
// RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00
// a=group:BUNDLE video voice
@ -2285,7 +2285,7 @@ bool ParseMediaDescription(const std::string& message,
cricket::SessionDescription* desc,
std::vector<JsepIceCandidate*>* candidates,
SdpParseError* error) {
ASSERT(desc != NULL);
RTC_DCHECK(desc != NULL);
std::string line;
int mline_index = -1;
@ -2589,9 +2589,9 @@ bool ParseContent(const std::string& message,
TransportDescription* transport,
std::vector<JsepIceCandidate*>* candidates,
SdpParseError* error) {
ASSERT(media_desc != NULL);
ASSERT(content_name != NULL);
ASSERT(transport != NULL);
RTC_DCHECK(media_desc != NULL);
RTC_DCHECK(content_name != NULL);
RTC_DCHECK(transport != NULL);
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
MaybeCreateStaticPayloadAudioCodecs(
@ -2846,10 +2846,10 @@ bool ParseContent(const std::string& message,
// Update the candidates with the media level "ice-pwd" and "ice-ufrag".
for (Candidates::iterator it = candidates_orig.begin();
it != candidates_orig.end(); ++it) {
ASSERT((*it).username().empty() ||
(*it).username() == transport->ice_ufrag);
RTC_DCHECK((*it).username().empty() ||
(*it).username() == transport->ice_ufrag);
(*it).set_username(transport->ice_ufrag);
ASSERT((*it).password().empty());
RTC_DCHECK((*it).password().empty());
(*it).set_password(transport->ice_pwd);
candidates->push_back(
new JsepIceCandidate(mline_id, mline_index, *it));
@ -2859,7 +2859,7 @@ bool ParseContent(const std::string& message,
bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos,
SdpParseError* error) {
ASSERT(ssrc_infos != NULL);
RTC_DCHECK(ssrc_infos != NULL);
// RFC 5576
// a=ssrc:<ssrc-id> <attribute>
// a=ssrc:<ssrc-id> <attribute>:<value>
@ -2938,7 +2938,7 @@ bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos,
bool ParseSsrcGroupAttribute(const std::string& line,
SsrcGroupVec* ssrc_groups,
SdpParseError* error) {
ASSERT(ssrc_groups != NULL);
RTC_DCHECK(ssrc_groups != NULL);
// RFC 5576
// a=ssrc-group:<semantics> <ssrc-id> ...
std::vector<std::string> fields;

View File

@ -258,7 +258,7 @@ static bool GetAudioSsrcByTrackId(const SessionDescription* session_description,
static bool GetTrackIdBySsrc(const SessionDescription* session_description,
uint32_t ssrc,
std::string* track_id) {
ASSERT(track_id != NULL);
RTC_DCHECK(track_id != NULL);
const cricket::ContentInfo* audio_info =
cricket::GetFirstAudioContent(session_description);
@ -502,7 +502,7 @@ WebRtcSession::WebRtcSession(
}
WebRtcSession::~WebRtcSession() {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
// Destroy video_channel_ first since it may have a pointer to the
// voice_channel_.
if (video_channel_) {
@ -698,7 +698,7 @@ void WebRtcSession::CreateAnswer(
bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
std::string* err_desc) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
// Takes the ownership of |desc| regardless of the result.
std::unique_ptr<SessionDescriptionInterface> desc_temp(desc);
@ -752,7 +752,7 @@ bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
std::string* err_desc) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
// Takes the ownership of |desc| regardless of the result.
std::unique_ptr<SessionDescriptionInterface> desc_temp(desc);
@ -853,7 +853,7 @@ void WebRtcSession::LogState(State old_state, State new_state) {
}
void WebRtcSession::SetState(State state) {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
if (state != state_) {
LogState(state_, state);
state_ = state;
@ -862,7 +862,7 @@ void WebRtcSession::SetState(State state) {
}
void WebRtcSession::SetError(Error error, const std::string& error_desc) {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
if (error != error_) {
error_ = error;
error_desc_ = error_desc;
@ -872,11 +872,11 @@ void WebRtcSession::SetError(Error error, const std::string& error_desc) {
bool WebRtcSession::UpdateSessionState(
Action action, cricket::ContentSource source,
std::string* err_desc) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
// If there's already a pending error then no state transition should happen.
// But all call-sites should be verifying this before calling us!
ASSERT(error() == ERROR_NONE);
RTC_DCHECK(error() == ERROR_NONE);
std::string td_err;
if (action == kOffer) {
if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) {
@ -944,7 +944,7 @@ WebRtcSession::Action WebRtcSession::GetAction(const std::string& type) {
} else if (type == SessionDescriptionInterface::kAnswer) {
return WebRtcSession::kAnswer;
}
ASSERT(false && "unknown action type");
RTC_NOTREACHED() << "unknown action type";
return WebRtcSession::kOffer;
}
@ -1240,7 +1240,7 @@ std::string WebRtcSession::BadStateErrMsg(State state) {
}
bool WebRtcSession::CanInsertDtmf(const std::string& track_id) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
if (!voice_channel_) {
LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists.";
return false;
@ -1259,7 +1259,7 @@ bool WebRtcSession::CanInsertDtmf(const std::string& track_id) {
bool WebRtcSession::InsertDtmf(const std::string& track_id,
int code, int duration) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
if (!voice_channel_) {
LOG(LS_ERROR) << "InsertDtmf: No audio channel exists.";
return false;
@ -1364,7 +1364,7 @@ bool WebRtcSession::ReadyToSendData() const {
}
std::unique_ptr<SessionStats> WebRtcSession::GetStats_s() {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
ChannelNamePairs channel_name_pairs;
if (voice_channel()) {
channel_name_pairs.voice = rtc::Optional<ChannelNamePair>(ChannelNamePair(
@ -1524,7 +1524,7 @@ void WebRtcSession::SetIceConnectionReceiving(bool receiving) {
void WebRtcSession::OnTransportControllerCandidatesGathered(
const std::string& transport_name,
const cricket::Candidates& candidates) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
int sdp_mline_index;
if (!GetLocalCandidateMediaIndex(transport_name, &sdp_mline_index)) {
LOG(LS_ERROR) << "OnTransportControllerCandidatesGathered: content name "
@ -1547,7 +1547,7 @@ void WebRtcSession::OnTransportControllerCandidatesGathered(
void WebRtcSession::OnTransportControllerCandidatesRemoved(
const std::vector<cricket::Candidate>& candidates) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
// Sanity check.
for (const cricket::Candidate& candidate : candidates) {
if (candidate.transport_name().empty()) {
@ -1872,7 +1872,7 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content,
std::unique_ptr<SessionStats> WebRtcSession::GetStats_n(
const ChannelNamePairs& channel_name_pairs) {
ASSERT(network_thread()->IsCurrent());
RTC_DCHECK(network_thread()->IsCurrent());
std::unique_ptr<SessionStats> session_stats(new SessionStats());
for (const auto channel_name_pair : { &channel_name_pairs.voice,
&channel_name_pairs.video,
@ -2001,13 +2001,13 @@ bool WebRtcSession::ValidateBundleSettings(const SessionDescription* desc) {
const cricket::ContentGroup* bundle_group =
desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
ASSERT(bundle_group != NULL);
RTC_DCHECK(bundle_group != NULL);
const cricket::ContentInfos& contents = desc->contents();
for (cricket::ContentInfos::const_iterator citer = contents.begin();
citer != contents.end(); ++citer) {
const cricket::ContentInfo* content = (&*citer);
ASSERT(content != NULL);
RTC_DCHECK(content != NULL);
if (bundle_group->HasContentName(content->name) &&
!content->rejected && content->type == cricket::NS_JINGLE_RTP) {
if (!HasRtcpMuxEnabled(content))
@ -2160,7 +2160,7 @@ bool WebRtcSession::SrtpRequired() const {
void WebRtcSession::OnTransportControllerGatheringState(
cricket::IceGatheringState state) {
ASSERT(signaling_thread()->IsCurrent());
RTC_DCHECK(signaling_thread()->IsCurrent());
if (state == cricket::kIceGatheringGathering) {
if (ice_observer_) {
ice_observer_->OnIceGatheringChange(

View File

@ -201,7 +201,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
}
WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
// Fail any requests that were asked for before identity generation completed.
FailPendingRequests(kFailedDueToSessionShutdown);
@ -249,8 +249,8 @@ void WebRtcSessionDescriptionFactory::CreateOffer(
if (certificate_request_state_ == CERTIFICATE_WAITING) {
create_session_description_requests_.push(request);
} else {
ASSERT(certificate_request_state_ == CERTIFICATE_SUCCEEDED ||
certificate_request_state_ == CERTIFICATE_NOT_NEEDED);
RTC_DCHECK(certificate_request_state_ == CERTIFICATE_SUCCEEDED ||
certificate_request_state_ == CERTIFICATE_NOT_NEEDED);
InternalCreateOffer(request);
}
}
@ -291,8 +291,8 @@ void WebRtcSessionDescriptionFactory::CreateAnswer(
if (certificate_request_state_ == CERTIFICATE_WAITING) {
create_session_description_requests_.push(request);
} else {
ASSERT(certificate_request_state_ == CERTIFICATE_SUCCEEDED ||
certificate_request_state_ == CERTIFICATE_NOT_NEEDED);
RTC_DCHECK(certificate_request_state_ == CERTIFICATE_SUCCEEDED ||
certificate_request_state_ == CERTIFICATE_NOT_NEEDED);
InternalCreateAnswer(request);
}
}
@ -364,7 +364,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
// Just increase the version number by one each time when a new offer
// is created regardless if it's identical to the previous one or not.
// The |session_version_| is a uint64_t, the wrap around should not happen.
ASSERT(session_version_ + 1 > session_version_);
RTC_DCHECK(session_version_ + 1 > session_version_);
JsepSessionDescription* offer(new JsepSessionDescription(
JsepSessionDescription::kOffer));
if (!offer->Initialize(desc, session_id_,
@ -422,7 +422,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
// unrelated to the version number in the o line of the offer.
// Get a new version number by increasing the |session_version_answer_|.
// The |session_version_| is a uint64_t, the wrap around should not happen.
ASSERT(session_version_ + 1 > session_version_);
RTC_DCHECK(session_version_ + 1 > session_version_);
JsepSessionDescription* answer(new JsepSessionDescription(
JsepSessionDescription::kAnswer));
if (!answer->Initialize(desc, session_id_,
@ -448,7 +448,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
void WebRtcSessionDescriptionFactory::FailPendingRequests(
const std::string& reason) {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
while (!create_session_description_requests_.empty()) {
const CreateSessionDescriptionRequest& request =
create_session_description_requests_.front();
@ -478,7 +478,7 @@ void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionSucceeded(
}
void WebRtcSessionDescriptionFactory::OnCertificateRequestFailed() {
ASSERT(signaling_thread_->IsCurrent());
RTC_DCHECK(signaling_thread_->IsCurrent());
LOG(LS_ERROR) << "Asynchronous certificate generation request failed.";
certificate_request_state_ = CERTIFICATE_FAILED;

View File

@ -16,6 +16,7 @@
#import <Foundation/NSProcessInfo.h>
#include <string.h>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/pathutils.h"
@ -36,7 +37,7 @@ static char* copyString(NSString* s) {
char* AppleDataDirectory() {
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
ASSERT([paths count] == 1);
RTC_DCHECK([paths count] == 1);
return copyString([paths objectAtIndex:0]);
}

View File

@ -9,6 +9,7 @@
*/
#include "webrtc/base/asyncsocket.h"
#include "webrtc/base/checks.h"
namespace rtc {
@ -27,7 +28,7 @@ AsyncSocketAdapter::~AsyncSocketAdapter() {
}
void AsyncSocketAdapter::Attach(AsyncSocket* socket) {
ASSERT(!socket_);
RTC_DCHECK(!socket_);
socket_ = socket;
if (socket_) {
socket_->SignalConnectEvent.connect(this,

View File

@ -9,6 +9,7 @@
*/
#include "webrtc/base/asyncudpsocket.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
namespace rtc {
@ -99,7 +100,7 @@ void AsyncUDPSocket::SetError(int error) {
}
void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
ASSERT(socket_.get() == socket);
RTC_DCHECK(socket_.get() == socket);
SocketAddress remote_addr;
int64_t timestamp;

View File

@ -66,7 +66,7 @@ DiskCache::DiskCache() : max_cache_(0), total_size_(0), total_accessors_(0) {
}
DiskCache::~DiskCache() {
ASSERT(0 == total_accessors_);
RTC_DCHECK(0 == total_accessors_);
}
bool DiskCache::Initialize(const std::string& folder, size_t size) {
@ -75,7 +75,7 @@ bool DiskCache::Initialize(const std::string& folder, size_t size) {
folder_ = folder;
max_cache_ = size;
ASSERT(0 == total_size_);
RTC_DCHECK(0 == total_size_);
if (!InitializeEntries())
return false;
@ -121,7 +121,7 @@ StreamInterface* DiskCache::WriteResource(const std::string& id, size_t index) {
size_t previous_size = 0;
std::string filename(IdToFilename(id, index));
FileStream::GetSize(filename, &previous_size);
ASSERT(previous_size <= entry->size);
RTC_DCHECK(previous_size <= entry->size);
if (previous_size > entry->size) {
previous_size = entry->size;
}
@ -221,7 +221,7 @@ bool DiskCache::CheckLimit() {
for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) {
cache_size += it->second.size;
}
ASSERT(cache_size == total_size_);
RTC_DCHECK(cache_size == total_size_);
#endif
// TODO: Replace this with a non-brain-dead algorithm for clearing out the
@ -259,7 +259,7 @@ std::string DiskCache::IdToFilename(const std::string& id, size_t index) const {
char* buffer = new char[buffer_size];
encode(buffer, buffer_size, id.data(), id.length(),
unsafe_filename_characters(), '%');
// TODO: ASSERT(strlen(buffer) < FileSystem::MaxBasenameLength());
// TODO(nisse): RTC_DCHECK(strlen(buffer) < FileSystem::MaxBasenameLength());
#else // !TRANSPARENT_CACHE_NAMES
// We might want to just use a hash of the filename at some point, both for
// obfuscation, and to avoid both filename length and escaping issues.

View File

@ -343,8 +343,8 @@ public:
}
HttpBase* Disconnect(HttpError error) {
ASSERT(NULL != base_);
ASSERT(NULL != base_->doc_stream_);
RTC_DCHECK(NULL != base_);
RTC_DCHECK(NULL != base_->doc_stream_);
HttpBase* base = base_;
base_->doc_stream_ = NULL;
base_ = NULL;
@ -366,7 +366,7 @@ HttpBase::HttpBase() : mode_(HM_NONE), data_(NULL), notify_(NULL),
}
HttpBase::~HttpBase() {
ASSERT(HM_NONE == mode_);
RTC_DCHECK(HM_NONE == mode_);
}
bool
@ -388,7 +388,7 @@ HttpBase::attach(StreamInterface* stream) {
StreamInterface*
HttpBase::detach() {
ASSERT(HM_NONE == mode_);
RTC_DCHECK(HM_NONE == mode_);
if (mode_ != HM_NONE) {
return NULL;
}
@ -402,7 +402,7 @@ HttpBase::detach() {
void
HttpBase::send(HttpData* data) {
ASSERT(HM_NONE == mode_);
RTC_DCHECK(HM_NONE == mode_);
if (mode_ != HM_NONE) {
return;
} else if (!isConnected()) {
@ -439,7 +439,7 @@ HttpBase::send(HttpData* data) {
void
HttpBase::recv(HttpData* data) {
ASSERT(HM_NONE == mode_);
RTC_DCHECK(HM_NONE == mode_);
if (mode_ != HM_NONE) {
return;
} else if (!isConnected()) {
@ -497,8 +497,8 @@ HttpError HttpBase::HandleStreamClose(int error) {
}
bool HttpBase::DoReceiveLoop(HttpError* error) {
ASSERT(HM_RECV == mode_);
ASSERT(NULL != error);
RTC_DCHECK(HM_RECV == mode_);
RTC_DCHECK(NULL != error);
// Do to the latency between receiving read notifications from
// pseudotcpchannel, we rely on repeated calls to read in order to acheive
@ -522,7 +522,7 @@ bool HttpBase::DoReceiveLoop(HttpError* error) {
&read, &read_error);
switch (read_result) {
case SR_SUCCESS:
ASSERT(len_ + read <= sizeof(buffer_));
RTC_DCHECK(len_ + read <= sizeof(buffer_));
len_ += read;
break;
case SR_BLOCK:
@ -557,7 +557,7 @@ bool HttpBase::DoReceiveLoop(HttpError* error) {
size_t processed;
ProcessResult process_result = Process(buffer_, len_, &processed,
error);
ASSERT(processed <= len_);
RTC_DCHECK(processed <= len_);
len_ -= processed;
memmove(buffer_, buffer_ + processed, len_);
switch (process_result) {
@ -588,14 +588,14 @@ HttpBase::read_and_process_data() {
void
HttpBase::flush_data() {
ASSERT(HM_SEND == mode_);
RTC_DCHECK(HM_SEND == mode_);
// When send_required is true, no more buffering can occur without a network
// write.
bool send_required = (len_ >= sizeof(buffer_));
while (true) {
ASSERT(len_ <= sizeof(buffer_));
RTC_DCHECK(len_ <= sizeof(buffer_));
// HTTP is inherently sensitive to round trip latency, since a frequent use
// case is for small requests and responses to be sent back and forth, and
@ -633,7 +633,7 @@ HttpBase::flush_data() {
sizeof(buffer_) - reserve,
&read, &error);
if (result == SR_SUCCESS) {
ASSERT(reserve + read <= sizeof(buffer_));
RTC_DCHECK(reserve + read <= sizeof(buffer_));
if (chunk_data_) {
// Prepend the chunk length in hex.
// Note: sprintfn appends a null terminator, which is why we can't
@ -653,7 +653,7 @@ HttpBase::flush_data() {
if (chunk_data_) {
// Append the empty chunk and empty trailers, then turn off
// chunking.
ASSERT(len_ + 5 <= sizeof(buffer_));
RTC_DCHECK(len_ + 5 <= sizeof(buffer_));
memcpy(buffer_ + len_, "0\r\n\r\n", 5);
len_ += 5;
chunk_data_ = false;
@ -686,7 +686,7 @@ HttpBase::flush_data() {
int error;
StreamResult result = http_stream_->Write(buffer_, len_, &written, &error);
if (result == SR_SUCCESS) {
ASSERT(written <= len_);
RTC_DCHECK(written <= len_);
len_ -= written;
memmove(buffer_, buffer_ + written, len_);
send_required = false;
@ -696,7 +696,7 @@ HttpBase::flush_data() {
return;
}
} else {
ASSERT(result == SR_ERROR);
RTC_DCHECK(result == SR_ERROR);
LOG_F(LS_ERROR) << "error";
OnHttpStreamEvent(http_stream_, SE_CLOSE, error);
return;
@ -708,7 +708,7 @@ HttpBase::flush_data() {
bool
HttpBase::queue_headers() {
ASSERT(HM_SEND == mode_);
RTC_DCHECK(HM_SEND == mode_);
while (header_ != data_->end()) {
size_t len = sprintfn(buffer_ + len_, sizeof(buffer_) - len_,
"%.*s: %.*s\r\n",
@ -732,7 +732,7 @@ HttpBase::queue_headers() {
void
HttpBase::do_complete(HttpError err) {
ASSERT(mode_ != HM_NONE);
RTC_DCHECK(mode_ != HM_NONE);
HttpMode mode = mode_;
mode_ = HM_NONE;
if (data_ && data_->document) {
@ -740,7 +740,8 @@ HttpBase::do_complete(HttpError err) {
}
data_ = NULL;
if ((HM_RECV == mode) && doc_stream_) {
ASSERT(HE_NONE != err); // We should have Disconnected doc_stream_ already.
RTC_DCHECK(HE_NONE !=
err); // We should have Disconnected doc_stream_ already.
DocumentStream* ds = doc_stream_;
ds->Disconnect(err);
ds->SignalEvent(ds, SE_CLOSE, err);
@ -756,7 +757,7 @@ HttpBase::do_complete(HttpError err) {
void
HttpBase::OnHttpStreamEvent(StreamInterface* stream, int events, int error) {
ASSERT(stream == http_stream_);
RTC_DCHECK(stream == http_stream_);
if ((events & SE_OPEN) && (mode_ == HM_CONNECT)) {
do_complete();
return;
@ -791,7 +792,7 @@ HttpBase::OnHttpStreamEvent(StreamInterface* stream, int events, int error) {
void
HttpBase::OnDocumentEvent(StreamInterface* stream, int events, int error) {
ASSERT(stream == data_->document.get());
RTC_DCHECK(stream == data_->document.get());
if ((events & SE_WRITE) && (mode_ == HM_RECV)) {
read_and_process_data();
return;
@ -834,7 +835,7 @@ HttpBase::ProcessHeaderComplete(bool chunked, size_t& data_size,
if (notify_) {
*error = notify_->onHttpHeaderComplete(chunked, data_size);
// The request must not be aborted as a result of this callback.
ASSERT(NULL != data_);
RTC_DCHECK(NULL != data_);
}
if ((HE_NONE == *error) && data_->document) {
data_->document->SignalEvent.connect(this, &HttpBase::OnDocumentEvent);

View File

@ -37,7 +37,7 @@ const size_t kCacheBody = 1;
// Convert decimal string to integer
bool HttpStringToUInt(const std::string& str, size_t* val) {
ASSERT(NULL != val);
RTC_DCHECK(NULL != val);
char* eos = NULL;
*val = strtoul(str.c_str(), &eos, 10);
return (*eos == '\0');
@ -341,7 +341,7 @@ void HttpClient::start() {
return;
}
ASSERT(!IsCacheActive());
RTC_DCHECK(!IsCacheActive());
if (request().hasHeader(HH_TRANSFER_ENCODING, NULL)) {
// Exact size must be known on the client. Instead of using chunked
@ -403,7 +403,7 @@ void HttpClient::connect() {
}
StreamInterface* stream = pool_->RequestConnectedStream(server_, &stream_err);
if (stream == NULL) {
ASSERT(0 != stream_err);
RTC_DCHECK(0 != stream_err);
LOG(LS_ERROR) << "RequestConnectedStream error: " << stream_err;
onHttpComplete(HM_CONNECT, HE_CONNECT_FAILED);
} else {
@ -453,8 +453,8 @@ bool HttpClient::ShouldRedirect(std::string* location) const {
}
bool HttpClient::BeginCacheFile() {
ASSERT(NULL != cache_);
ASSERT(CS_READY == cache_state_);
RTC_DCHECK(NULL != cache_);
RTC_DCHECK(CS_READY == cache_state_);
std::string id = GetCacheID(request());
CacheLock lock(cache_, id, true);
@ -520,8 +520,8 @@ void HttpClient::CompleteCacheFile() {
}
bool HttpClient::CheckCache() {
ASSERT(NULL != cache_);
ASSERT(CS_READY == cache_state_);
RTC_DCHECK(NULL != cache_);
RTC_DCHECK(CS_READY == cache_state_);
std::string id = GetCacheID(request());
if (!cache_->HasResource(id)) {
@ -615,7 +615,7 @@ HttpError HttpClient::ReadCacheBody(const std::string& id) {
}
bool HttpClient::PrepareValidate() {
ASSERT(CS_READY == cache_state_);
RTC_DCHECK(CS_READY == cache_state_);
// At this point, request() contains the pending request, and response()
// contains the cached response headers. Reformat the request to validate
// the cached content.
@ -637,7 +637,7 @@ bool HttpClient::PrepareValidate() {
}
HttpError HttpClient::CompleteValidate() {
ASSERT(CS_VALIDATING == cache_state_);
RTC_DCHECK(CS_VALIDATING == cache_state_);
std::string id = GetCacheID(request());
@ -686,7 +686,7 @@ HttpError HttpClient::onHttpHeaderComplete(bool chunked, size_t& data_size) {
// Continue processing response as normal
}
ASSERT(!IsCacheActive());
RTC_DCHECK(!IsCacheActive());
if ((request().verb == HV_HEAD) || !HttpCodeHasBody(response().scode)) {
// HEAD requests and certain response codes contain no body
data_size = 0;
@ -757,7 +757,7 @@ void HttpClient::onHttpComplete(HttpMode mode, HttpError err) {
request().document.reset();
} else if (request().document && !request().document->Rewind()) {
// Unable to replay the request document.
ASSERT(REDIRECT_ALWAYS == redirect_action_);
RTC_DCHECK(REDIRECT_ALWAYS == redirect_action_);
err = HE_STREAM;
}
if (err == HE_NONE) {

View File

@ -13,6 +13,7 @@
#include <memory>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/httpbase.h"
#include "webrtc/base/nethelpers.h"
@ -89,7 +90,10 @@ public:
void set_uri_form(UriForm form) { uri_form_ = form; }
UriForm uri_form() const { return uri_form_; }
void set_cache(DiskCache* cache) { ASSERT(!IsCacheActive()); cache_ = cache; }
void set_cache(DiskCache* cache) {
RTC_DCHECK(!IsCacheActive());
cache_ = cache;
}
bool cache_enabled() const { return (NULL != cache_); }
// reset clears the server, request, and response structures. It will also

View File

@ -12,6 +12,7 @@
#define WEBRTC_BASE_HTTPCOMMON_INL_H__
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/httpcommon.h"
@ -72,7 +73,7 @@ void Url<CTYPE>::do_set_full_path(const CTYPE* val, size_t len) {
// TODO: consider failing in this case.
path_.assign(1, static_cast<CTYPE>('/'));
} else {
ASSERT(val[0] == static_cast<CTYPE>('/'));
RTC_DCHECK(val[0] == static_cast<CTYPE>('/'));
path_.assign(val, path_length);
}
query_.assign(query, len - path_length);

View File

@ -23,6 +23,7 @@
#include "webrtc/base/arraysize.h"
#include "webrtc/base/base64.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/cryptstring.h"
#include "webrtc/base/httpcommon-inl.h"
@ -341,7 +342,7 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
};
ASSERT(NULL != seconds);
RTC_DCHECK(NULL != seconds);
struct tm tval;
memset(&tval, 0, sizeof(tval));
char month[4], zone[6];
@ -481,9 +482,9 @@ void HttpData::setContent(const std::string& content_type,
void HttpData::setDocumentAndLength(StreamInterface* document) {
// TODO: Consider calling Rewind() here?
ASSERT(!hasHeader(HH_CONTENT_LENGTH, NULL));
ASSERT(!hasHeader(HH_TRANSFER_ENCODING, NULL));
ASSERT(document != NULL);
RTC_DCHECK(!hasHeader(HH_CONTENT_LENGTH, NULL));
RTC_DCHECK(!hasHeader(HH_TRANSFER_ENCODING, NULL));
RTC_DCHECK(document != NULL);
this->document.reset(document);
size_t content_length = 0;
if (this->document->GetAvailable(&content_length)) {
@ -515,7 +516,7 @@ HttpRequestData::copy(const HttpRequestData& src) {
size_t
HttpRequestData::formatLeader(char* buffer, size_t size) const {
ASSERT(path.find(' ') == std::string::npos);
RTC_DCHECK(path.find(' ') == std::string::npos);
return sprintfn(buffer, size, "%s %.*s HTTP/%s", ToString(verb), path.size(),
path.data(), ToString(version));
}
@ -838,7 +839,7 @@ HttpAuthResult HttpAuthenticate(
std::string dig_response = MD5(HA1 + ":" + middle + ":" + HA2);
#if TEST_DIGEST
ASSERT(strcmp(dig_response.c_str(), DIGEST_RESPONSE) == 0);
RTC_DCHECK(strcmp(dig_response.c_str(), DIGEST_RESPONSE) == 0);
#endif
std::stringstream ss;
@ -1020,7 +1021,7 @@ HttpAuthResult HttpAuthenticate(
return HAR_IGNORE;
}
ASSERT(!context);
RTC_DCHECK(!context);
context = neg = new NegotiateAuthContext(auth_method, cred, ctx);
neg->specified_credentials = specify_credentials;
neg->steps = steps;

View File

@ -45,7 +45,7 @@ HttpServer::~HttpServer() {
int
HttpServer::HandleConnection(StreamInterface* stream) {
int connection_id = next_connection_id_++;
ASSERT(connection_id != HTTP_INVALID_CONNECTION_ID);
RTC_DCHECK(connection_id != HTTP_INVALID_CONNECTION_ID);
Connection* connection = new Connection(connection_id, this);
connections_.insert(ConnectionMap::value_type(connection_id, connection));
connection->BeginProcess(stream);
@ -147,7 +147,7 @@ HttpServer::Connection::EndProcess() {
void
HttpServer::Connection::Respond(HttpServerTransaction* transaction) {
ASSERT(current_ == NULL);
RTC_DCHECK(current_ == NULL);
current_ = transaction;
if (current_->response.begin() == current_->response.end()) {
current_->response.set_error(HC_INTERNAL_SERVER_ERROR);
@ -179,7 +179,7 @@ HttpServer::Connection::onHttpHeaderComplete(bool chunked, size_t& data_size) {
if (data_size == SIZE_UNKNOWN) {
data_size = 0;
}
ASSERT(current_ != NULL);
RTC_DCHECK(current_ != NULL);
bool custom_document = false;
server_->SignalHttpRequestHeader(server_, current_, &custom_document);
if (!custom_document) {
@ -191,7 +191,7 @@ HttpServer::Connection::onHttpHeaderComplete(bool chunked, size_t& data_size) {
void
HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) {
if (mode == HM_SEND) {
ASSERT(current_ != NULL);
RTC_DCHECK(current_ != NULL);
signalling_ = true;
server_->SignalHttpRequestComplete(server_, current_, err);
signalling_ = false;
@ -205,7 +205,7 @@ HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) {
} else if (mode == HM_CONNECT) {
base_.recv(&current_->request);
} else if (mode == HM_RECV) {
ASSERT(current_ != NULL);
RTC_DCHECK(current_ != NULL);
// TODO: do we need this?
//request_.document_->rewind();
HttpServerTransaction* transaction = current_;
@ -268,7 +268,7 @@ void HttpListenServer::StopListening() {
}
void HttpListenServer::OnReadEvent(AsyncSocket* socket) {
ASSERT(socket == listener_.get());
RTC_DCHECK(socket == listener_.get());
AsyncSocket* incoming = listener_->Accept(NULL);
if (incoming) {
StreamInterface* stream = new SocketStream(incoming);

View File

@ -73,7 +73,7 @@ void DecodeFourChar(UInt32 fc, std::string* out) {
}
static bool GetOSVersion(int* major, int* minor, int* bugfix) {
ASSERT(major && minor && bugfix);
RTC_DCHECK(major && minor && bugfix);
struct utsname uname_info;
if (uname(&uname_info) != 0)
return false;

View File

@ -30,7 +30,7 @@ class SCOPED_LOCKABLE DebugNonReentrantCritScope {
EXCLUSIVE_LOCK_FUNCTION(cs)
: cs_(cs), locked_(locked) {
cs_->Enter();
ASSERT(!*locked_);
RTC_DCHECK(!*locked_);
*locked_ = true;
}
@ -329,7 +329,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
}
// If this was a dispose message, delete it and skip it.
if (MQID_DISPOSE == pmsg->message_id) {
ASSERT(NULL == pmsg->phandler);
RTC_DCHECK(NULL == pmsg->phandler);
delete pmsg->pdata;
*pmsg = Message();
continue;

View File

@ -10,6 +10,7 @@
#include <memory>
#include "webrtc/base/checks.h"
#include "webrtc/base/natsocketfactory.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/logging.h"
@ -87,7 +88,7 @@ class NATProxyServerSocket : public AsyncProxyServerSocket {
}
int family = data[1];
ASSERT(family == AF_INET || family == AF_INET6);
RTC_DCHECK(family == AF_INET || family == AF_INET6);
if ((family == AF_INET && *len < kNATEncodedIPv4AddressSize) ||
(family == AF_INET6 && *len < kNATEncodedIPv6AddressSize)) {
return;
@ -169,7 +170,7 @@ void NATServer::OnInternalUDPPacket(
Translate(route);
iter = int_map_->find(route);
}
ASSERT(iter != int_map_->end());
RTC_DCHECK(iter != int_map_->end());
// Allow the destination to send packets back to the source.
iter->second->WhitelistInsert(dest_addr);
@ -186,7 +187,7 @@ void NATServer::OnExternalUDPPacket(
// Find the translation for this addresses.
ExternalMap::iterator iter = ext_map_->find(local_addr);
ASSERT(iter != ext_map_->end());
RTC_DCHECK(iter != ext_map_->end());
// Allow the NAT to reject this packet.
if (ShouldFilterOut(iter->second, remote_addr)) {

View File

@ -11,6 +11,7 @@
#include "webrtc/base/natsocketfactory.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/virtualsocketserver.h"
@ -29,12 +30,12 @@ size_t PackAddressForNAT(char* buf, size_t buf_size,
// Writes the port.
*(reinterpret_cast<uint16_t*>(&buf[2])) = HostToNetwork16(remote_addr.port());
if (family == AF_INET) {
ASSERT(buf_size >= kNATEncodedIPv4AddressSize);
RTC_DCHECK(buf_size >= kNATEncodedIPv4AddressSize);
in_addr v4addr = ip.ipv4_address();
memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4);
return kNATEncodedIPv4AddressSize;
} else if (family == AF_INET6) {
ASSERT(buf_size >= kNATEncodedIPv6AddressSize);
RTC_DCHECK(buf_size >= kNATEncodedIPv6AddressSize);
in6_addr v6addr = ip.ipv6_address();
memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4);
return kNATEncodedIPv6AddressSize;
@ -47,8 +48,8 @@ size_t PackAddressForNAT(char* buf, size_t buf_size,
// data where the original packet starts).
size_t UnpackAddressFromNAT(const char* buf, size_t buf_size,
SocketAddress* remote_addr) {
ASSERT(buf_size >= 8);
ASSERT(buf[0] == 0);
RTC_DCHECK(buf_size >= 8);
RTC_DCHECK(buf[0] == 0);
int family = buf[1];
uint16_t port =
NetworkToHost16(*(reinterpret_cast<const uint16_t*>(&buf[2])));
@ -57,7 +58,7 @@ size_t UnpackAddressFromNAT(const char* buf, size_t buf_size,
*remote_addr = SocketAddress(IPAddress(*v4addr), port);
return kNATEncodedIPv4AddressSize;
} else if (family == AF_INET6) {
ASSERT(buf_size >= 20);
RTC_DCHECK(buf_size >= 20);
const in6_addr* v6addr = reinterpret_cast<const in6_addr*>(&buf[4]);
*remote_addr = SocketAddress(IPAddress(*v6addr), port);
return kNATEncodedIPv6AddressSize;
@ -129,14 +130,14 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
}
int Send(const void* data, size_t size) override {
ASSERT(connected_);
RTC_DCHECK(connected_);
return SendTo(data, size, remote_addr_);
}
int SendTo(const void* data,
size_t size,
const SocketAddress& addr) override {
ASSERT(!connected_ || addr == remote_addr_);
RTC_DCHECK(!connected_ || addr == remote_addr_);
if (server_addr_.IsNil() || type_ == SOCK_STREAM) {
return socket_->SendTo(data, size, addr);
}
@ -149,7 +150,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
memcpy(buf.get() + addrlength, data, size);
int result = socket_->SendTo(buf.get(), encoded_size, server_addr_);
if (result >= 0) {
ASSERT(result == static_cast<int>(encoded_size));
RTC_DCHECK(result == static_cast<int>(encoded_size));
result = result - static_cast<int>(addrlength);
}
return result;
@ -175,12 +176,12 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
// Read the packet from the socket.
int result = socket_->RecvFrom(buf_, size_, &remote_addr, timestamp);
if (result >= 0) {
ASSERT(remote_addr == server_addr_);
RTC_DCHECK(remote_addr == server_addr_);
// TODO: we need better framing so we know how many bytes we can
// return before we need to read the next address. For UDP, this will be
// fine as long as the reader always reads everything in the packet.
ASSERT((size_t)result < size_);
RTC_DCHECK((size_t)result < size_);
// Decode the wire packet into the actual results.
SocketAddress real_remote_addr;
@ -235,7 +236,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
void OnConnectEvent(AsyncSocket* socket) {
// If we're NATed, we need to send a message with the real addr to use.
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
if (server_addr_.IsNil()) {
connected_ = true;
SignalConnectEvent(this);
@ -245,7 +246,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
}
void OnReadEvent(AsyncSocket* socket) {
// If we're NATed, we need to process the connect reply.
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
if (type_ == SOCK_STREAM && !server_addr_.IsNil() && !connected_) {
HandleConnectReply();
} else {
@ -253,11 +254,11 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
}
}
void OnWriteEvent(AsyncSocket* socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalWriteEvent(this);
}
void OnCloseEvent(AsyncSocket* socket, int error) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalCloseEvent(this, error);
}

View File

@ -266,7 +266,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
if (current_list.ips[0].family() == AF_INET) {
stats->ipv4_network_count++;
} else {
ASSERT(current_list.ips[0].family() == AF_INET6);
RTC_DCHECK(current_list.ips[0].family() == AF_INET6);
stats->ipv6_network_count++;
}
}
@ -302,7 +302,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
if (!existing_net->active()) {
*changed = true;
}
ASSERT(net->active());
RTC_DCHECK(net->active());
if (existing_net != net) {
delete net;
}
@ -740,7 +740,7 @@ void BasicNetworkManager::StartUpdating() {
}
void BasicNetworkManager::StopUpdating() {
ASSERT(Thread::Current() == thread_);
RTC_DCHECK(Thread::Current() == thread_);
if (!start_count_)
return;
@ -826,9 +826,9 @@ AdapterType BasicNetworkManager::GetAdapterTypeFromName(
}
IPAddress BasicNetworkManager::QueryDefaultLocalAddress(int family) const {
ASSERT(thread_ == Thread::Current());
ASSERT(thread_->socketserver() != nullptr);
ASSERT(family == AF_INET || family == AF_INET6);
RTC_DCHECK(thread_ == Thread::Current());
RTC_DCHECK(thread_->socketserver() != nullptr);
RTC_DCHECK(family == AF_INET || family == AF_INET6);
std::unique_ptr<AsyncSocket> socket(
thread_->socketserver()->CreateAsyncSocket(family, SOCK_DGRAM));
@ -855,7 +855,7 @@ void BasicNetworkManager::UpdateNetworksOnce() {
if (!start_count_)
return;
ASSERT(Thread::Current() == thread_);
RTC_DCHECK(Thread::Current() == thread_);
NetworkList list;
if (!CreateNetworks(false, &list)) {

View File

@ -10,6 +10,7 @@
#include "webrtc/base/networkmonitor.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
namespace {
@ -35,7 +36,7 @@ void NetworkMonitorBase::OnNetworksChanged() {
}
void NetworkMonitorBase::OnMessage(Message* msg) {
ASSERT(msg->message_id == UPDATE_NETWORKS_MESSAGE);
RTC_DCHECK(msg->message_id == UPDATE_NETWORKS_MESSAGE);
SignalNetworksChanged();
}

View File

@ -28,6 +28,7 @@
#include <openssl/x509v3.h>
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/openssl.h"
@ -289,7 +290,7 @@ OpenSSLAdapter::~OpenSSLAdapter() {
void
OpenSSLAdapter::SetMode(SSLMode mode) {
ASSERT(state_ == SSL_NONE);
RTC_DCHECK(state_ == SSL_NONE);
ssl_mode_ = mode;
}
@ -318,7 +319,7 @@ OpenSSLAdapter::StartSSL(const char* hostname, bool restartable) {
int
OpenSSLAdapter::BeginSSL() {
LOG(LS_INFO) << "BeginSSL: " << ssl_host_name_;
ASSERT(state_ == SSL_CONNECTING);
RTC_DCHECK(state_ == SSL_CONNECTING);
int err = 0;
BIO* bio = NULL;
@ -370,7 +371,7 @@ ssl_error:
int
OpenSSLAdapter::ContinueSSL() {
ASSERT(state_ == SSL_CONNECTING);
RTC_DCHECK(state_ == SSL_CONNECTING);
// Clear the DTLS timer
Thread::Current()->Clear(this, MSG_TIMEOUT);
@ -627,7 +628,7 @@ void
OpenSSLAdapter::OnConnectEvent(AsyncSocket* socket) {
LOG(LS_INFO) << "OpenSSLAdapter::OnConnectEvent";
if (state_ != SSL_WAIT) {
ASSERT(state_ == SSL_NONE);
RTC_DCHECK(state_ == SSL_NONE);
AsyncSocketAdapter::OnConnectEvent(socket);
return;
}

View File

@ -12,6 +12,7 @@
#include "webrtc/base/openssldigest.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/openssl.h"
@ -51,7 +52,7 @@ size_t OpenSSLDigest::Finish(void* buf, size_t len) {
unsigned int md_len;
EVP_DigestFinal_ex(&ctx_, static_cast<unsigned char*>(buf), &md_len);
EVP_DigestInit_ex(&ctx_, md_, NULL); // prepare for future Update()s
ASSERT(md_len == Size());
RTC_DCHECK(md_len == Size());
return md_len;
}
@ -75,15 +76,15 @@ bool OpenSSLDigest::GetDigestEVP(const std::string& algorithm,
}
// Can't happen
ASSERT(EVP_MD_size(md) >= 16);
RTC_DCHECK(EVP_MD_size(md) >= 16);
*mdp = md;
return true;
}
bool OpenSSLDigest::GetDigestName(const EVP_MD* md,
std::string* algorithm) {
ASSERT(md != NULL);
ASSERT(algorithm != NULL);
RTC_DCHECK(md != NULL);
RTC_DCHECK(algorithm != NULL);
int md_type = EVP_MD_type(md);
if (md_type == NID_md5) {
@ -119,4 +120,3 @@ bool OpenSSLDigest::GetDigestSize(const std::string& algorithm,
} // namespace rtc
#endif // HAVE_OPENSSL_SSL_H

View File

@ -443,7 +443,7 @@ void OpenSSLCertificate::ToDER(Buffer* der_buffer) const {
}
void OpenSSLCertificate::AddReference() const {
ASSERT(x509_ != NULL);
RTC_DCHECK(x509_ != NULL);
#if defined(OPENSSL_IS_BORINGSSL)
X509_up_ref(x509_);
#else
@ -478,8 +478,8 @@ int64_t OpenSSLCertificate::CertificateExpirationTime() const {
OpenSSLIdentity::OpenSSLIdentity(OpenSSLKeyPair* key_pair,
OpenSSLCertificate* certificate)
: key_pair_(key_pair), certificate_(certificate) {
ASSERT(key_pair != NULL);
ASSERT(certificate != NULL);
RTC_DCHECK(key_pair != NULL);
RTC_DCHECK(certificate != NULL);
}
OpenSSLIdentity::~OpenSSLIdentity() = default;

View File

@ -17,6 +17,7 @@
#include <memory>
#include <string>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/sslidentity.h"
@ -30,7 +31,7 @@ namespace rtc {
class OpenSSLKeyPair {
public:
explicit OpenSSLKeyPair(EVP_PKEY* pkey) : pkey_(pkey) {
ASSERT(pkey_ != NULL);
RTC_DCHECK(pkey_ != NULL);
}
static OpenSSLKeyPair* Generate(const KeyParams& key_params);

View File

@ -312,7 +312,7 @@ int PhysicalSocket::Send(const void* pv, size_t cb) {
UpdateLastError();
MaybeRemapSendError();
// We have seen minidumps where this may be false.
ASSERT(sent <= static_cast<int>(cb));
RTC_DCHECK(sent <= static_cast<int>(cb));
if ((sent > 0 && sent < static_cast<int>(cb)) ||
(sent < 0 && IsBlockingError(GetError()))) {
enabled_events_ |= DE_WRITE;
@ -337,7 +337,7 @@ int PhysicalSocket::SendTo(const void* buffer,
UpdateLastError();
MaybeRemapSendError();
// We have seen minidumps where this may be false.
ASSERT(sent <= static_cast<int>(length));
RTC_DCHECK(sent <= static_cast<int>(length));
if ((sent > 0 && sent < static_cast<int>(length)) ||
(sent < 0 && IsBlockingError(GetError()))) {
enabled_events_ |= DE_WRITE;
@ -499,7 +499,7 @@ int PhysicalSocket::EstimateMTU(uint16_t* mtu) {
return err;
}
ASSERT((0 <= value) && (value <= 65536));
RTC_DCHECK((0 <= value) && (value <= 65536));
*mtu = value;
return 0;
#elif defined(__native_client__)
@ -625,7 +625,7 @@ SocketDispatcher::~SocketDispatcher() {
}
bool SocketDispatcher::Initialize() {
ASSERT(s_ != INVALID_SOCKET);
RTC_DCHECK(s_ != INVALID_SOCKET);
// Must be a non-blocking
#if defined(WEBRTC_WIN)
u_long argp = 1;
@ -890,7 +890,7 @@ class PosixSignalHandler {
// Returns true if the given signal number is set.
bool IsSignalSet(int signum) const {
ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
RTC_DCHECK(signum < static_cast<int>(arraysize(received_signal_)));
if (signum < static_cast<int>(arraysize(received_signal_))) {
return received_signal_[signum];
} else {
@ -900,7 +900,7 @@ class PosixSignalHandler {
// Clears the given signal number.
void ClearSignal(int signum) {
ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
RTC_DCHECK(signum < static_cast<int>(arraysize(received_signal_)));
if (signum < static_cast<int>(arraysize(received_signal_))) {
received_signal_[signum] = false;
}
@ -1145,7 +1145,7 @@ PhysicalSocketServer::~PhysicalSocketServer() {
signal_dispatcher_.reset();
#endif
delete signal_wakeup_;
ASSERT(dispatchers_.empty());
RTC_DCHECK(dispatchers_.empty());
}
void PhysicalSocketServer::WakeUp() {
@ -1271,7 +1271,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
for (size_t i = 0; i < dispatchers_.size(); ++i) {
// Query dispatchers for read and write wait state
Dispatcher *pdispatcher = dispatchers_[i];
ASSERT(pdispatcher);
RTC_DCHECK(pdispatcher);
if (!process_io && (pdispatcher != signal_wakeup_))
continue;
int fd = pdispatcher->GetDescriptor();
@ -1372,7 +1372,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
ptvWait->tv_sec = tvStop.tv_sec - tvT.tv_sec;
ptvWait->tv_usec = tvStop.tv_usec - tvT.tv_usec;
if (ptvWait->tv_usec < 0) {
ASSERT(ptvWait->tv_sec > 0);
RTC_DCHECK(ptvWait->tv_sec > 0);
ptvWait->tv_usec += 1000000;
ptvWait->tv_sec -= 1;
}
@ -1476,7 +1476,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
event_owners.push_back(disp);
}
}
ASSERT(iterators_.back() == &i);
RTC_DCHECK(iterators_.back() == &i);
iterators_.pop_back();
}
@ -1579,9 +1579,9 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
}
}
}
ASSERT(iterators_.back() == &end);
RTC_DCHECK(iterators_.back() == &end);
iterators_.pop_back();
ASSERT(iterators_.back() == &i);
RTC_DCHECK(iterators_.back() == &i);
iterators_.pop_back();
}

View File

@ -33,6 +33,7 @@
#include <memory>
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/httpcommon.h"
#include "webrtc/base/httpcommon-inl.h"
@ -410,7 +411,7 @@ bool GetFirefoxProfilePath(Pathname* path) {
}
bool GetDefaultFirefoxProfile(Pathname* profile_path) {
ASSERT(NULL != profile_path);
RTC_DCHECK(NULL != profile_path);
Pathname path;
if (!GetFirefoxProfilePath(&path)) {
return false;

View File

@ -11,6 +11,8 @@
#include "webrtc/base/proxyserver.h"
#include <algorithm>
#include "webrtc/base/checks.h"
#include "webrtc/base/socketfactory.h"
namespace rtc {
@ -22,8 +24,8 @@ ProxyServer::ProxyServer(
: ext_factory_(ext_factory), ext_ip_(ext_ip.ipaddr(), 0), // strip off port
server_socket_(int_factory->CreateAsyncSocket(int_addr.family(),
SOCK_STREAM)) {
ASSERT(server_socket_.get() != NULL);
ASSERT(int_addr.family() == AF_INET || int_addr.family() == AF_INET6);
RTC_DCHECK(server_socket_.get() != NULL);
RTC_DCHECK(int_addr.family() == AF_INET || int_addr.family() == AF_INET6);
server_socket_->Bind(int_addr);
server_socket_->Listen(5);
server_socket_->SignalReadEvent.connect(this, &ProxyServer::OnAcceptEvent);
@ -41,7 +43,7 @@ SocketAddress ProxyServer::GetServerAddress() {
}
void ProxyServer::OnAcceptEvent(AsyncSocket* socket) {
ASSERT(socket != NULL && socket == server_socket_.get());
RTC_DCHECK(socket != NULL && socket == server_socket_.get());
AsyncSocket* int_socket = socket->Accept(NULL);
AsyncProxyServerSocket* wrapped_socket = WrapSocket(int_socket);
AsyncSocket* ext_socket = ext_factory_->CreateAsyncSocket(ext_ip_.family(),
@ -82,7 +84,7 @@ ProxyBinding::~ProxyBinding() = default;
void ProxyBinding::OnConnectRequest(AsyncProxyServerSocket* socket,
const SocketAddress& addr) {
ASSERT(!connected_ && ext_socket_.get() != NULL);
RTC_DCHECK(!connected_ && ext_socket_.get() != NULL);
ext_socket_->Connect(addr);
// TODO: handle errors here
}
@ -101,7 +103,7 @@ void ProxyBinding::OnInternalClose(AsyncSocket* socket, int err) {
}
void ProxyBinding::OnExternalConnect(AsyncSocket* socket) {
ASSERT(socket != NULL);
RTC_DCHECK(socket != NULL);
connected_ = true;
int_socket_->SendConnectResult(0, socket->GetRemoteAddress());
}
@ -124,7 +126,7 @@ void ProxyBinding::OnExternalClose(AsyncSocket* socket, int err) {
void ProxyBinding::Read(AsyncSocket* socket, FifoBuffer* buffer) {
// Only read if the buffer is empty.
ASSERT(socket != NULL);
RTC_DCHECK(socket != NULL);
size_t size;
int read;
if (buffer->GetBuffered(&size) && size == 0) {
@ -135,7 +137,7 @@ void ProxyBinding::Read(AsyncSocket* socket, FifoBuffer* buffer) {
}
void ProxyBinding::Write(AsyncSocket* socket, FifoBuffer* buffer) {
ASSERT(socket != NULL);
RTC_DCHECK(socket != NULL);
size_t size;
int written;
const void* p = buffer->GetReadData(&size);

View File

@ -14,6 +14,7 @@
#include <algorithm>
#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/constructormagic.h"
@ -97,8 +98,8 @@ class RollingAccumulator {
T ComputeMax() const {
if (max_stale_) {
ASSERT(count_ > 0 &&
"It shouldn't be possible for max_stale_ && count_ == 0");
RTC_DCHECK(count_ > 0) <<
"It shouldn't be possible for max_stale_ && count_ == 0";
max_ = samples_[next_index_];
for (size_t i = 1u; i < count_; i++) {
max_ = std::max(max_, samples_[(next_index_ + i) % max_count()]);
@ -110,8 +111,8 @@ class RollingAccumulator {
T ComputeMin() const {
if (min_stale_) {
ASSERT(count_ > 0 &&
"It shouldn't be possible for min_stale_ && count_ == 0");
RTC_DCHECK(count_ > 0) <<
"It shouldn't be possible for min_stale_ && count_ == 0";
min_ = samples_[next_index_];
for (size_t i = 1u; i < count_; i++) {
min_ = std::min(min_, samples_[(next_index_ + i) % max_count()]);

View File

@ -30,19 +30,19 @@ SignalThread::SignalThread(bool use_socket_server)
}
SignalThread::~SignalThread() {
ASSERT(refcount_ == 0);
RTC_DCHECK(refcount_ == 0);
}
bool SignalThread::SetName(const std::string& name, const void* obj) {
EnterExit ee(this);
ASSERT(main_->IsCurrent());
ASSERT(kInit == state_);
RTC_DCHECK(main_->IsCurrent());
RTC_DCHECK(kInit == state_);
return worker_.SetName(name, obj);
}
void SignalThread::Start() {
EnterExit ee(this);
ASSERT(main_->IsCurrent());
RTC_DCHECK(main_->IsCurrent());
if (kInit == state_ || kComplete == state_) {
state_ = kRunning;
OnWorkStart();
@ -54,7 +54,7 @@ void SignalThread::Start() {
void SignalThread::Destroy(bool wait) {
EnterExit ee(this);
ASSERT(main_->IsCurrent());
RTC_DCHECK(main_->IsCurrent());
if ((kInit == state_) || (kComplete == state_)) {
refcount_--;
} else if (kRunning == state_ || kReleasing == state_) {
@ -77,7 +77,7 @@ void SignalThread::Destroy(bool wait) {
void SignalThread::Release() {
EnterExit ee(this);
ASSERT(main_->IsCurrent());
RTC_DCHECK(main_->IsCurrent());
if (kComplete == state_) {
refcount_--;
} else if (kRunning == state_) {
@ -90,14 +90,14 @@ void SignalThread::Release() {
bool SignalThread::ContinueWork() {
EnterExit ee(this);
ASSERT(worker_.IsCurrent());
RTC_DCHECK(worker_.IsCurrent());
return worker_.ProcessMessages(0);
}
void SignalThread::OnMessage(Message *msg) {
EnterExit ee(this);
if (ST_MSG_WORKER_DONE == msg->message_id) {
ASSERT(main_->IsCurrent());
RTC_DCHECK(main_->IsCurrent());
OnWorkDone();
bool do_delete = false;
if (kRunning == state_) {

View File

@ -13,6 +13,7 @@
#include <string>
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/nullsocketserver.h"
#include "webrtc/base/sigslot.h"
@ -124,7 +125,7 @@ class SignalThread
t_->cs_.Enter();
// If refcount_ is zero then the object has already been deleted and we
// will be double-deleting it in ~EnterExit()! (shouldn't happen)
ASSERT(t_->refcount_ != 0);
RTC_DCHECK(t_->refcount_ != 0);
++t_->refcount_;
}
~EnterExit() UNLOCK_FUNCTION() {

View File

@ -97,7 +97,7 @@ void BufferedReadAdapter::BufferInput(bool on) {
}
void BufferedReadAdapter::OnReadEvent(AsyncSocket * socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
if (!buffering_) {
AsyncSocketAdapter::OnReadEvent(socket);
@ -184,7 +184,7 @@ int AsyncSSLSocket::Connect(const SocketAddress& addr) {
}
void AsyncSSLSocket::OnConnectEvent(AsyncSocket * socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
// TODO: we could buffer output too...
VERIFY(sizeof(kSslClientHello) ==
DirectSend(kSslClientHello, sizeof(kSslClientHello)));
@ -234,7 +234,7 @@ void AsyncSSLServerSocket::ProcessInput(char* data, size_t* len) {
*len -= sizeof(kSslClientHello);
// Clients should not send more data until the handshake is completed.
ASSERT(*len == 0);
RTC_DCHECK(*len == 0);
// Send a server hello back to the client.
DirectSend(kSslServerHello, sizeof(kSslServerHello));
@ -557,7 +557,7 @@ void AsyncSocksProxySocket::OnConnectEvent(AsyncSocket* socket) {
}
void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) {
ASSERT(state_ < SS_TUNNEL);
RTC_DCHECK(state_ < SS_TUNNEL);
ByteBufferReader response(data, *len);
@ -715,7 +715,7 @@ AsyncSocksProxyServerSocket::AsyncSocksProxyServerSocket(AsyncSocket* socket)
void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) {
// TODO: See if the whole message has arrived
ASSERT(state_ < SS_CONNECT_PENDING);
RTC_DCHECK(state_ < SS_CONNECT_PENDING);
ByteBufferReader response(data, *len);
if (state_ == SS_HELLO) {

View File

@ -28,6 +28,7 @@
#include <sstream>
#include "webrtc/base/byteorder.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nethelpers.h"
@ -120,7 +121,7 @@ void SocketAddress::SetResolvedIP(const IPAddress& ip) {
}
void SocketAddress::SetPort(int port) {
ASSERT((0 <= port) && (port < 65536));
RTC_DCHECK((0 <= port) && (port < 65536));
port_ = static_cast<uint16_t>(port);
}

View File

@ -151,14 +151,14 @@ ReuseSocketPool::ReuseSocketPool(SocketFactory* factory)
}
ReuseSocketPool::~ReuseSocketPool() {
ASSERT(!checked_out_);
RTC_DCHECK(!checked_out_);
delete stream_;
}
StreamInterface*
ReuseSocketPool::RequestConnectedStream(const SocketAddress& remote, int* err) {
// Only one socket can be used from this "pool" at a time
ASSERT(!checked_out_);
RTC_DCHECK(!checked_out_);
if (!stream_) {
LOG_F(LS_VERBOSE) << "Creating new socket";
int family = remote.family();
@ -198,8 +198,8 @@ ReuseSocketPool::RequestConnectedStream(const SocketAddress& remote, int* err) {
void
ReuseSocketPool::ReturnConnectedStream(StreamInterface* stream) {
ASSERT(stream == stream_);
ASSERT(checked_out_);
RTC_DCHECK(stream == stream_);
RTC_DCHECK(checked_out_);
checked_out_ = false;
// Until the socket is reused, monitor it to determine if it closes.
stream_->SignalEvent.connect(this, &ReuseSocketPool::OnStreamEvent);
@ -207,8 +207,8 @@ ReuseSocketPool::ReturnConnectedStream(StreamInterface* stream) {
void
ReuseSocketPool::OnStreamEvent(StreamInterface* stream, int events, int err) {
ASSERT(stream == stream_);
ASSERT(!checked_out_);
RTC_DCHECK(stream == stream_);
RTC_DCHECK(!checked_out_);
// If the stream was written to and then immediately returned to us then
// we may get a writable notification for it, which we should ignore.
@ -220,7 +220,7 @@ ReuseSocketPool::OnStreamEvent(StreamInterface* stream, int events, int err) {
// If the peer sent data, we can't process it, so drop the connection.
// If the socket has closed, clean it up.
// In either case, we'll reconnect it the next time it is used.
ASSERT(0 != (events & (SE_READ|SE_CLOSE)));
RTC_DCHECK(0 != (events & (SE_READ | SE_CLOSE)));
if (0 != (events & SE_CLOSE)) {
LOG_F(LS_VERBOSE) << "Connection closed with error: " << err;
} else {
@ -250,7 +250,7 @@ LoggingPoolAdapter::~LoggingPoolAdapter() {
StreamInterface* LoggingPoolAdapter::RequestConnectedStream(
const SocketAddress& remote, int* err) {
if (StreamInterface* stream = pool_->RequestConnectedStream(remote, err)) {
ASSERT(SS_CLOSED != stream->GetState());
RTC_DCHECK(SS_CLOSED != stream->GetState());
std::stringstream ss;
ss << label_ << "(0x" << std::setfill('0') << std::hex << std::setw(8)
<< stream << ")";

View File

@ -10,6 +10,8 @@
#include "webrtc/base/socketstream.h"
#include "webrtc/base/checks.h"
namespace rtc {
SocketStream::SocketStream(AsyncSocket* socket) : socket_(NULL) {
@ -45,7 +47,7 @@ AsyncSocket* SocketStream::Detach() {
}
StreamState SocketStream::GetState() const {
ASSERT(socket_ != NULL);
RTC_DCHECK(socket_ != NULL);
switch (socket_->GetState()) {
case Socket::CS_CONNECTED:
return SS_OPEN;
@ -59,7 +61,7 @@ StreamState SocketStream::GetState() const {
StreamResult SocketStream::Read(void* buffer, size_t buffer_len,
size_t* read, int* error) {
ASSERT(socket_ != NULL);
RTC_DCHECK(socket_ != NULL);
int result = socket_->Recv(buffer, buffer_len, nullptr);
if (result < 0) {
if (socket_->IsBlocking())
@ -78,7 +80,7 @@ StreamResult SocketStream::Read(void* buffer, size_t buffer_len,
StreamResult SocketStream::Write(const void* data, size_t data_len,
size_t* written, int* error) {
ASSERT(socket_ != NULL);
RTC_DCHECK(socket_ != NULL);
int result = socket_->Send(data, data_len);
if (result < 0) {
if (socket_->IsBlocking())
@ -93,27 +95,27 @@ StreamResult SocketStream::Write(const void* data, size_t data_len,
}
void SocketStream::Close() {
ASSERT(socket_ != NULL);
RTC_DCHECK(socket_ != NULL);
socket_->Close();
}
void SocketStream::OnConnectEvent(AsyncSocket* socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalEvent(this, SE_OPEN | SE_READ | SE_WRITE, 0);
}
void SocketStream::OnReadEvent(AsyncSocket* socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalEvent(this, SE_READ, 0);
}
void SocketStream::OnWriteEvent(AsyncSocket* socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalEvent(this, SE_WRITE, 0);
}
void SocketStream::OnCloseEvent(AsyncSocket* socket, int err) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
SignalEvent(this, SE_CLOSE, err);
}

View File

@ -200,7 +200,7 @@ std::string SSLIdentity::DerToPem(const std::string& pem_type,
}
SSLCertChain::SSLCertChain(const std::vector<SSLCertificate*>& certs) {
ASSERT(!certs.empty());
RTC_DCHECK(!certs.empty());
certs_.resize(certs.size());
std::transform(certs.begin(), certs.end(), certs_.begin(), DupCert);
}

View File

@ -11,6 +11,7 @@
#include <memory>
#include "webrtc/base/autodetectproxy.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/httpcommon.h"
#include "webrtc/base/httpcommon-inl.h"
#include "webrtc/base/socketadapters.h"
@ -37,8 +38,8 @@ class ProxySocketAdapter : public AsyncSocketAdapter {
}
int Connect(const SocketAddress& addr) override {
ASSERT(NULL == detect_);
ASSERT(NULL == socket_);
RTC_DCHECK(NULL == detect_);
RTC_DCHECK(NULL == socket_);
remote_ = addr;
if (remote_.IsAnyIP() && remote_.hostname().empty()) {
LOG_F(LS_ERROR) << "Empty address";
@ -78,7 +79,7 @@ class ProxySocketAdapter : public AsyncSocketAdapter {
private:
// AutoDetectProxy Slots
void OnProxyDetectionComplete(SignalThread* thread) {
ASSERT(detect_ == thread);
RTC_DCHECK(detect_ == thread);
Attach(factory_->CreateProxySocket(detect_->proxy(), family_, type_));
detect_->Release();
detect_ = NULL;

View File

@ -434,7 +434,7 @@ bool FileStream::SetPosition(size_t position) {
}
bool FileStream::GetPosition(size_t* position) const {
ASSERT(NULL != position);
RTC_DCHECK(NULL != position);
if (!file_)
return false;
long result = ftell(file_);
@ -446,7 +446,7 @@ bool FileStream::GetPosition(size_t* position) const {
}
bool FileStream::GetSize(size_t* size) const {
ASSERT(NULL != size);
RTC_DCHECK(NULL != size);
if (!file_)
return false;
struct stat file_stats;
@ -458,7 +458,7 @@ bool FileStream::GetSize(size_t* size) const {
}
bool FileStream::GetAvailable(size_t* size) const {
ASSERT(NULL != size);
RTC_DCHECK(NULL != size);
if (!GetSize(size))
return false;
long result = ftell(file_);
@ -563,7 +563,7 @@ StreamResult MemoryStreamBase::Write(const void* buffer, size_t bytes,
if (SR_SUCCESS != result) {
return result;
}
ASSERT(buffer_length_ >= new_buffer_length);
RTC_DCHECK(buffer_length_ >= new_buffer_length);
available = buffer_length_ - seek_position_;
}
@ -808,7 +808,7 @@ const void* FifoBuffer::GetReadData(size_t* size) {
void FifoBuffer::ConsumeReadData(size_t size) {
CritScope cs(&crit_);
ASSERT(size <= data_length_);
RTC_DCHECK(size <= data_length_);
const bool was_writable = data_length_ < buffer_length_;
read_position_ = (read_position_ + size) % buffer_length_;
data_length_ -= size;
@ -838,7 +838,7 @@ void* FifoBuffer::GetWriteBuffer(size_t* size) {
void FifoBuffer::ConsumeWriteBuffer(size_t size) {
CritScope cs(&crit_);
ASSERT(size <= buffer_length_ - data_length_);
RTC_DCHECK(size <= buffer_length_ - data_length_);
const bool was_readable = (data_length_ > 0);
data_length_ += size;
if (!was_readable && size > 0) {
@ -1070,7 +1070,7 @@ StreamResult Flow(StreamInterface* source,
char* buffer, size_t buffer_len,
StreamInterface* sink,
size_t* data_len /* = NULL */) {
ASSERT(buffer_len > 0);
RTC_DCHECK(buffer_len > 0);
StreamResult result;
size_t count, read_pos, write_pos;

View File

@ -9,6 +9,7 @@
*/
#include "webrtc/base/task.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/taskrunner.h"
@ -31,14 +32,16 @@ Task::Task(TaskParent *parent)
unique_id_ = unique_id_seed_++;
// sanity check that we didn't roll-over our id seed
ASSERT(unique_id_ < unique_id_seed_);
RTC_DCHECK(unique_id_ < unique_id_seed_);
}
Task::~Task() {
// Is this task being deleted in the correct manner?
ASSERT(!done_ || GetRunner()->is_ok_to_delete(this));
ASSERT(state_ == STATE_INIT || done_);
ASSERT(state_ == STATE_INIT || blocked_);
#if RTC_DCHECK_IS_ON
RTC_DCHECK(!done_ || GetRunner()->is_ok_to_delete(this));
#endif
RTC_DCHECK(state_ == STATE_INIT || done_);
RTC_DCHECK(state_ == STATE_INIT || blocked_);
// If the task is being deleted without being done, it
// means that it hasn't been removed from its parent.
@ -68,11 +71,11 @@ void Task::Start() {
void Task::Step() {
if (done_) {
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
// we do not know how !blocked_ happens when done_ - should be impossible.
// But it causes problems, so in retail build, we force blocked_, and
// under debug we assert.
ASSERT(blocked_);
RTC_DCHECK(blocked_);
#else
blocked_ = true;
#endif
@ -88,9 +91,9 @@ void Task::Step() {
// SignalDone();
Stop();
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
// verify that stop removed this from its parent
ASSERT(!parent()->IsChildTask(this));
RTC_DCHECK(!parent()->IsChildTask(this));
#endif
return;
}
@ -125,9 +128,9 @@ void Task::Step() {
// SignalDone();
Stop();
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
// verify that stop removed this from its parent
ASSERT(!parent()->IsChildTask(this));
RTC_DCHECK(!parent()->IsChildTask(this));
#endif
blocked_ = true;
}
@ -150,9 +153,9 @@ void Task::Abort(bool nowake) {
// "done_" is set before calling "Stop()" to ensure that this code
// doesn't execute more than once (recursively) for the same task.
Stop();
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
// verify that stop removed this from its parent
ASSERT(!parent()->IsChildTask(this));
RTC_DCHECK(!parent()->IsChildTask(this));
#endif
if (!nowake) {
// WakeTasks to self-delete.

View File

@ -12,6 +12,7 @@
#include "webrtc/base/taskparent.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/task.h"
#include "webrtc/base/taskrunner.h"
@ -20,8 +21,8 @@ namespace rtc {
TaskParent::TaskParent(Task* derived_instance, TaskParent *parent)
: parent_(parent) {
ASSERT(derived_instance != NULL);
ASSERT(parent != NULL);
RTC_DCHECK(derived_instance != NULL);
RTC_DCHECK(parent != NULL);
runner_ = parent->GetRunner();
parent_->AddChild(derived_instance);
Initialize();
@ -30,7 +31,7 @@ TaskParent::TaskParent(Task* derived_instance, TaskParent *parent)
TaskParent::TaskParent(TaskRunner *derived_instance)
: parent_(NULL),
runner_(derived_instance) {
ASSERT(derived_instance != NULL);
RTC_DCHECK(derived_instance != NULL);
Initialize();
}
@ -46,9 +47,9 @@ void TaskParent::AddChild(Task *child) {
children_->insert(child);
}
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
bool TaskParent::IsChildTask(Task *task) {
ASSERT(task != NULL);
RTC_DCHECK(task != NULL);
return task->parent_ == this && children_->find(task) != children_->end();
}
#endif
@ -69,7 +70,7 @@ bool TaskParent::AnyChildError() {
void TaskParent::AbortAllChildren() {
if (children_->size() > 0) {
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
runner_->IncrementAbortCount();
#endif
@ -78,7 +79,7 @@ void TaskParent::AbortAllChildren() {
(*it)->Abort(true); // Note we do not wake
}
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
runner_->DecrementAbortCount();
#endif
}

View File

@ -14,6 +14,7 @@
#include <memory>
#include <set>
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
namespace rtc {
@ -32,7 +33,7 @@ class TaskParent {
bool AllChildrenDone();
bool AnyChildError();
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
bool IsChildTask(Task *task);
#endif

View File

@ -12,6 +12,7 @@
#include "webrtc/base/taskrunner.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/task.h"
#include "webrtc/base/logging.h"
@ -19,15 +20,7 @@
namespace rtc {
TaskRunner::TaskRunner()
: TaskParent(this),
next_timeout_task_(NULL),
tasks_running_(false)
#if !defined(NDEBUG)
, abort_count_(0),
deleting_task_(NULL)
#endif
{
}
: TaskParent(this) {}
TaskRunner::~TaskRunner() {
// this kills and deletes children silently!
@ -54,8 +47,10 @@ void TaskRunner::InternalRunTasks(bool in_destructor) {
// If that occurs, then tasks may be deleted in this method,
// but pointers to them will still be in the
// "ChildSet copy" in TaskParent::AbortAllChildren.
// Subsequent use of those task may cause data corruption or crashes.
ASSERT(!abort_count_);
// Subsequent use of those task may cause data corruption or crashes.
#if RTC_DCHECK_IS_ON
RTC_DCHECK(!abort_count_);
#endif
// Running continues until all tasks are Blocked (ok for a small # of tasks)
if (tasks_running_) {
return; // don't reenter
@ -87,11 +82,11 @@ void TaskRunner::InternalRunTasks(bool in_destructor) {
need_timeout_recalc = true;
}
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
deleting_task_ = task;
#endif
delete task;
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
deleting_task_ = NULL;
#endif
tasks_[i] = NULL;
@ -150,7 +145,7 @@ int64_t TaskRunner::next_task_timeout() const {
void TaskRunner::UpdateTaskTimeout(Task* task,
int64_t previous_task_timeout_time) {
ASSERT(task != NULL);
RTC_DCHECK(task != NULL);
int64_t previous_timeout_time = next_task_timeout();
bool task_is_timeout_task = next_timeout_task_ != NULL &&
task->unique_id() == next_timeout_task_->unique_id();

View File

@ -15,6 +15,7 @@
#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/taskparent.h"
@ -45,7 +46,7 @@ class TaskRunner : public TaskParent, public sigslot::has_slots<> {
void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time);
#if !defined(NDEBUG)
#if RTC_DCHECK_IS_ON
bool is_ok_to_delete(Task* task) {
return task == deleting_task_;
}
@ -86,11 +87,11 @@ class TaskRunner : public TaskParent, public sigslot::has_slots<> {
void CheckForTimeoutChange(int64_t previous_timeout_time);
std::vector<Task *> tasks_;
Task *next_timeout_task_;
bool tasks_running_;
#if !defined(NDEBUG)
int abort_count_;
Task* deleting_task_;
Task *next_timeout_task_ = nullptr;
bool tasks_running_ = false;
#if RTC_DCHECK_IS_ON
int abort_count_ = 0;
Task* deleting_task_ = nullptr;
#endif
void RecalcNextTimeout(Task *exclude_task);

View File

@ -20,6 +20,7 @@
#include <time.h>
#endif
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nullsocketserver.h"
@ -134,7 +135,7 @@ Thread::ScopedDisallowBlockingCalls::ScopedDisallowBlockingCalls()
}
Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() {
ASSERT(thread_->IsCurrent());
RTC_DCHECK(thread_->IsCurrent());
thread_->SetAllowBlockingCalls(previous_state_);
}
@ -213,9 +214,9 @@ bool Thread::SetName(const std::string& name, const void* obj) {
}
bool Thread::Start(Runnable* runnable) {
ASSERT(owned_);
RTC_DCHECK(owned_);
if (!owned_) return false;
ASSERT(!running());
RTC_DCHECK(!running());
if (running()) return false;
Restart(); // reset IsQuitting() if the thread is being restarted
@ -273,14 +274,14 @@ void Thread::SafeWrapCurrent() {
void Thread::Join() {
if (running()) {
ASSERT(!IsCurrent());
RTC_DCHECK(!IsCurrent());
if (Current() && !Current()->blocking_calls_allowed_) {
LOG(LS_WARNING) << "Waiting for the thread to join, "
<< "but blocking calls have been disallowed";
}
#if defined(WEBRTC_WIN)
ASSERT(thread_ != NULL);
RTC_DCHECK(thread_ != NULL);
WaitForSingleObject(thread_, INFINITE);
CloseHandle(thread_);
thread_ = NULL;
@ -294,7 +295,7 @@ void Thread::Join() {
}
bool Thread::SetAllowBlockingCalls(bool allow) {
ASSERT(IsCurrent());
RTC_DCHECK(IsCurrent());
bool previous = blocking_calls_allowed_;
blocking_calls_allowed_ = allow;
return previous;
@ -304,7 +305,7 @@ bool Thread::SetAllowBlockingCalls(bool allow) {
void Thread::AssertBlockingIsAllowedOnCurrentThread() {
#if !defined(NDEBUG)
Thread* current = Thread::Current();
ASSERT(!current || current->blocking_calls_allowed_);
RTC_DCHECK(!current || current->blocking_calls_allowed_);
#endif
}
@ -366,7 +367,7 @@ void Thread::Send(const Location& posted_from,
AutoThread thread;
Thread *current_thread = Thread::Current();
ASSERT(current_thread != NULL); // AutoThread ensures this
RTC_DCHECK(current_thread != NULL); // AutoThread ensures this
bool ready = false;
{
@ -555,7 +556,7 @@ AutoThread::~AutoThread() {
#if defined(WEBRTC_WIN)
void ComThread::Run() {
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
ASSERT(SUCCEEDED(hr));
RTC_DCHECK(SUCCEEDED(hr));
if (SUCCEEDED(hr)) {
Thread::Run();
CoUninitialize();

View File

@ -67,7 +67,7 @@ TransformAdapter::Read(void * buffer, size_t buffer_len,
StreamResult result = transform_->Transform(buffer_, &in_len,
buffer, &out_len,
(state_ == ST_FLUSHING));
ASSERT(result != SR_BLOCK);
RTC_DCHECK(result != SR_BLOCK);
if (result == SR_EOS) {
// Note: Don't signal SR_EOS this iteration, unless out_len is zero
state_ = ST_COMPLETE;
@ -118,7 +118,7 @@ TransformAdapter::Write(const void * data, size_t data_len,
buffer_ + len_, &out_len,
(state_ == ST_FLUSHING));
ASSERT(result != SR_BLOCK);
RTC_DCHECK(result != SR_BLOCK);
if (result == SR_EOS) {
// Note: Don't signal SR_EOS this iteration, unless no data written
state_ = ST_COMPLETE;

View File

@ -45,6 +45,7 @@
#endif
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/stream.h"
@ -136,7 +137,7 @@ bool UnixFilesystem::DeleteFile(const Pathname &filename) {
LOG(LS_INFO) << "Deleting file:" << filename.pathname();
if (!IsFile(filename)) {
ASSERT(IsFile(filename));
RTC_DCHECK(IsFile(filename));
return false;
}
return ::unlink(filename.pathname().c_str()) == 0;
@ -146,7 +147,7 @@ bool UnixFilesystem::DeleteEmptyFolder(const Pathname &folder) {
LOG(LS_INFO) << "Deleting folder" << folder.pathname();
if (!IsFolder(folder)) {
ASSERT(IsFolder(folder));
RTC_DCHECK(IsFolder(folder));
return false;
}
std::string no_slash(folder.pathname(), 0, folder.pathname().length()-1);
@ -156,7 +157,7 @@ bool UnixFilesystem::DeleteEmptyFolder(const Pathname &folder) {
bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create,
const std::string *append) {
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
ASSERT(provided_app_temp_folder_ != NULL);
RTC_DCHECK(provided_app_temp_folder_ != NULL);
pathname.SetPathname(provided_app_temp_folder_, "");
#else
if (const char* tmpdir = getenv("TMPDIR")) {
@ -172,7 +173,7 @@ bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create,
}
#endif // defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
if (append) {
ASSERT(!append->empty());
RTC_DCHECK(!append->empty());
pathname.AppendFolder(*append);
}
return !create || CreateFolder(pathname);
@ -197,7 +198,7 @@ std::string UnixFilesystem::TempFilename(const Pathname &dir,
bool UnixFilesystem::MoveFile(const Pathname &old_path,
const Pathname &new_path) {
if (!IsFile(old_path)) {
ASSERT(IsFile(old_path));
RTC_DCHECK(IsFile(old_path));
return false;
}
LOG(LS_VERBOSE) << "Moving " << old_path.pathname()
@ -247,7 +248,7 @@ bool UnixFilesystem::CopyFile(const Pathname &old_path,
bool UnixFilesystem::IsTemporaryPath(const Pathname& pathname) {
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
ASSERT(provided_app_temp_folder_ != NULL);
RTC_DCHECK(provided_app_temp_folder_ != NULL);
#endif
const char* const kTempPrefixes[] = {
@ -316,13 +317,13 @@ bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) {
// On macOS and iOS, there is no requirement that the path contains the
// organization.
#if !defined(WEBRTC_MAC)
ASSERT(!organization_name_.empty());
RTC_DCHECK(!organization_name_.empty());
#endif
ASSERT(!application_name_.empty());
RTC_DCHECK(!application_name_.empty());
// First get the base directory for app data.
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
ASSERT(provided_app_data_folder_ != NULL);
RTC_DCHECK(provided_app_data_folder_ != NULL);
path->SetPathname(provided_app_data_folder_, "");
#elif defined(WEBRTC_LINUX) // && !WEBRTC_MAC && !WEBRTC_ANDROID
if (per_user) {
@ -389,11 +390,11 @@ bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) {
bool UnixFilesystem::GetAppTempFolder(Pathname* path) {
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
ASSERT(provided_app_temp_folder_ != NULL);
RTC_DCHECK(provided_app_temp_folder_ != NULL);
path->SetPathname(provided_app_temp_folder_);
return true;
#else
ASSERT(!application_name_.empty());
RTC_DCHECK(!application_name_.empty());
// TODO: Consider whether we are worried about thread safety.
if (app_temp_path_ != NULL && strlen(app_temp_path_) > 0) {
path->SetPathname(app_temp_path_);
@ -422,7 +423,7 @@ bool UnixFilesystem::GetDiskFreeSpace(const Pathname& path,
#ifdef __native_client__
return false;
#else // __native_client__
ASSERT(NULL != freebytes);
RTC_DCHECK(NULL != freebytes);
// TODO: Consider making relative paths absolute using cwd.
// TODO: When popping off a symlink, push back on the components of the
// symlink, so we don't jump out of the target disk inadvertently.

View File

@ -17,6 +17,7 @@
#include "webrtc/base/arraysize.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@ -318,7 +319,7 @@ int inet_pton_v6(const char* src, void* dst) {
//
void FileTimeToUnixTime(const FILETIME& ft, time_t* ut) {
ASSERT(NULL != ut);
RTC_DCHECK(NULL != ut);
// FILETIME has an earlier date base than time_t (1/1/1970), so subtract off
// the difference.
@ -342,7 +343,7 @@ void FileTimeToUnixTime(const FILETIME& ft, time_t* ut) {
}
void UnixTimeToFileTime(const time_t& ut, FILETIME* ft) {
ASSERT(NULL != ft);
RTC_DCHECK(NULL != ft);
// FILETIME has an earlier date base than time_t (1/1/1970), so add in
// the difference.
@ -404,13 +405,13 @@ bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename) {
// Non-unc path: <pathname>
// Becomes: \\?\<pathname>
start -= 4;
ASSERT(start >= full_filename);
RTC_DCHECK(start >= full_filename);
memcpy(start, kLongPathPrefix, 4 * sizeof(wchar_t));
} else if (start[2] != L'?') {
// Unc path: \\<server>\<pathname>
// Becomes: \\?\UNC\<server>\<pathname>
start -= 6;
ASSERT(start >= full_filename);
RTC_DCHECK(start >= full_filename);
memcpy(start, kLongPathPrefix, 7 * sizeof(wchar_t));
} else {
// Already in long-path form.

View File

@ -76,7 +76,7 @@ FileStream *Win32Filesystem::OpenFile(const Pathname &filename,
bool Win32Filesystem::DeleteFile(const Pathname &filename) {
LOG(LS_INFO) << "Deleting file " << filename.pathname();
if (!IsFile(filename)) {
ASSERT(IsFile(filename));
RTC_DCHECK(IsFile(filename));
return false;
}
return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0;
@ -106,7 +106,7 @@ bool Win32Filesystem::GetTemporaryFolder(Pathname &pathname, bool create,
pathname.clear();
pathname.SetFolder(ToUtf8(buffer));
if (append != NULL) {
ASSERT(!append->empty());
RTC_DCHECK(!append->empty());
pathname.AppendFolder(*append);
}
return !create || CreateFolder(pathname);
@ -125,7 +125,7 @@ std::string Win32Filesystem::TempFilename(const Pathname &dir,
bool Win32Filesystem::MoveFile(const Pathname &old_path,
const Pathname &new_path) {
if (!IsFile(old_path)) {
ASSERT(IsFile(old_path));
RTC_DCHECK(IsFile(old_path));
return false;
}
LOG(LS_INFO) << "Moving " << old_path.pathname()
@ -217,8 +217,8 @@ bool Win32Filesystem::GetAppPathname(Pathname* path) {
}
bool Win32Filesystem::GetAppDataFolder(Pathname* path, bool per_user) {
ASSERT(!organization_name_.empty());
ASSERT(!application_name_.empty());
RTC_DCHECK(!organization_name_.empty());
RTC_DCHECK(!application_name_.empty());
TCHAR buffer[MAX_PATH + 1];
int csidl = per_user ? CSIDL_LOCAL_APPDATA : CSIDL_COMMON_APPDATA;
if (!::SHGetSpecialFolderPath(NULL, buffer, csidl, TRUE))
@ -282,7 +282,7 @@ bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path,
int64_t total_number_of_free_bytes; // receives the free bytes on disk
// make sure things won't change in 64 bit machine
// TODO replace with compile time assert
ASSERT(sizeof(ULARGE_INTEGER) == sizeof(uint64_t)); // NOLINT
RTC_DCHECK(sizeof(ULARGE_INTEGER) == sizeof(uint64_t)); // NOLINT
if (::GetDiskFreeSpaceEx(target_drive,
(PULARGE_INTEGER)free_bytes,
(PULARGE_INTEGER)&total_number_of_bytes,

View File

@ -251,11 +251,11 @@ bool Win32Socket::CreateT(int family, int type) {
}
int Win32Socket::Attach(SOCKET s) {
ASSERT(socket_ == INVALID_SOCKET);
RTC_DCHECK(socket_ == INVALID_SOCKET);
if (socket_ != INVALID_SOCKET)
return SOCKET_ERROR;
ASSERT(s != INVALID_SOCKET);
RTC_DCHECK(s != INVALID_SOCKET);
if (s == INVALID_SOCKET)
return SOCKET_ERROR;
@ -304,7 +304,7 @@ SocketAddress Win32Socket::GetRemoteAddress() const {
}
int Win32Socket::Bind(const SocketAddress& addr) {
ASSERT(socket_ != INVALID_SOCKET);
RTC_DCHECK(socket_ != INVALID_SOCKET);
if (socket_ == INVALID_SOCKET)
return SOCKET_ERROR;
@ -553,7 +553,7 @@ int Win32Socket::EstimateMTU(uint16_t* mtu) {
}
void Win32Socket::CreateSink() {
ASSERT(NULL == sink_);
RTC_DCHECK(NULL == sink_);
// Create window
sink_ = new EventSink(this);
@ -563,7 +563,7 @@ void Win32Socket::CreateSink() {
bool Win32Socket::SetAsync(int events) {
if (NULL == sink_) {
CreateSink();
ASSERT(NULL != sink_);
RTC_DCHECK(NULL != sink_);
}
// start the async select
@ -793,7 +793,7 @@ bool Win32SocketServer::Wait(int cms, bool process_io) {
} while (b && TimeSince(start) < cms);
} else if (cms != 0) {
// Sit and wait forever for a WakeUp. This is the Thread::Send case.
ASSERT(cms == -1);
RTC_DCHECK(cms == -1);
MSG msg;
b = GetMessage(&msg, NULL, s_wm_wakeup_id, s_wm_wakeup_id);
{

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/win32window.h"
@ -26,7 +27,7 @@ Win32Window::Win32Window() : wnd_(NULL) {
}
Win32Window::~Win32Window() {
ASSERT(NULL == wnd_);
RTC_DCHECK(NULL == wnd_);
}
bool Win32Window::Create(HWND parent, const wchar_t* title, DWORD style,

View File

@ -64,7 +64,7 @@ Conductor::Conductor(PeerConnectionClient* client, MainWindow* main_wnd)
}
Conductor::~Conductor() {
ASSERT(peer_connection_.get() == NULL);
RTC_DCHECK(peer_connection_.get() == NULL);
}
bool Conductor::connection_active() const {
@ -77,8 +77,8 @@ void Conductor::Close() {
}
bool Conductor::InitializePeerConnection() {
ASSERT(peer_connection_factory_.get() == NULL);
ASSERT(peer_connection_.get() == NULL);
RTC_DCHECK(peer_connection_factory_.get() == NULL);
RTC_DCHECK(peer_connection_.get() == NULL);
peer_connection_factory_ = webrtc::CreatePeerConnectionFactory();
@ -112,8 +112,8 @@ bool Conductor::ReinitializePeerConnectionForLoopback() {
}
bool Conductor::CreatePeerConnection(bool dtls) {
ASSERT(peer_connection_factory_.get() != NULL);
ASSERT(peer_connection_.get() == NULL);
RTC_DCHECK(peer_connection_factory_.get() != NULL);
RTC_DCHECK(peer_connection_.get() == NULL);
webrtc::PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer server;
@ -145,7 +145,7 @@ void Conductor::DeletePeerConnection() {
}
void Conductor::EnsureStreamingUI() {
ASSERT(peer_connection_.get() != NULL);
RTC_DCHECK(peer_connection_.get() != NULL);
if (main_wnd_->IsWindow()) {
if (main_wnd_->current_ui() != MainWindow::STREAMING)
main_wnd_->SwitchToStreamingUI();
@ -231,11 +231,11 @@ void Conductor::OnPeerDisconnected(int id) {
}
void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
ASSERT(peer_id_ == peer_id || peer_id_ == -1);
ASSERT(!message.empty());
RTC_DCHECK(peer_id_ == peer_id || peer_id_ == -1);
RTC_DCHECK(!message.empty());
if (!peer_connection_.get()) {
ASSERT(peer_id_ == -1);
RTC_DCHECK(peer_id_ == -1);
peer_id_ = peer_id;
if (!InitializePeerConnection()) {
@ -244,7 +244,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
return;
}
} else if (peer_id != peer_id_) {
ASSERT(peer_id_ != -1);
RTC_DCHECK(peer_id_ != -1);
LOG(WARNING) << "Received a message from unknown peer while already in a "
"conversation with a different peer.";
return;
@ -350,8 +350,8 @@ void Conductor::DisconnectFromServer() {
}
void Conductor::ConnectToPeer(int peer_id) {
ASSERT(peer_id_ == -1);
ASSERT(peer_id != -1);
RTC_DCHECK(peer_id_ == -1);
RTC_DCHECK(peer_id != -1);
if (peer_connection_.get()) {
main_wnd_->MessageBox("Error",
@ -444,7 +444,7 @@ void Conductor::UIThreadCallback(int msg_id, void* data) {
LOG(INFO) << "PEER_CONNECTION_CLOSED";
DeletePeerConnection();
ASSERT(active_streams_.empty());
RTC_DCHECK(active_streams_.empty());
if (main_wnd_->IsWindow()) {
if (client_->is_connected()) {

View File

@ -17,6 +17,7 @@
#include "libyuv/convert_from.h"
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/examples/peerconnection/client/defaults.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringutils.h"
@ -142,7 +143,7 @@ GtkMainWnd::GtkMainWnd(const char* server, int port, bool autoconnect,
}
GtkMainWnd::~GtkMainWnd() {
ASSERT(!IsWindow());
RTC_DCHECK(!IsWindow());
}
void GtkMainWnd::RegisterObserver(MainWndCallback* callback) {
@ -198,7 +199,7 @@ void GtkMainWnd::QueueUIThreadCallback(int msg_id, void* data) {
}
bool GtkMainWnd::Create() {
ASSERT(window_ == NULL);
RTC_DCHECK(window_ == NULL);
window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
if (window_) {
@ -229,8 +230,8 @@ bool GtkMainWnd::Destroy() {
void GtkMainWnd::SwitchToConnectUI() {
LOG(INFO) << __FUNCTION__;
ASSERT(IsWindow());
ASSERT(vbox_ == NULL);
RTC_DCHECK(IsWindow());
RTC_DCHECK(vbox_ == NULL);
gtk_container_set_border_width(GTK_CONTAINER(window_), 10);
@ -322,7 +323,7 @@ void GtkMainWnd::SwitchToPeerList(const Peers& peers) {
void GtkMainWnd::SwitchToStreamingUI() {
LOG(INFO) << __FUNCTION__;
ASSERT(draw_area_ == NULL);
RTC_DCHECK(draw_area_ == NULL);
gtk_container_set_border_width(GTK_CONTAINER(window_), 0);
if (peer_list_) {
@ -396,7 +397,7 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) {
void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
GtkTreeViewColumn* column) {
ASSERT(peer_list_ != NULL);
RTC_DCHECK(peer_list_ != NULL);
GtkTreeIter iter;
GtkTreeModel* model;
GtkTreeSelection* selection =

View File

@ -16,6 +16,7 @@
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/examples/peerconnection/client/defaults.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@ -79,11 +80,11 @@ MainWnd::MainWnd(const char* server, int port, bool auto_connect,
}
MainWnd::~MainWnd() {
ASSERT(!IsWindow());
RTC_DCHECK(!IsWindow());
}
bool MainWnd::Create() {
ASSERT(wnd_ == NULL);
RTC_DCHECK(wnd_ == NULL);
if (!RegisterWindowClass())
return false;
@ -146,7 +147,7 @@ bool MainWnd::PreTranslateMessage(MSG* msg) {
}
void MainWnd::SwitchToConnectUI() {
ASSERT(IsWindow());
RTC_DCHECK(IsWindow());
LayoutPeerListUI(false);
ui_ = CONNECT_TO_SERVER;
LayoutConnectUI(true);
@ -440,7 +441,7 @@ bool MainWnd::RegisterWindowClass() {
wcex.lpfnWndProc = &WndProc;
wcex.lpszClassName = kClassName;
wnd_class_ = ::RegisterClassEx(&wcex);
ASSERT(wnd_class_ != 0);
RTC_DCHECK(wnd_class_ != 0);
return wnd_class_ != 0;
}
@ -456,7 +457,7 @@ void MainWnd::CreateChildWindow(HWND* wnd, MainWnd::ChildWindowID id,
100, 100, 100, 100, wnd_,
reinterpret_cast<HMENU>(id),
GetModuleHandle(NULL), NULL);
ASSERT(::IsWindow(*wnd) != FALSE);
RTC_DCHECK(::IsWindow(*wnd) != FALSE);
::SendMessage(*wnd, WM_SETFONT, reinterpret_cast<WPARAM>(GetDefaultFont()),
TRUE);
}
@ -614,7 +615,7 @@ void MainWnd::VideoRenderer::OnFrame(
SetSize(buffer->width(), buffer->height());
ASSERT(image_.get() != NULL);
RTC_DCHECK(image_.get() != NULL);
libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(),
buffer->DataU(), buffer->StrideU(),
buffer->DataV(), buffer->StrideV(),

View File

@ -11,6 +11,7 @@
#include "webrtc/examples/peerconnection/client/peer_connection_client.h"
#include "webrtc/examples/peerconnection/client/defaults.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nethelpers.h"
@ -36,7 +37,7 @@ rtc::AsyncSocket* CreateClientSocket(int family) {
return sock;
#elif defined(WEBRTC_POSIX)
rtc::Thread* thread = rtc::Thread::Current();
ASSERT(thread != NULL);
RTC_DCHECK(thread != NULL);
return thread->socketserver()->CreateAsyncSocket(family, SOCK_STREAM);
#else
#error Platform not supported.
@ -56,8 +57,8 @@ PeerConnectionClient::~PeerConnectionClient() {
}
void PeerConnectionClient::InitSocketSignals() {
ASSERT(control_socket_.get() != NULL);
ASSERT(hanging_get_.get() != NULL);
RTC_DCHECK(control_socket_.get() != NULL);
RTC_DCHECK(hanging_get_.get() != NULL);
control_socket_->SignalCloseEvent.connect(this,
&PeerConnectionClient::OnClose);
hanging_get_->SignalCloseEvent.connect(this,
@ -86,14 +87,14 @@ const Peers& PeerConnectionClient::peers() const {
void PeerConnectionClient::RegisterObserver(
PeerConnectionClientObserver* callback) {
ASSERT(!callback_);
RTC_DCHECK(!callback_);
callback_ = callback;
}
void PeerConnectionClient::Connect(const std::string& server, int port,
const std::string& client_name) {
ASSERT(!server.empty());
ASSERT(!client_name.empty());
RTC_DCHECK(!server.empty());
RTC_DCHECK(!client_name.empty());
if (state_ != NOT_CONNECTED) {
LOG(WARNING)
@ -158,8 +159,8 @@ bool PeerConnectionClient::SendToPeer(int peer_id, const std::string& message) {
if (state_ != CONNECTED)
return false;
ASSERT(is_connected());
ASSERT(control_socket_->GetState() == rtc::Socket::CS_CLOSED);
RTC_DCHECK(is_connected());
RTC_DCHECK(control_socket_->GetState() == rtc::Socket::CS_CLOSED);
if (!is_connected() || peer_id == -1)
return false;
@ -225,7 +226,7 @@ void PeerConnectionClient::Close() {
}
bool PeerConnectionClient::ConnectControlSocket() {
ASSERT(control_socket_->GetState() == rtc::Socket::CS_CLOSED);
RTC_DCHECK(control_socket_->GetState() == rtc::Socket::CS_CLOSED);
int err = control_socket_->Connect(server_address_);
if (err == SOCKET_ERROR) {
Close();
@ -235,9 +236,9 @@ bool PeerConnectionClient::ConnectControlSocket() {
}
void PeerConnectionClient::OnConnect(rtc::AsyncSocket* socket) {
ASSERT(!onconnect_data_.empty());
RTC_DCHECK(!onconnect_data_.empty());
size_t sent = socket->Send(onconnect_data_.c_str(), onconnect_data_.length());
ASSERT(sent == onconnect_data_.length());
RTC_DCHECK(sent == onconnect_data_.length());
RTC_UNUSED(sent);
onconnect_data_.clear();
}
@ -248,7 +249,7 @@ void PeerConnectionClient::OnHangingGetConnect(rtc::AsyncSocket* socket) {
"GET /wait?peer_id=%i HTTP/1.0\r\n\r\n", my_id_);
int len = static_cast<int>(strlen(buffer));
int sent = socket->Send(buffer, len);
ASSERT(sent == len);
RTC_DCHECK(sent == len);
RTC_UNUSED2(sent, len);
}
@ -266,7 +267,7 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data,
size_t eoh,
const char* header_pattern,
size_t* value) {
ASSERT(value != NULL);
RTC_DCHECK(value != NULL);
size_t found = data.find(header_pattern);
if (found != std::string::npos && found < eoh) {
*value = atoi(&data[found + strlen(header_pattern)]);
@ -278,7 +279,7 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data,
bool PeerConnectionClient::GetHeaderValue(const std::string& data, size_t eoh,
const char* header_pattern,
std::string* value) {
ASSERT(value != NULL);
RTC_DCHECK(value != NULL);
size_t found = data.find(header_pattern);
if (found != std::string::npos && found < eoh) {
size_t begin = found + strlen(header_pattern);
@ -338,9 +339,9 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) {
if (ok) {
if (my_id_ == -1) {
// First response. Let's store our server assigned ID.
ASSERT(state_ == SIGNING_IN);
RTC_DCHECK(state_ == SIGNING_IN);
my_id_ = static_cast<int>(peer_id);
ASSERT(my_id_ != -1);
RTC_DCHECK(my_id_ != -1);
// The body of the response will be a list of already connected peers.
if (content_length) {
@ -360,7 +361,7 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) {
pos = eol + 1;
}
}
ASSERT(is_connected());
RTC_DCHECK(is_connected());
callback_->OnSignedIn();
} else if (state_ == SIGNING_OUT) {
Close();
@ -373,7 +374,7 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) {
control_data_.clear();
if (state_ == SIGNING_IN) {
ASSERT(hanging_get_->GetState() == rtc::Socket::CS_CLOSED);
RTC_DCHECK(hanging_get_->GetState() == rtc::Socket::CS_CLOSED);
state_ = CONNECTED;
hanging_get_->Connect(server_address_);
}
@ -427,10 +428,10 @@ bool PeerConnectionClient::ParseEntry(const std::string& entry,
std::string* name,
int* id,
bool* connected) {
ASSERT(name != NULL);
ASSERT(id != NULL);
ASSERT(connected != NULL);
ASSERT(!entry.empty());
RTC_DCHECK(name != NULL);
RTC_DCHECK(id != NULL);
RTC_DCHECK(connected != NULL);
RTC_DCHECK(!entry.empty());
*connected = false;
size_t separator = entry.find(',');
@ -466,7 +467,7 @@ bool PeerConnectionClient::ParseServerResponse(const std::string& response,
}
*eoh = response.find("\r\n\r\n");
ASSERT(*eoh != std::string::npos);
RTC_DCHECK(*eoh != std::string::npos);
if (*eoh == std::string::npos)
return false;

View File

@ -19,6 +19,7 @@
#include <vector>
#include "webrtc/api/call/audio_sink.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/copyonwritebuffer.h"
#include "webrtc/base/networkroute.h"
#include "webrtc/base/stringutils.h"
@ -468,7 +469,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
auto it = local_sinks_.find(ssrc);
if (source) {
if (it != local_sinks_.end()) {
ASSERT(it->second->source() == source);
RTC_DCHECK(it->second->source() == source);
} else {
local_sinks_.insert(
std::make_pair(ssrc, new VoiceChannelAudioSink(source)));

View File

@ -19,6 +19,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/checks.h"
#include "webrtc/config.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/media/base/rtputils.h"
@ -326,12 +327,12 @@ class FakeWebRtcVoiceEngine
}
size_t GetNetEqCapacity() const {
auto ch = channels_.find(last_channel_);
ASSERT(ch != channels_.end());
RTC_DCHECK(ch != channels_.end());
return ch->second->neteq_capacity;
}
bool GetNetEqFastAccelerate() const {
auto ch = channels_.find(last_channel_);
ASSERT(ch != channels_.end());
RTC_DCHECK(ch != channels_.end());
return ch->second->neteq_fast_accelerate;
}

View File

@ -10,6 +10,7 @@
#include "webrtc/modules/video_capture/windows/sink_filter_ds.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/modules/video_capture/windows/help_functions_ds.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -337,7 +338,7 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample )
if (SUCCEEDED (hr))
{
const LONG length = pIMediaSample->GetActualDataLength();
ASSERT(length >= 0);
RTC_DCHECK(length >= 0);
unsigned char* pBuffer = NULL;
if(S_OK != pIMediaSample->GetPointer(&pBuffer))

View File

@ -13,6 +13,7 @@
#include <string.h>
#include "webrtc/p2p/base/stun.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@ -68,7 +69,7 @@ int AsyncStunTCPSocket::Send(const void *pv, size_t cb,
AppendToOutBuffer(pv, cb);
ASSERT(pad_bytes < 4);
RTC_DCHECK(pad_bytes < 4);
char padding[4] = {0};
AppendToOutBuffer(padding, pad_bytes);

View File

@ -16,6 +16,7 @@
#include "webrtc/p2p/base/stun.h"
#include "webrtc/base/asynctcpsocket.h"
#include "webrtc/base/asyncudpsocket.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nethelpers.h"
#include "webrtc/base/physicalsocketserver.h"
@ -89,7 +90,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateServerTcpSocket(
// If using fake TLS, wrap the TCP socket in a pseudo-SSL socket.
if (opts & PacketSocketFactory::OPT_TLS_FAKE) {
ASSERT(!(opts & PacketSocketFactory::OPT_TLS));
RTC_DCHECK(!(opts & PacketSocketFactory::OPT_TLS));
socket = new AsyncSSLSocket(socket);
}
@ -133,7 +134,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
int tlsOpts =
opts & (PacketSocketFactory::OPT_TLS | PacketSocketFactory::OPT_TLS_FAKE |
PacketSocketFactory::OPT_TLS_INSECURE);
ASSERT((tlsOpts & (tlsOpts - 1)) == 0);
RTC_DCHECK((tlsOpts & (tlsOpts - 1)) == 0);
if ((tlsOpts & PacketSocketFactory::OPT_TLS) ||
(tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE)) {
@ -204,7 +205,7 @@ int BasicPacketSocketFactory::BindSocket(AsyncSocket* socket,
SocketFactory* BasicPacketSocketFactory::socket_factory() {
if (thread_) {
ASSERT(thread_ == Thread::Current());
RTC_DCHECK(thread_ == Thread::Current());
return thread_->socketserver();
} else {
return socket_factory_;

View File

@ -21,6 +21,7 @@
#include <string>
#include "webrtc/p2p/base/p2pconstants.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/network.h"
#include "webrtc/base/socketaddress.h"
@ -148,7 +149,7 @@ class Candidate {
// cost of 0 indicates this candidate can be used freely. A value of
// rtc::kNetworkCostMax indicates it should be used only as the last resort.
void set_network_cost(uint16_t network_cost) {
ASSERT(network_cost <= rtc::kNetworkCostMax);
RTC_DCHECK(network_cost <= rtc::kNetworkCostMax);
network_cost_ = network_cost;
}
uint16_t network_cost() const { return network_cost_; }

View File

@ -403,7 +403,7 @@ int DtlsTransportChannelWrapper::SendPacket(
return -1;
case DTLS_TRANSPORT_CONNECTED:
if (flags & PF_SRTP_BYPASS) {
ASSERT(!srtp_ciphers_.empty());
RTC_DCHECK(!srtp_ciphers_.empty());
if (!IsRtpPacket(data, size)) {
return -1;
}
@ -440,7 +440,7 @@ bool DtlsTransportChannelWrapper::IsDtlsConnected() {
// impl again
void DtlsTransportChannelWrapper::OnWritableState(
rtc::PacketTransportInterface* transport) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(transport == channel_);
LOG_J(LS_VERBOSE, this)
<< "DTLSTransportChannelWrapper: channel writable state changed to "
@ -473,7 +473,7 @@ void DtlsTransportChannelWrapper::OnWritableState(
void DtlsTransportChannelWrapper::OnReceivingState(
rtc::PacketTransportInterface* transport) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(transport == channel_);
LOG_J(LS_VERBOSE, this)
<< "DTLSTransportChannelWrapper: channel receiving state changed to "
@ -490,9 +490,9 @@ void DtlsTransportChannelWrapper::OnReadPacket(
size_t size,
const rtc::PacketTime& packet_time,
int flags) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(transport == channel_);
ASSERT(flags == 0);
RTC_DCHECK(flags == 0);
if (!dtls_active_) {
// Not doing DTLS.
@ -550,7 +550,7 @@ void DtlsTransportChannelWrapper::OnReadPacket(
}
// Sanity check.
ASSERT(!srtp_ciphers_.empty());
RTC_DCHECK(!srtp_ciphers_.empty());
// Signal this upwards as a bypass packet.
SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS);
@ -566,7 +566,7 @@ void DtlsTransportChannelWrapper::OnReadPacket(
void DtlsTransportChannelWrapper::OnSentPacket(
rtc::PacketTransportInterface* transport,
const rtc::SentPacket& sent_packet) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
SignalSentPacket(this, sent_packet);
}
@ -580,8 +580,8 @@ void DtlsTransportChannelWrapper::OnReadyToSend(
void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls,
int sig, int err) {
ASSERT(rtc::Thread::Current() == network_thread_);
ASSERT(dtls == dtls_.get());
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(dtls == dtls_.get());
if (sig & rtc::SE_OPEN) {
// This is the first time.
LOG_J(LS_INFO, this) << "DTLS handshake complete.";
@ -612,7 +612,7 @@ void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls,
}
}
if (sig & rtc::SE_CLOSE) {
ASSERT(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself.
RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself.
set_writable(false);
if (!err) {
LOG_J(LS_INFO, this) << "DTLS channel closed";
@ -685,33 +685,33 @@ bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data,
void DtlsTransportChannelWrapper::OnGatheringState(
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalGatheringState(this);
}
void DtlsTransportChannelWrapper::OnCandidateGathered(
TransportChannelImpl* channel,
const Candidate& c) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalCandidateGathered(this, c);
}
void DtlsTransportChannelWrapper::OnCandidatesRemoved(
TransportChannelImpl* channel,
const Candidates& candidates) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalCandidatesRemoved(this, candidates);
}
void DtlsTransportChannelWrapper::OnRoleConflict(
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalRoleConflict(this);
}
void DtlsTransportChannelWrapper::OnRouteChange(
TransportChannel* channel, const Candidate& candidate) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalRouteChange(this, candidate);
}
@ -720,14 +720,14 @@ void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged(
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalSelectedCandidatePairChanged(this, selected_candidate_pair,
last_sent_packet_id, ready_to_send);
}
void DtlsTransportChannelWrapper::OnChannelStateChanged(
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
RTC_DCHECK(channel == channel_);
SignalStateChanged(this);
}

View File

@ -312,7 +312,7 @@ bool JsepTransport::VerifyCertificateFingerprint(
}
std::unique_ptr<rtc::SSLFingerprint> fp_tmp(rtc::SSLFingerprint::Create(
fingerprint->algorithm, certificate->identity()));
ASSERT(fp_tmp.get() != NULL);
RTC_DCHECK(fp_tmp.get() != NULL);
if (*fp_tmp == *fingerprint) {
return true;
}

View File

@ -129,14 +129,14 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name,
}
P2PTransportChannel::~P2PTransportChannel() {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
}
// Add the allocator session to our list so that we know which sessions
// are still active.
void P2PTransportChannel::AddAllocatorSession(
std::unique_ptr<PortAllocatorSession> session) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
@ -247,7 +247,7 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection(
}
void P2PTransportChannel::SetIceRole(IceRole ice_role) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
if (ice_role_ != ice_role) {
ice_role_ = ice_role;
for (PortInterface* port : ports_) {
@ -262,7 +262,7 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) {
}
void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
if (!ports_.empty() || !pruned_ports_.empty()) {
LOG(LS_ERROR)
<< "Attempt to change tiebreaker after Port has been allocated.";
@ -310,7 +310,7 @@ TransportChannelState P2PTransportChannel::ComputeState() const {
}
void P2PTransportChannel::SetIceParameters(const IceParameters& ice_params) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
LOG(LS_INFO) << "Set ICE ufrag: " << ice_params.ufrag
<< " pwd: " << ice_params.pwd << " on transport "
<< transport_name();
@ -321,7 +321,7 @@ void P2PTransportChannel::SetIceParameters(const IceParameters& ice_params) {
void P2PTransportChannel::SetRemoteIceParameters(
const IceParameters& ice_params) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
LOG(LS_INFO) << "Remote supports ICE renomination ? "
<< ice_params.renomination;
IceParameters* current_ice = remote_ice();
@ -502,7 +502,7 @@ void P2PTransportChannel::MaybeStartGathering() {
// A new port is available, attempt to make connections for it
void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
PortInterface* port) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Set in-effect options on the new port
for (OptionMap::const_iterator it = options_.begin();
@ -547,7 +547,7 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
void P2PTransportChannel::OnCandidatesReady(
PortAllocatorSession* session,
const std::vector<Candidate>& candidates) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
for (size_t i = 0; i < candidates.size(); ++i) {
SignalCandidateGathered(this, candidates[i]);
}
@ -555,7 +555,7 @@ void P2PTransportChannel::OnCandidatesReady(
void P2PTransportChannel::OnCandidatesAllocationDone(
PortAllocatorSession* session) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
if (config_.gather_continually()) {
LOG(LS_INFO) << "P2PTransportChannel: " << transport_name()
<< ", component " << component()
@ -575,7 +575,7 @@ void P2PTransportChannel::OnUnknownAddress(
const rtc::SocketAddress& address, ProtocolType proto,
IceMessage* stun_msg, const std::string &remote_username,
bool port_muxed) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Port has received a valid stun packet from an address that no Connection
// is currently available for. See if we already have a candidate with the
@ -714,8 +714,8 @@ const IceParameters* P2PTransportChannel::FindRemoteIceFromUfrag(
}
void P2PTransportChannel::OnNominated(Connection* conn) {
ASSERT(network_thread_ == rtc::Thread::Current());
ASSERT(ice_role_ == ICEROLE_CONTROLLED);
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(ice_role_ == ICEROLE_CONTROLLED);
if (selected_connection_ == conn) {
return;
@ -734,7 +734,7 @@ void P2PTransportChannel::OnNominated(Connection* conn) {
}
void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
uint32_t generation = GetRemoteCandidateGeneration(candidate);
// If a remote candidate with a previous generation arrives, drop it.
@ -798,7 +798,7 @@ void P2PTransportChannel::RemoveRemoteCandidate(
// the origin port.
bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate,
PortInterface* origin_port) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// If we've already seen the new remote candidate (in the current candidate
// generation), then we shouldn't try creating connections for it.
@ -947,7 +947,7 @@ void P2PTransportChannel::RememberRemoteCandidate(
// Set options on ourselves is simply setting options on all of our available
// port objects.
int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
OptionMap::iterator it = options_.find(opt);
if (it == options_.end()) {
options_.insert(std::make_pair(opt, value));
@ -970,7 +970,7 @@ int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
}
bool P2PTransportChannel::GetOption(rtc::Socket::Option opt, int* value) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
const auto& found = options_.find(opt);
if (found == options_.end()) {
@ -984,7 +984,7 @@ bool P2PTransportChannel::GetOption(rtc::Socket::Option opt, int* value) {
int P2PTransportChannel::SendPacket(const char *data, size_t len,
const rtc::PacketOptions& options,
int flags) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
if (flags != 0) {
error_ = EINVAL;
return -1;
@ -999,14 +999,14 @@ int P2PTransportChannel::SendPacket(const char *data, size_t len,
last_sent_packet_id_ = options.packet_id;
int sent = selected_connection_->Send(data, len, options);
if (sent <= 0) {
ASSERT(sent < 0);
RTC_DCHECK(sent < 0);
error_ = selected_connection_->GetError();
}
return sent;
}
bool P2PTransportChannel::GetStats(ConnectionInfos *infos) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Gather connection infos.
infos->clear();
@ -1221,7 +1221,7 @@ bool P2PTransportChannel::PresumedWritable(const Connection* conn) const {
// Sort the available connections to find the best one. We also monitor
// the number of available connections and the current state.
void P2PTransportChannel::SortConnectionsAndUpdateState() {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Make sure the connection states are up-to-date since this affects how they
// will be sorted.
@ -1544,7 +1544,7 @@ bool P2PTransportChannel::IsPingable(const Connection* conn,
int64_t now) const {
const Candidate& remote = conn->remote_candidate();
// We should never get this far with an empty remote ufrag.
ASSERT(!remote.username().empty());
RTC_DCHECK(!remote.username().empty());
if (remote.username().empty() || remote.password().empty()) {
// If we don't have an ICE ufrag and pwd, there's no way we can ping.
return false;
@ -1768,7 +1768,7 @@ bool P2PTransportChannel::GetUseCandidateAttr(Connection* conn,
// the selected connection again. It could have become usable, or become
// unusable.
void P2PTransportChannel::OnConnectionStateChange(Connection* connection) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// May stop the allocator session when at least one connection becomes
// strongly connected after starting to get ports and the local candidate of
@ -1790,7 +1790,7 @@ void P2PTransportChannel::OnConnectionStateChange(Connection* connection) {
// When a connection is removed, edit it out, and then update our best
// connection.
void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Note: the previous selected_connection_ may be destroyed by now, so don't
// use it.
@ -1798,7 +1798,7 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
// Remove this connection from the list.
std::vector<Connection*>::iterator iter =
std::find(connections_.begin(), connections_.end(), connection);
ASSERT(iter != connections_.end());
RTC_DCHECK(iter != connections_.end());
pinged_connections_.erase(*iter);
unpinged_connections_.erase(*iter);
connections_.erase(iter);
@ -1828,7 +1828,7 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
// When a port is destroyed, remove it from our list of ports to use for
// connection attempts.
void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end());
pruned_ports_.erase(
@ -1841,7 +1841,7 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
void P2PTransportChannel::OnPortsPruned(
PortAllocatorSession* session,
const std::vector<PortInterface*>& ports) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
for (PortInterface* port : ports) {
if (PrunePort(port)) {
LOG(INFO) << "Removed port: " << port->ToString() << " " << ports_.size()
@ -1853,7 +1853,7 @@ void P2PTransportChannel::OnPortsPruned(
void P2PTransportChannel::OnCandidatesRemoved(
PortAllocatorSession* session,
const std::vector<Candidate>& candidates) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Do not signal candidate removals if continual gathering is not enabled, or
// if this is not the last session because an ICE restart would have signaled
// the remote side to remove all candidates in previous sessions.
@ -1903,7 +1903,7 @@ void P2PTransportChannel::OnReadPacket(Connection* connection,
const char* data,
size_t len,
const rtc::PacketTime& packet_time) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
// Do not deliver, if packet doesn't belong to the correct transport channel.
if (!FindConnection(connection))
@ -1920,7 +1920,7 @@ void P2PTransportChannel::OnReadPacket(Connection* connection,
}
void P2PTransportChannel::OnSentPacket(const rtc::SentPacket& sent_packet) {
ASSERT(network_thread_ == rtc::Thread::Current());
RTC_DCHECK(network_thread_ == rtc::Thread::Current());
SignalSentPacket(this, sent_packet);
}

View File

@ -184,7 +184,7 @@ Port::Port(rtc::Thread* thread,
ice_role_(ICEROLE_UNKNOWN),
tiebreaker_(0),
shared_socket_(false) {
ASSERT(factory_ != NULL);
RTC_DCHECK(factory_ != NULL);
Construct();
}
@ -193,7 +193,7 @@ void Port::Construct() {
// relies on it. If the username_fragment and password are empty,
// we should just create one.
if (ice_username_fragment_.empty()) {
ASSERT(password_.empty());
RTC_DCHECK(password_.empty());
ice_username_fragment_ = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
password_ = rtc::CreateRandomString(ICE_PWD_LENGTH);
}
@ -253,7 +253,7 @@ void Port::AddAddress(const rtc::SocketAddress& address,
uint32_t relay_preference,
bool final) {
if (protocol == TCP_PROTOCOL_NAME && type == LOCAL_PORT_TYPE) {
ASSERT(!tcptype.empty());
RTC_DCHECK(!tcptype.empty());
}
std::string foundation =
@ -355,8 +355,8 @@ bool Port::GetStunMessage(const char* data,
// NOTE: This could clearly be optimized to avoid allocating any memory.
// However, at the data rates we'll be looking at on the client side,
// this probably isn't worth worrying about.
ASSERT(out_msg != NULL);
ASSERT(out_username != NULL);
RTC_DCHECK(out_msg != NULL);
RTC_DCHECK(out_username != NULL);
out_username->clear();
// Don't bother parsing the packet if we can tell it's not STUN.
@ -554,12 +554,12 @@ void Port::CreateStunUsername(const std::string& remote_username,
void Port::SendBindingResponse(StunMessage* request,
const rtc::SocketAddress& addr) {
ASSERT(request->type() == STUN_BINDING_REQUEST);
RTC_DCHECK(request->type() == STUN_BINDING_REQUEST);
// Retrieve the username from the request.
const StunByteStringAttribute* username_attr =
request->GetByteString(STUN_ATTR_USERNAME);
ASSERT(username_attr != NULL);
RTC_DCHECK(username_attr != NULL);
if (username_attr == NULL) {
// No valid username, skip the response.
return;
@ -618,7 +618,7 @@ void Port::SendBindingResponse(StunMessage* request,
void Port::SendBindingErrorResponse(StunMessage* request,
const rtc::SocketAddress& addr,
int error_code, const std::string& reason) {
ASSERT(request->type() == STUN_BINDING_REQUEST);
RTC_DCHECK(request->type() == STUN_BINDING_REQUEST);
// Fill in the response message.
StunMessage response;
@ -661,7 +661,7 @@ void Port::Prune() {
}
void Port::OnMessage(rtc::Message *pmsg) {
ASSERT(pmsg->message_id == MSG_DESTROY_IF_DEAD);
RTC_DCHECK(pmsg->message_id == MSG_DESTROY_IF_DEAD);
bool dead =
(state_ == State::INIT || state_ == State::PRUNED) &&
connections_.empty() &&
@ -672,7 +672,7 @@ void Port::OnMessage(rtc::Message *pmsg) {
}
void Port::OnNetworkTypeChanged(const rtc::Network* network) {
ASSERT(network == network_);
RTC_DCHECK(network == network_);
UpdateNetworkCost();
}
@ -715,7 +715,7 @@ void Port::EnablePortPackets() {
void Port::OnConnectionDestroyed(Connection* conn) {
AddressMap::iterator iter =
connections_.find(conn->remote_candidate().address());
ASSERT(iter != connections_.end());
RTC_DCHECK(iter != connections_.end());
connections_.erase(iter);
HandleConnectionDestroyed(conn);
@ -732,7 +732,7 @@ void Port::OnConnectionDestroyed(Connection* conn) {
}
void Port::Destroy() {
ASSERT(connections_.empty());
RTC_DCHECK(connections_.empty());
LOG_J(LS_INFO, this) << "Port deleted";
SignalDestroyed(this);
delete this;
@ -883,7 +883,7 @@ Connection::~Connection() {
}
const Candidate& Connection::local_candidate() const {
ASSERT(local_candidate_index_ < port_->Candidates().size());
RTC_DCHECK(local_candidate_index_ < port_->Candidates().size());
return port_->Candidates()[local_candidate_index_];
}
@ -1455,7 +1455,7 @@ void Connection::MaybeUpdatePeerReflexiveCandidate(
}
void Connection::OnMessage(rtc::Message *pmsg) {
ASSERT(pmsg->message_id == MSG_DELETE);
RTC_DCHECK(pmsg->message_id == MSG_DELETE);
LOG(LS_INFO) << "Connection deleted with number of pings sent: "
<< num_pings_sent_;
SignalDestroyed(this);
@ -1580,7 +1580,7 @@ int ProxyConnection::Send(const void* data, size_t size,
int sent = port_->SendTo(data, size, remote_candidate_.address(),
options, true);
if (sent <= 0) {
ASSERT(sent < 0);
RTC_DCHECK(sent < 0);
error_ = port_->GetError();
stats_.sent_discarded_packets++;
} else {

View File

@ -219,7 +219,7 @@ PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv)
m_sbuf_len(DEFAULT_SND_BUF_SIZE),
m_sbuf(m_sbuf_len) {
// Sanity check on buffer sizes (needed for OnTcpWriteable notification logic)
ASSERT(m_rbuf_len + MIN_PACKET < m_sbuf_len);
RTC_DCHECK(m_rbuf_len + MIN_PACKET < m_sbuf_len);
uint32_t now = Now();
@ -236,7 +236,7 @@ PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv)
m_msslevel = 0;
m_largest = 0;
ASSERT(MIN_PACKET > PACKET_OVERHEAD);
RTC_DCHECK(MIN_PACKET > PACKET_OVERHEAD);
m_mss = MIN_PACKET - PACKET_OVERHEAD;
m_mtu_advise = MAX_PACKET;
@ -388,10 +388,10 @@ void PseudoTcp::SetOption(Option opt, int value) {
} else if (opt == OPT_ACKDELAY) {
m_ack_delay = value;
} else if (opt == OPT_SNDBUF) {
ASSERT(m_state == TCP_LISTEN);
RTC_DCHECK(m_state == TCP_LISTEN);
resizeSendBuffer(value);
} else if (opt == OPT_RCVBUF) {
ASSERT(m_state == TCP_LISTEN);
RTC_DCHECK(m_state == TCP_LISTEN);
resizeReceiveBuffer(value);
} else {
RTC_NOTREACHED();
@ -435,7 +435,7 @@ int PseudoTcp::Recv(char* buffer, size_t len) {
m_error = EWOULDBLOCK;
return SOCKET_ERROR;
}
ASSERT(result == rtc::SR_SUCCESS);
RTC_DCHECK(result == rtc::SR_SUCCESS);
size_t available_space = 0;
m_rbuf.GetWriteRemaining(&available_space);
@ -492,7 +492,7 @@ uint32_t PseudoTcp::queue(const char* data, uint32_t len, bool bCtrl) {
m_sbuf.GetWriteRemaining(&available_space);
if (len > static_cast<uint32_t>(available_space)) {
ASSERT(!bCtrl);
RTC_DCHECK(!bCtrl);
len = static_cast<uint32_t>(available_space);
}
@ -517,7 +517,7 @@ IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32_t seq,
uint8_t flags,
uint32_t offset,
uint32_t len) {
ASSERT(HEADER_SIZE + len <= MAX_PACKET);
RTC_DCHECK(HEADER_SIZE + len <= MAX_PACKET);
uint32_t now = Now();
@ -540,8 +540,8 @@ IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32_t seq,
rtc::StreamResult result = m_sbuf.ReadOffset(
buffer.get() + HEADER_SIZE, len, offset, &bytes_read);
RTC_UNUSED(result);
ASSERT(result == rtc::SR_SUCCESS);
ASSERT(static_cast<uint32_t>(bytes_read) == len);
RTC_DCHECK(result == rtc::SR_SUCCESS);
RTC_DCHECK(static_cast<uint32_t>(bytes_read) == len);
}
#if _DEBUGMSG >= _DBG_VERBOSE
@ -750,7 +750,7 @@ bool PseudoTcp::process(Segment& seg) {
m_sbuf.ConsumeReadData(nAcked);
for (uint32_t nFree = nAcked; nFree > 0;) {
ASSERT(!m_slist.empty());
RTC_DCHECK(!m_slist.empty());
if (nFree < m_slist.front().len) {
m_slist.front().len -= nFree;
nFree = 0;
@ -912,7 +912,7 @@ bool PseudoTcp::process(Segment& seg) {
rtc::StreamResult result = m_rbuf.WriteOffset(seg.data, seg.len,
nOffset, NULL);
ASSERT(result == rtc::SR_SUCCESS);
RTC_DCHECK(result == rtc::SR_SUCCESS);
RTC_UNUSED(result);
if (seg.seq == m_rcv_nxt) {
@ -989,7 +989,7 @@ bool PseudoTcp::transmit(const SList::iterator& seg, uint32_t now) {
return false;
}
ASSERT(wres == IPseudoTcpNotify::WR_TOO_LARGE);
RTC_DCHECK(wres == IPseudoTcpNotify::WR_TOO_LARGE);
while (true) {
if (PACKET_MAXIMUMS[m_msslevel + 1] == 0) {
@ -1110,7 +1110,7 @@ void PseudoTcp::attemptSend(SendFlags sflags) {
SList::iterator it = m_slist.begin();
while (it->xmit > 0) {
++it;
ASSERT(it != m_slist.end());
RTC_DCHECK(it != m_slist.end());
}
SList::iterator seg = it;
@ -1203,7 +1203,7 @@ void PseudoTcp::parseOptions(const char* data, uint32_t len) {
}
// Length of this option.
ASSERT(len != 0);
RTC_DCHECK(len != 0);
RTC_UNUSED(len);
uint8_t opt_len = 0;
buf.ReadUInt8(&opt_len);
@ -1273,7 +1273,7 @@ void PseudoTcp::resizeReceiveBuffer(uint32_t new_size) {
// buffer. This should always be true because this method is called either
// before connection is established or when peers are exchanging connect
// messages.
ASSERT(result);
RTC_DCHECK(result);
RTC_UNUSED(result);
m_rbuf_len = new_size;
m_rwnd_scale = scale_factor;

View File

@ -11,6 +11,7 @@
#include "webrtc/p2p/base/relayport.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
@ -270,7 +271,7 @@ bool RelayPort::HasMagicCookie(const char* data, size_t size) {
void RelayPort::PrepareAddress() {
// We initiate a connect on the first entry. If this completes, it will fill
// in the server address as the address of this port.
ASSERT(entries_.size() == 1);
RTC_DCHECK(entries_.size() == 1);
entries_[0]->Connect();
ready_ = false;
}
@ -341,7 +342,7 @@ int RelayPort::SendTo(const void* data, size_t size,
// still be necessary). Otherwise, we can't yet use this connection, so we
// default to the first one.
if (!entry || !entry->connected()) {
ASSERT(!entries_.empty());
RTC_DCHECK(!entries_.empty());
entry = entries_[0];
if (!entry->connected()) {
error_ = ENOTCONN;
@ -352,7 +353,7 @@ int RelayPort::SendTo(const void* data, size_t size,
// Send the actual contents to the server using the usual mechanism.
int sent = entry->SendTo(data, size, addr, options);
if (sent <= 0) {
ASSERT(sent < 0);
RTC_DCHECK(sent < 0);
error_ = entry->GetError();
return SOCKET_ERROR;
}
@ -435,7 +436,7 @@ void RelayConnection::OnSendPacket(const void* data, size_t size,
if (sent <= 0) {
LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() <<
strerror(socket_->GetError());
ASSERT(sent < 0);
RTC_DCHECK(sent < 0);
}
}
@ -645,7 +646,7 @@ void RelayEntry::HandleConnectFailure(
}
void RelayEntry::OnMessage(rtc::Message *pmsg) {
ASSERT(pmsg->message_id == kMessageConnectTimeout);
RTC_DCHECK(pmsg->message_id == kMessageConnectTimeout);
if (current_connection_) {
const ProtocolAddress* ra = current_connection_->protocol_address();
LOG(LS_WARNING) << "Relay " << ra->proto << " connection to " <<
@ -684,7 +685,7 @@ void RelayEntry::OnReadPacket(
const char* data, size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
// ASSERT(remote_addr == port_->server_addr());
// RTC_DCHECK(remote_addr == port_->server_addr());
// TODO: are we worried about this?
if (current_connection_ == NULL || socket != current_connection_->socket()) {

View File

@ -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.

View File

@ -15,6 +15,7 @@
#include <memory>
#include "webrtc/base/byteorder.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/crc32.h"
#include "webrtc/base/logging.h"
@ -48,7 +49,7 @@ StunMessage::StunMessage()
: type_(0),
length_(0),
transaction_id_(EMPTY_TRANSACTION_ID) {
ASSERT(IsValidTransactionId(transaction_id_));
RTC_DCHECK(IsValidTransactionId(transaction_id_));
attrs_ = new std::vector<StunAttribute*>();
}
@ -61,7 +62,7 @@ StunMessage::~StunMessage() {
bool StunMessage::IsLegacy() const {
if (transaction_id_.size() == kStunLegacyTransactionIdLength)
return true;
ASSERT(transaction_id_.size() == kStunTransactionIdLength);
RTC_DCHECK(transaction_id_.size() == kStunTransactionIdLength);
return false;
}
@ -198,7 +199,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size,
password.c_str(), password.size(),
temp_data.get(), mi_pos,
hmac, sizeof(hmac));
ASSERT(ret == sizeof(hmac));
RTC_DCHECK(ret == sizeof(hmac));
if (ret != sizeof(hmac))
return false;
@ -233,7 +234,7 @@ bool StunMessage::AddMessageIntegrity(const char* key,
key, keylen,
buf.Data(), msg_len_for_hmac,
hmac, sizeof(hmac));
ASSERT(ret == sizeof(hmac));
RTC_DCHECK(ret == sizeof(hmac));
if (ret != sizeof(hmac)) {
LOG(LS_ERROR) << "HMAC computation failed. Message-Integrity "
<< "has dummy value.";
@ -324,7 +325,7 @@ bool StunMessage::Read(ByteBufferReader* buf) {
// RFC3489 instead of RFC5389.
transaction_id.insert(0, magic_cookie);
}
ASSERT(IsValidTransactionId(transaction_id));
RTC_DCHECK(IsValidTransactionId(transaction_id));
transaction_id_ = transaction_id;
if (length_ != buf->Length())
@ -357,7 +358,7 @@ bool StunMessage::Read(ByteBufferReader* buf) {
}
}
ASSERT(buf->Length() == rest);
RTC_DCHECK(buf->Length() == rest);
return true;
}
@ -655,12 +656,12 @@ StunUInt32Attribute::StunUInt32Attribute(uint16_t type)
}
bool StunUInt32Attribute::GetBit(size_t index) const {
ASSERT(index < 32);
RTC_DCHECK(index < 32);
return static_cast<bool>((bits_ >> index) & 0x1);
}
void StunUInt32Attribute::SetBit(size_t index, bool value) {
ASSERT(index < 32);
RTC_DCHECK(index < 32);
bits_ &= ~(1 << index);
bits_ |= value ? (1 << index) : 0;
}
@ -731,14 +732,14 @@ void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) {
}
uint8_t StunByteStringAttribute::GetByte(size_t index) const {
ASSERT(bytes_ != NULL);
ASSERT(index < length());
RTC_DCHECK(bytes_ != NULL);
RTC_DCHECK(index < length());
return static_cast<uint8_t>(bytes_[index]);
}
void StunByteStringAttribute::SetByte(size_t index, uint8_t value) {
ASSERT(bytes_ != NULL);
ASSERT(index < length());
RTC_DCHECK(bytes_ != NULL);
RTC_DCHECK(index < length());
bytes_[index] = value;
}

View File

@ -214,7 +214,7 @@ UDPPort::UDPPort(rtc::Thread* thread,
bool UDPPort::Init() {
stun_keepalive_lifetime_ = GetStunKeepaliveLifetime();
if (!SharedSocket()) {
ASSERT(socket_ == NULL);
RTC_DCHECK(socket_ == NULL);
socket_ = socket_factory()->CreateUdpSocket(
rtc::SocketAddress(ip(), 0), min_port(), max_port());
if (!socket_) {
@ -236,7 +236,7 @@ UDPPort::~UDPPort() {
}
void UDPPort::PrepareAddress() {
ASSERT(requests_.empty());
RTC_DCHECK(requests_.empty());
if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) {
OnLocalAddressReady(socket_, socket_->GetLocalAddress());
}
@ -325,8 +325,8 @@ void UDPPort::OnReadPacket(rtc::AsyncPacketSocket* socket,
size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
ASSERT(socket == socket_);
ASSERT(!remote_addr.IsUnresolvedIP());
RTC_DCHECK(socket == socket_);
RTC_DCHECK(!remote_addr.IsUnresolvedIP());
// Look for a response from the STUN server.
// Even if the response doesn't match one of our outstanding requests, we
@ -356,7 +356,7 @@ void UDPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
void UDPPort::SendStunBindingRequests() {
// We will keep pinging the stun server to make sure our NAT pin-hole stays
// open until the deadline (specified in SendStunBindingRequest).
ASSERT(requests_.empty());
RTC_DCHECK(requests_.empty());
for (ServerAddresses::const_iterator it = server_addresses_.begin();
it != server_addresses_.end(); ++it) {
@ -377,7 +377,7 @@ void UDPPort::ResolveStunAddress(const rtc::SocketAddress& stun_addr) {
void UDPPort::OnResolveResult(const rtc::SocketAddress& input,
int error) {
ASSERT(resolver_.get() != NULL);
RTC_DCHECK(resolver_.get() != NULL);
rtc::SocketAddress resolved;
if (error != 0 ||

View File

@ -13,6 +13,7 @@
#include <algorithm>
#include <memory>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
@ -44,7 +45,7 @@ void StunRequestManager::Send(StunRequest* request) {
void StunRequestManager::SendDelayed(StunRequest* request, int delay) {
request->set_manager(this);
ASSERT(requests_.find(request->id()) == requests_.end());
RTC_DCHECK(requests_.find(request->id()) == requests_.end());
request->set_origin(origin_);
request->Construct();
requests_[request->id()] = request;
@ -76,10 +77,10 @@ bool StunRequestManager::HasRequest(int msg_type) {
}
void StunRequestManager::Remove(StunRequest* request) {
ASSERT(request->manager() == this);
RTC_DCHECK(request->manager() == this);
RequestMap::iterator iter = requests_.find(request->id());
if (iter != requests_.end()) {
ASSERT(iter->second == request);
RTC_DCHECK(iter->second == request);
requests_.erase(iter);
thread_->Clear(request);
}
@ -165,7 +166,7 @@ StunRequest::StunRequest(StunMessage* request)
}
StunRequest::~StunRequest() {
ASSERT(manager_ != NULL);
RTC_DCHECK(manager_ != NULL);
if (manager_) {
manager_->Remove(this);
manager_->thread_->Clear(this);
@ -180,12 +181,12 @@ void StunRequest::Construct() {
origin_));
}
Prepare(msg_);
ASSERT(msg_->type() != 0);
RTC_DCHECK(msg_->type() != 0);
}
}
int StunRequest::type() {
ASSERT(msg_ != NULL);
RTC_DCHECK(msg_ != NULL);
return msg_->type();
}
@ -199,13 +200,13 @@ int StunRequest::Elapsed() const {
void StunRequest::set_manager(StunRequestManager* manager) {
ASSERT(!manager_);
RTC_DCHECK(!manager_);
manager_ = manager;
}
void StunRequest::OnMessage(rtc::Message* pmsg) {
ASSERT(manager_ != NULL);
ASSERT(pmsg->message_id == MSG_STUN_SEND);
RTC_DCHECK(manager_ != NULL);
RTC_DCHECK(pmsg->message_id == MSG_STUN_SEND);
if (timeout_) {
OnTimeout();

View File

@ -67,6 +67,7 @@
#include "webrtc/p2p/base/tcpport.h"
#include "webrtc/p2p/base/common.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@ -251,7 +252,7 @@ int TCPPort::GetError() {
void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket,
rtc::AsyncPacketSocket* new_socket) {
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
Incoming incoming;
incoming.addr = new_socket->GetRemoteAddress();
@ -320,7 +321,7 @@ TCPConnection::TCPConnection(TCPPort* port,
LOG_J(LS_VERBOSE, this)
<< "socket ipaddr: " << socket_->GetLocalAddress().ToString()
<< ",port() ip:" << port->ip().ToString();
ASSERT(socket_->GetLocalAddress().ipaddr() == port->ip());
RTC_DCHECK(socket_->GetLocalAddress().ipaddr() == port->ip());
ConnectSocketSignals(socket);
}
}
@ -378,11 +379,11 @@ void TCPConnection::OnConnectionRequestResponse(ConnectionRequest* req,
Connection::OnReadyToSend();
}
pretending_to_be_writable_ = false;
ASSERT(write_state() == STATE_WRITABLE);
RTC_DCHECK(write_state() == STATE_WRITABLE);
}
void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
ASSERT(socket == socket_.get());
RTC_DCHECK(socket == socket_.get());
// Do not use this connection if the socket bound to a different address than
// the one we asked for. This is seen in Chrome, where TCP sockets cannot be
// given a binding address, and the platform is expected to pick the
@ -419,7 +420,7 @@ void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
}
void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
ASSERT(socket == socket_.get());
RTC_DCHECK(socket == socket_.get());
LOG_J(LS_INFO, this) << "Connection closed with error " << error;
// Guard against the condition where IPC socket will call OnClose for every
@ -478,17 +479,17 @@ void TCPConnection::OnReadPacket(
rtc::AsyncPacketSocket* socket, const char* data, size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
ASSERT(socket == socket_.get());
RTC_DCHECK(socket == socket_.get());
Connection::OnReadPacket(data, size, packet_time);
}
void TCPConnection::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
ASSERT(socket == socket_.get());
RTC_DCHECK(socket == socket_.get());
Connection::OnReadyToSend();
}
void TCPConnection::CreateOutgoingTcpSocket() {
ASSERT(outgoing_);
RTC_DCHECK(outgoing_);
// TODO(guoweis): Handle failures here (unlikely since TCP).
int opts = (remote_candidate().protocol() == SSLTCP_PROTOCOL_NAME)
? rtc::PacketSocketFactory::OPT_TLS_FAKE

View File

@ -16,6 +16,7 @@
#include "webrtc/p2p/base/stun.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nethelpers.h"
@ -317,14 +318,14 @@ void TurnPort::PrepareAddress() {
}
bool TurnPort::CreateTurnClientSocket() {
ASSERT(!socket_ || SharedSocket());
RTC_DCHECK(!socket_ || SharedSocket());
if (server_address_.proto == PROTO_UDP && !SharedSocket()) {
socket_ = socket_factory()->CreateUdpSocket(
rtc::SocketAddress(ip(), 0), min_port(), max_port());
} else if (server_address_.proto == PROTO_TCP ||
server_address_.proto == PROTO_TLS) {
ASSERT(!SharedSocket());
RTC_DCHECK(!SharedSocket());
int opts = rtc::PacketSocketFactory::OPT_STUN;
// Apply server address TLS and insecure bits to options.
@ -375,7 +376,7 @@ bool TurnPort::CreateTurnClientSocket() {
}
void TurnPort::OnSocketConnect(rtc::AsyncPacketSocket* socket) {
ASSERT(server_address_.proto == PROTO_TCP);
RTC_DCHECK(server_address_.proto == PROTO_TCP);
// Do not use this port if the socket bound to a different address than
// the one we asked for. This is seen in Chrome, where TCP sockets cannot be
// given a binding address, and the platform is expected to pick the
@ -420,7 +421,7 @@ void TurnPort::OnSocketConnect(rtc::AsyncPacketSocket* socket) {
void TurnPort::OnSocketClose(rtc::AsyncPacketSocket* socket, int error) {
LOG_J(LS_WARNING, this) << "Connection with server failed, error=" << error;
ASSERT(socket == socket_);
RTC_DCHECK(socket == socket_);
Close();
}
@ -680,7 +681,7 @@ void TurnPort::ResolveTurnAddress(const rtc::SocketAddress& address) {
}
void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) {
ASSERT(resolver == resolver_);
RTC_DCHECK(resolver == resolver_);
// If DNS resolve is failed when trying to connect to the server using TCP,
// one of the reason could be due to DNS queries blocked by firewall.
// In such cases we will try to connect to the server with hostname, assuming
@ -713,7 +714,7 @@ void TurnPort::OnResolveResult(rtc::AsyncResolverInterface* resolver) {
void TurnPort::OnSendStunPacket(const void* data, size_t size,
StunRequest* request) {
ASSERT(connected());
RTC_DCHECK(connected());
rtc::PacketOptions options(DefaultDscpValue());
if (Send(data, size, options) < 0) {
LOG_J(LS_ERROR, this) << "Failed to send TURN message, err="
@ -804,8 +805,8 @@ void TurnPort::OnMessage(rtc::Message* message) {
// Since it's TCP, we have to delete the connected socket and reconnect
// with the alternate server. PrepareAddress will send stun binding once
// the new socket is connected.
ASSERT(server_address().proto == PROTO_TCP);
ASSERT(!SharedSocket());
RTC_DCHECK(server_address().proto == PROTO_TCP);
RTC_DCHECK(!SharedSocket());
delete socket_;
socket_ = NULL;
PrepareAddress();
@ -1021,7 +1022,7 @@ void TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr) {
}
void TurnPort::DestroyEntry(TurnEntry* entry) {
ASSERT(entry != NULL);
RTC_DCHECK(entry != NULL);
entry->SignalDestroyed(entry);
entries_.remove(entry);
delete entry;
@ -1042,12 +1043,12 @@ void TurnPort::HandleConnectionDestroyed(Connection* conn) {
// already destroyed.
const rtc::SocketAddress& remote_address = conn->remote_candidate().address();
TurnEntry* entry = FindEntry(remote_address);
ASSERT(entry != NULL);
RTC_DCHECK(entry != NULL);
ScheduleEntryDestruction(entry);
}
void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) {
ASSERT(entry->destruction_timestamp() == 0);
RTC_DCHECK(entry->destruction_timestamp() == 0);
int64_t timestamp = rtc::TimeMillis();
entry->set_destruction_timestamp(timestamp);
invoker_.AsyncInvokeDelayed<void>(
@ -1057,7 +1058,7 @@ void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) {
}
void TurnPort::CancelEntryDestruction(TurnEntry* entry) {
ASSERT(entry->destruction_timestamp() != 0);
RTC_DCHECK(entry->destruction_timestamp() != 0);
entry->set_destruction_timestamp(0);
}
@ -1368,7 +1369,7 @@ void TurnCreatePermissionRequest::OnTimeout() {
}
void TurnCreatePermissionRequest::OnEntryDestroyed(TurnEntry* entry) {
ASSERT(entry_ == entry);
RTC_DCHECK(entry_ == entry);
entry_ = NULL;
}
@ -1438,7 +1439,7 @@ void TurnChannelBindRequest::OnTimeout() {
}
void TurnChannelBindRequest::OnEntryDestroyed(TurnEntry* entry) {
ASSERT(entry_ == entry);
RTC_DCHECK(entry_ == entry);
entry_ = NULL;
}
@ -1533,7 +1534,7 @@ void TurnEntry::OnCreatePermissionTimeout() {
void TurnEntry::OnChannelBindSuccess() {
LOG_J(LS_INFO, port_) << "Channel bind for " << ext_addr_.ToSensitiveString()
<< " succeeded";
ASSERT(state_ == STATE_BINDING || state_ == STATE_BOUND);
RTC_DCHECK(state_ == STATE_BINDING || state_ == STATE_BOUND);
state_ = STATE_BOUND;
}

View File

@ -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;
}

View File

@ -100,14 +100,14 @@ const uint32_t DISABLE_ALL_PHASES =
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory)
: network_manager_(network_manager), socket_factory_(socket_factory) {
ASSERT(network_manager_ != nullptr);
ASSERT(socket_factory_ != nullptr);
RTC_DCHECK(network_manager_ != nullptr);
RTC_DCHECK(socket_factory_ != nullptr);
Construct();
}
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
: network_manager_(network_manager), socket_factory_(nullptr) {
ASSERT(network_manager_ != nullptr);
RTC_DCHECK(network_manager_ != nullptr);
Construct();
}
@ -115,7 +115,7 @@ BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
const ServerAddresses& stun_servers)
: network_manager_(network_manager), socket_factory_(socket_factory) {
ASSERT(socket_factory_ != NULL);
RTC_DCHECK(socket_factory_ != NULL);
SetConfiguration(stun_servers, std::vector<RelayServerConfig>(), 0, false);
Construct();
}
@ -274,7 +274,7 @@ void BasicPortAllocatorSession::StartGettingPorts() {
}
void BasicPortAllocatorSession::StopGettingPorts() {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
ClearGettingPorts();
// Note: this must be called after ClearGettingPorts because both may set the
// session state and we should set the state to STOPPED.
@ -282,7 +282,7 @@ void BasicPortAllocatorSession::StopGettingPorts() {
}
void BasicPortAllocatorSession::ClearGettingPorts() {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
network_thread_->Clear(this, MSG_ALLOCATE);
for (uint32_t i = 0; i < sequences_.size(); ++i) {
sequences_[i]->Stop();
@ -435,23 +435,23 @@ bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
void BasicPortAllocatorSession::OnMessage(rtc::Message *message) {
switch (message->message_id) {
case MSG_CONFIG_START:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
GetPortConfigurations();
break;
case MSG_CONFIG_READY:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
break;
case MSG_ALLOCATE:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocate();
break;
case MSG_SEQUENCEOBJECTS_CREATED:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocationSequenceObjectsCreated();
break;
case MSG_CONFIG_STOP:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigStop();
break;
default:
@ -491,7 +491,7 @@ void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) {
}
void BasicPortAllocatorSession::OnConfigStop() {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
// If any of the allocated ports have not completed the candidates allocation,
// mark those as error. Since session doesn't need any new candidates
@ -522,7 +522,7 @@ void BasicPortAllocatorSession::OnConfigStop() {
}
void BasicPortAllocatorSession::AllocatePorts() {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE);
}
@ -536,7 +536,7 @@ void BasicPortAllocatorSession::OnAllocate() {
std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
std::vector<rtc::Network*> networks;
rtc::NetworkManager* network_manager = allocator_->network_manager();
ASSERT(network_manager != nullptr);
RTC_DCHECK(network_manager != nullptr);
// If the network permission state is BLOCKED, we just act as if the flag has
// been passed in.
if (network_manager->enumeration_permission() ==
@ -720,9 +720,9 @@ void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
void BasicPortAllocatorSession::OnCandidateReady(
Port* port, const Candidate& c) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
PortData* data = FindPort(port);
ASSERT(data != NULL);
RTC_DCHECK(data != NULL);
LOG_J(LS_INFO, port) << "Gathered candidate: " << c.ToSensitiveString();
// Discarding any candidate signal if port allocation status is
// already done with gathering.
@ -831,10 +831,10 @@ void BasicPortAllocatorSession::PruneAllPorts() {
}
void BasicPortAllocatorSession::OnPortComplete(Port* port) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
LOG_J(LS_INFO, port) << "Port completed gathering candidates.";
PortData* data = FindPort(port);
ASSERT(data != NULL);
RTC_DCHECK(data != NULL);
// Ignore any late signals.
if (!data->inprogress()) {
@ -848,10 +848,10 @@ void BasicPortAllocatorSession::OnPortComplete(Port* port) {
}
void BasicPortAllocatorSession::OnPortError(Port* port) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
LOG_J(LS_INFO, port) << "Port encountered error while gathering candidates.";
PortData* data = FindPort(port);
ASSERT(data != NULL);
RTC_DCHECK(data != NULL);
// We might have already given up on this port and stopped it.
if (!data->inprogress()) {
return;
@ -965,7 +965,7 @@ void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
void BasicPortAllocatorSession::OnPortDestroyed(
PortInterface* port) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
for (std::vector<PortData>::iterator iter = ports_.begin();
iter != ports_.end(); ++iter) {
if (port == iter->port()) {
@ -1123,8 +1123,8 @@ void AllocationSequence::Stop() {
}
void AllocationSequence::OnMessage(rtc::Message* msg) {
ASSERT(rtc::Thread::Current() == session_->network_thread());
ASSERT(msg->message_id == MSG_ALLOCATION_PHASE);
RTC_DCHECK(rtc::Thread::Current() == session_->network_thread());
RTC_DCHECK(msg->message_id == MSG_ALLOCATION_PHASE);
const char* const PHASE_NAMES[kNumPhases] = {
"Udp", "Relay", "Tcp", "SslTcp"
@ -1292,7 +1292,7 @@ void AllocationSequence::CreateRelayPorts() {
// If BasicPortAllocatorSession::OnAllocate left relay ports enabled then we
// ought to have a relay list for them here.
ASSERT(config_ && !config_->relays.empty());
RTC_DCHECK(config_ && !config_->relays.empty());
if (!(config_ && !config_->relays.empty())) {
LOG(LS_WARNING)
<< "AllocationSequence: No relay server configured, skipping.";
@ -1393,7 +1393,7 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
*relay_port, config.credentials, config.priority,
session_->allocator()->origin());
}
ASSERT(port != NULL);
RTC_DCHECK(port != NULL);
port->SetTlsCertPolicy(config.tls_cert_policy);
session_->AddAllocatedPort(port, this, true);
}
@ -1403,7 +1403,7 @@ void AllocationSequence::OnReadPacket(
rtc::AsyncPacketSocket* socket, const char* data, size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
ASSERT(socket == udp_socket_.get());
RTC_DCHECK(socket == udp_socket_.get());
bool turn_port_found = false;

View File

@ -16,6 +16,7 @@
#include <vector>
#include "webrtc/p2p/base/portallocator.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/network.h"
#include "webrtc/base/thread.h"
@ -154,7 +155,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession,
}
void set_has_pairable_candidate(bool has_pairable_candidate) {
if (has_pairable_candidate) {
ASSERT(state_ == STATE_INPROGRESS);
RTC_DCHECK(state_ == STATE_INPROGRESS);
}
has_pairable_candidate_ = has_pairable_candidate;
}
@ -162,7 +163,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession,
state_ = STATE_COMPLETE;
}
void set_error() {
ASSERT(state_ == STATE_INPROGRESS);
RTC_DCHECK(state_ == STATE_INPROGRESS);
state_ = STATE_ERROR;
}

View File

@ -10,6 +10,7 @@
#include "webrtc/p2p/client/socketmonitor.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
namespace cricket {
@ -50,7 +51,7 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) {
rtc::CritScope cs(&crit_);
switch (message->message_id) {
case MSG_MONITOR_START:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
if (!monitoring_) {
monitoring_ = true;
PollConnectionStats_w();
@ -58,7 +59,7 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) {
break;
case MSG_MONITOR_STOP:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
if (monitoring_) {
monitoring_ = false;
network_thread_->Clear(this);
@ -66,12 +67,12 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) {
break;
case MSG_MONITOR_POLL:
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
PollConnectionStats_w();
break;
case MSG_MONITOR_SIGNAL: {
ASSERT(rtc::Thread::Current() == monitoring_thread_);
RTC_DCHECK(rtc::Thread::Current() == monitoring_thread_);
std::vector<ConnectionInfo> infos = connection_infos_;
crit_.Leave();
SignalUpdate(this, infos);
@ -82,7 +83,7 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) {
}
void ConnectionMonitor::PollConnectionStats_w() {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
rtc::CritScope cs(&crit_);
// Gather connection infos

View File

@ -10,6 +10,7 @@
#include "webrtc/p2p/quic/quictransport.h"
#include "webrtc/base/checks.h"
#include "webrtc/p2p/base/p2ptransportchannel.h"
namespace cricket {
@ -87,7 +88,7 @@ void QuicTransport::DestroyTransportChannel(TransportChannelImpl* channel) {
}
bool QuicTransport::GetSslRole(rtc::SSLRole* ssl_role) const {
ASSERT(ssl_role != NULL);
RTC_DCHECK(ssl_role != NULL);
*ssl_role = local_role_;
return true;
}

View File

@ -273,8 +273,8 @@ int QuicTransportChannel::SendPacket(const char* data,
// - Once the QUIC handshake completes, the state is that of the
// |channel_| again.
void QuicTransportChannel::OnWritableState(TransportChannel* channel) {
ASSERT(rtc::Thread::Current() == network_thread_);
ASSERT(channel == channel_.get());
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(channel == channel_.get());
LOG_J(LS_VERBOSE, this)
<< "QuicTransportChannel: channel writable state changed to "
<< channel_->writable();
@ -307,8 +307,8 @@ void QuicTransportChannel::OnWritableState(TransportChannel* channel) {
}
void QuicTransportChannel::OnReceivingState(TransportChannel* channel) {
ASSERT(rtc::Thread::Current() == network_thread_);
ASSERT(channel == channel_.get());
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(channel == channel_.get());
LOG_J(LS_VERBOSE, this)
<< "QuicTransportChannel: channel receiving state changed to "
<< channel_->receiving();
@ -323,9 +323,9 @@ void QuicTransportChannel::OnReadPacket(TransportChannel* channel,
size_t size,
const rtc::PacketTime& packet_time,
int flags) {
ASSERT(rtc::Thread::Current() == network_thread_);
ASSERT(channel == channel_.get());
ASSERT(flags == 0);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(channel == channel_.get());
RTC_DCHECK(flags == 0);
switch (quic_state_) {
case QUIC_TRANSPORT_NEW:
@ -360,7 +360,7 @@ void QuicTransportChannel::OnReadPacket(TransportChannel* channel,
void QuicTransportChannel::OnSentPacket(TransportChannel* channel,
const rtc::SentPacket& sent_packet) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
SignalSentPacket(this, sent_packet);
}
@ -371,24 +371,24 @@ void QuicTransportChannel::OnReadyToSend(TransportChannel* channel) {
}
void QuicTransportChannel::OnGatheringState(TransportChannelImpl* channel) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalGatheringState(this);
}
void QuicTransportChannel::OnCandidateGathered(TransportChannelImpl* channel,
const Candidate& c) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalCandidateGathered(this, c);
}
void QuicTransportChannel::OnRoleConflict(TransportChannelImpl* channel) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalRoleConflict(this);
}
void QuicTransportChannel::OnRouteChange(TransportChannel* channel,
const Candidate& candidate) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalRouteChange(this, candidate);
}
@ -397,14 +397,14 @@ void QuicTransportChannel::OnSelectedCandidatePairChanged(
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalSelectedCandidatePairChanged(this, selected_candidate_pair,
last_sent_packet_id, ready_to_send);
}
void QuicTransportChannel::OnChannelStateChanged(
TransportChannelImpl* channel) {
ASSERT(channel == channel_.get());
RTC_DCHECK(channel == channel_.get());
SignalStateChanged(this);
}
@ -506,7 +506,7 @@ bool QuicTransportChannel::StartQuicHandshake() {
}
bool QuicTransportChannel::HandleQuicPacket(const char* data, size_t size) {
ASSERT(rtc::Thread::Current() == network_thread_);
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
return quic_->OnReadPacket(data, size);
}

View File

@ -14,6 +14,7 @@
#include "webrtc/api/mediacontroller.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h"
@ -154,7 +155,7 @@ void ChannelManager::GetSupportedDataCodecs(
}
bool ChannelManager::Init() {
ASSERT(!initialized_);
RTC_DCHECK(!initialized_);
if (initialized_) {
return false;
}
@ -169,17 +170,17 @@ bool ChannelManager::Init() {
initialized_ = worker_thread_->Invoke<bool>(
RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this));
ASSERT(initialized_);
RTC_DCHECK(initialized_);
return initialized_;
}
bool ChannelManager::InitMediaEngine_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
return media_engine_->Init();
}
void ChannelManager::Terminate() {
ASSERT(initialized_);
RTC_DCHECK(initialized_);
if (!initialized_) {
return;
}
@ -189,12 +190,12 @@ void ChannelManager::Terminate() {
}
void ChannelManager::DestructorDeletes_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
media_engine_.reset(NULL);
}
void ChannelManager::Terminate_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
// Need to destroy the voice/video channels
while (!video_channels_.empty()) {
DestroyVideoChannel_w(video_channels_.back());
@ -226,9 +227,9 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w(
bool rtcp,
bool srtp_required,
const AudioOptions& options) {
ASSERT(initialized_);
ASSERT(worker_thread_ == rtc::Thread::Current());
ASSERT(nullptr != media_controller);
RTC_DCHECK(initialized_);
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(nullptr != media_controller);
VoiceMediaChannel* media_channel = media_engine_->CreateChannel(
media_controller->call_w(), media_controller->config(), options);
if (!media_channel)
@ -258,11 +259,11 @@ void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) {
void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) {
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel_w");
// Destroy voice channel.
ASSERT(initialized_);
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(initialized_);
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
VoiceChannels::iterator it = std::find(voice_channels_.begin(),
voice_channels_.end(), voice_channel);
ASSERT(it != voice_channels_.end());
RTC_DCHECK(it != voice_channels_.end());
if (it == voice_channels_.end())
return;
voice_channels_.erase(it);
@ -291,9 +292,9 @@ VideoChannel* ChannelManager::CreateVideoChannel_w(
bool rtcp,
bool srtp_required,
const VideoOptions& options) {
ASSERT(initialized_);
ASSERT(worker_thread_ == rtc::Thread::Current());
ASSERT(nullptr != media_controller);
RTC_DCHECK(initialized_);
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(nullptr != media_controller);
VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel(
media_controller->call_w(), media_controller->config(), options);
if (media_channel == NULL) {
@ -324,11 +325,11 @@ void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) {
void ChannelManager::DestroyVideoChannel_w(VideoChannel* video_channel) {
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel_w");
// Destroy video channel.
ASSERT(initialized_);
ASSERT(worker_thread_ == rtc::Thread::Current());
RTC_DCHECK(initialized_);
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
VideoChannels::iterator it = std::find(video_channels_.begin(),
video_channels_.end(), video_channel);
ASSERT(it != video_channels_.end());
RTC_DCHECK(it != video_channels_.end());
if (it == video_channels_.end())
return;
@ -357,7 +358,7 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel_w(
bool rtcp,
bool srtp_required) {
// This is ok to alloc from a thread other than the worker thread.
ASSERT(initialized_);
RTC_DCHECK(initialized_);
MediaConfig config;
if (media_controller) {
config = media_controller->config();
@ -393,10 +394,10 @@ void ChannelManager::DestroyRtpDataChannel(RtpDataChannel* data_channel) {
void ChannelManager::DestroyRtpDataChannel_w(RtpDataChannel* data_channel) {
TRACE_EVENT0("webrtc", "ChannelManager::DestroyRtpDataChannel_w");
// Destroy data channel.
ASSERT(initialized_);
RTC_DCHECK(initialized_);
RtpDataChannels::iterator it =
std::find(data_channels_.begin(), data_channels_.end(), data_channel);
ASSERT(it != data_channels_.end());
RTC_DCHECK(it != data_channels_.end());
if (it == data_channels_.end())
return;

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/pc/channelmanager.h"
#include "webrtc/pc/mediamonitor.h"
@ -50,7 +51,7 @@ void MediaMonitor::OnMessage(rtc::Message* message) {
switch (message->message_id) {
case MSG_MONITOR_START:
ASSERT(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
if (!monitoring_) {
monitoring_ = true;
PollMediaChannel();
@ -58,7 +59,7 @@ void MediaMonitor::OnMessage(rtc::Message* message) {
break;
case MSG_MONITOR_STOP:
ASSERT(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
if (monitoring_) {
monitoring_ = false;
worker_thread_->Clear(this);
@ -66,12 +67,12 @@ void MediaMonitor::OnMessage(rtc::Message* message) {
break;
case MSG_MONITOR_POLL:
ASSERT(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
PollMediaChannel();
break;
case MSG_MONITOR_SIGNAL:
ASSERT(rtc::Thread::Current() == monitor_thread_);
RTC_DCHECK(rtc::Thread::Current() == monitor_thread_);
Update();
break;
}
@ -79,7 +80,7 @@ void MediaMonitor::OnMessage(rtc::Message* message) {
void MediaMonitor::PollMediaChannel() {
rtc::CritScope cs(&crit_);
ASSERT(rtc::Thread::Current() == worker_thread_);
RTC_DCHECK(rtc::Thread::Current() == worker_thread_);
GetStats();

View File

@ -365,7 +365,7 @@ class UsedIds {
while (IsIdUsed(next_id_) && next_id_ >= min_allowed_id_) {
--next_id_;
}
ASSERT(next_id_ >= min_allowed_id_);
RTC_DCHECK(next_id_ >= min_allowed_id_);
return next_id_;
}
@ -1470,7 +1470,7 @@ SessionDescription* MediaSessionDescriptionFactory::CreateAnswer(
return NULL;
}
} else {
ASSERT(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA));
RTC_DCHECK(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA));
if (!AddDataContentForAnswer(offer, options, current_description,
&current_streams, answer.get())) {
return NULL;

View File

@ -185,7 +185,7 @@ AndroidNetworkMonitor::AndroidNetworkMonitor()
"init",
"(Landroid/content/Context;)Lorg/webrtc/NetworkMonitor;"),
application_context_)) {
ASSERT(application_context_ != nullptr);
RTC_DCHECK(application_context_ != nullptr);
CHECK_EXCEPTION(jni()) << "Error during NetworkMonitor.init";
if (android_sdk_int_ <= 0) {
jmethodID m = GetStaticMethodID(jni(), *j_network_monitor_class_,