Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 3699236

Browse files
Tomas GunnarssonCommit Bot
authored andcommitted
Update RTC_DCHECK_IS_ON checks in SdpOfferAnswerHandler
...and OperationsChain. Bug: none Change-Id: Iac07db38deb02fda0a9194b73755cd329def8e98 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186840 Reviewed-by: Harald Alvestrand <[email protected]> Commit-Queue: Tommi <[email protected]> Cr-Commit-Position: refs/heads/master@{#32327}
1 parent f8e62fc commit 3699236

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

pc/sdp_offer_answer.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,14 @@ class CreateSessionDescriptionObserverOperationWrapper
744744
RTC_DCHECK(observer_);
745745
}
746746
~CreateSessionDescriptionObserverOperationWrapper() override {
747+
#if RTC_DCHECK_IS_ON
747748
RTC_DCHECK(was_called_);
749+
#endif
748750
}
749751

750752
void OnSuccess(SessionDescriptionInterface* desc) override {
753+
#if RTC_DCHECK_IS_ON
751754
RTC_DCHECK(!was_called_);
752-
#ifdef RTC_DCHECK_IS_ON
753755
was_called_ = true;
754756
#endif // RTC_DCHECK_IS_ON
755757
// Completing the operation before invoking the observer allows the observer
@@ -759,16 +761,16 @@ class CreateSessionDescriptionObserverOperationWrapper
759761
}
760762

761763
void OnFailure(RTCError error) override {
764+
#if RTC_DCHECK_IS_ON
762765
RTC_DCHECK(!was_called_);
763-
#ifdef RTC_DCHECK_IS_ON
764766
was_called_ = true;
765767
#endif // RTC_DCHECK_IS_ON
766768
operation_complete_callback_();
767769
observer_->OnFailure(std::move(error));
768770
}
769771

770772
private:
771-
#ifdef RTC_DCHECK_IS_ON
773+
#if RTC_DCHECK_IS_ON
772774
bool was_called_ = false;
773775
#endif // RTC_DCHECK_IS_ON
774776
rtc::scoped_refptr<CreateSessionDescriptionObserver> observer_;
@@ -2919,6 +2921,7 @@ SdpOfferAnswerHandler::AssociateTransceiver(
29192921
const ContentInfo* old_local_content,
29202922
const ContentInfo* old_remote_content) {
29212923
RTC_DCHECK(IsUnifiedPlan());
2924+
#if RTC_DCHECK_IS_ON
29222925
// If this is an offer then the m= section might be recycled. If the m=
29232926
// section is being recycled (defined as: rejected in the current local or
29242927
// remote description and not rejected in new description), the transceiver
@@ -2933,6 +2936,8 @@ SdpOfferAnswerHandler::AssociateTransceiver(
29332936
// The transceiver should be disassociated in RemoveStoppedTransceivers()
29342937
RTC_DCHECK(!old_transceiver);
29352938
}
2939+
#endif
2940+
29362941
const MediaContentDescription* media_desc = content.media_description();
29372942
auto transceiver = transceivers().FindByMid(content.name);
29382943
if (source == cricket::CS_LOCAL) {
@@ -2984,6 +2989,9 @@ SdpOfferAnswerHandler::AssociateTransceiver(
29842989
transceivers().StableState(transceiver)->set_newly_created();
29852990
}
29862991
}
2992+
2993+
RTC_DCHECK(transceiver);
2994+
29872995
// Check if the offer indicated simulcast but the answer rejected it.
29882996
// This can happen when simulcast is not supported on the remote party.
29892997
if (SimulcastIsRejected(old_local_content, *media_desc)) {
@@ -2996,12 +3004,13 @@ SdpOfferAnswerHandler::AssociateTransceiver(
29963004
}
29973005
}
29983006
}
2999-
RTC_DCHECK(transceiver);
3007+
30003008
if (transceiver->media_type() != media_desc->type()) {
30013009
LOG_AND_RETURN_ERROR(
30023010
RTCErrorType::INVALID_PARAMETER,
30033011
"Transceiver type does not match media description type.");
30043012
}
3013+
30053014
if (media_desc->HasSimulcast()) {
30063015
std::vector<SimulcastLayer> layers =
30073016
source == cricket::CS_LOCAL

rtc_base/operations_chain.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ OperationsChain::CallbackHandle::CallbackHandle(
1919
: operations_chain_(std::move(operations_chain)) {}
2020

2121
OperationsChain::CallbackHandle::~CallbackHandle() {
22+
#if RTC_DCHECK_IS_ON
2223
RTC_DCHECK(has_run_);
24+
#endif
2325
}
2426

2527
void OperationsChain::CallbackHandle::OnOperationComplete() {
28+
#if RTC_DCHECK_IS_ON
2629
RTC_DCHECK(!has_run_);
27-
#ifdef RTC_DCHECK_IS_ON
2830
has_run_ = true;
2931
#endif // RTC_DCHECK_IS_ON
3032
operations_chain_->OnOperationComplete();

rtc_base/operations_chain.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ class OperationWithFunctor final : public Operation {
5151
: functor_(std::forward<FunctorT>(functor)),
5252
callback_(std::move(callback)) {}
5353

54-
~OperationWithFunctor() override { RTC_DCHECK(has_run_); }
54+
~OperationWithFunctor() override {
55+
#if RTC_DCHECK_IS_ON
56+
RTC_DCHECK(has_run_);
57+
#endif // RTC_DCHECK_IS_ON
58+
}
5559

5660
void Run() override {
61+
#if RTC_DCHECK_IS_ON
5762
RTC_DCHECK(!has_run_);
58-
#ifdef RTC_DCHECK_IS_ON
5963
has_run_ = true;
6064
#endif // RTC_DCHECK_IS_ON
6165
// The functor being executed may invoke the callback synchronously,
@@ -71,7 +75,7 @@ class OperationWithFunctor final : public Operation {
7175
private:
7276
typename std::remove_reference<FunctorT>::type functor_;
7377
std::function<void()> callback_;
74-
#ifdef RTC_DCHECK_IS_ON
78+
#if RTC_DCHECK_IS_ON
7579
bool has_run_ = false;
7680
#endif // RTC_DCHECK_IS_ON
7781
};
@@ -168,7 +172,7 @@ class OperationsChain final : public RefCountedObject<RefCountInterface> {
168172

169173
private:
170174
scoped_refptr<OperationsChain> operations_chain_;
171-
#ifdef RTC_DCHECK_IS_ON
175+
#if RTC_DCHECK_IS_ON
172176
bool has_run_ = false;
173177
#endif // RTC_DCHECK_IS_ON
174178

0 commit comments

Comments
 (0)