Update SdpOfferAnswerHandler to use rtc::make_ref_counted
Also change return type of FinalRefCountedObject::Release() to
RefCountReleaseStatus, for consistency with other refcount classes.
Bug: webrtc:12701
Change-Id: I37c325e78ba7ae3e220b618da02cb243604ca4cc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229590
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34849}
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 82f13ee..b8a43a9 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -1126,11 +1126,9 @@
return;
}
// The operation completes asynchronously when the wrapper is invoked.
- rtc::scoped_refptr<CreateSessionDescriptionObserverOperationWrapper>
- observer_wrapper(new rtc::RefCountedObject<
- CreateSessionDescriptionObserverOperationWrapper>(
- std::move(observer_refptr),
- std::move(operations_chain_callback)));
+ auto observer_wrapper = rtc::make_ref_counted<
+ CreateSessionDescriptionObserverOperationWrapper>(
+ std::move(observer_refptr), std::move(operations_chain_callback));
this_weak_ptr->DoCreateOffer(options, observer_wrapper);
});
}
@@ -1160,9 +1158,8 @@
// `observer_refptr` is invoked in a posted message.
this_weak_ptr->DoSetLocalDescription(
std::move(desc),
- rtc::scoped_refptr<SetLocalDescriptionObserverInterface>(
- new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
- this_weak_ptr, observer_refptr)));
+ rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
+ this_weak_ptr, observer_refptr));
// For backwards-compatability reasons, we declare the operation as
// completed here (rather than in a post), so that the operation chain
// is not blocked by this operation when the observer is invoked. This
@@ -1203,7 +1200,7 @@
SetSessionDescriptionObserver* observer) {
RTC_DCHECK_RUN_ON(signaling_thread());
SetLocalDescription(
- new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
+ rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
weak_ptr_factory_.GetWeakPtr(), observer));
}
@@ -1212,10 +1209,9 @@
RTC_DCHECK_RUN_ON(signaling_thread());
// The `create_sdp_observer` handles performing DoSetLocalDescription() with
// the resulting description as well as completing the operation.
- rtc::scoped_refptr<ImplicitCreateSessionDescriptionObserver>
- create_sdp_observer(
- new rtc::RefCountedObject<ImplicitCreateSessionDescriptionObserver>(
- weak_ptr_factory_.GetWeakPtr(), observer));
+ auto create_sdp_observer =
+ rtc::make_ref_counted<ImplicitCreateSessionDescriptionObserver>(
+ weak_ptr_factory_.GetWeakPtr(), observer);
// Chain this operation. If asynchronous operations are pending on the chain,
// this operation will be queued to be invoked, otherwise the contents of the
// lambda will execute immediately.
@@ -1513,9 +1509,8 @@
// `observer_refptr` is invoked in a posted message.
this_weak_ptr->DoSetRemoteDescription(
std::move(desc),
- rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>(
- new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
- this_weak_ptr, observer_refptr)));
+ rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
+ this_weak_ptr, observer_refptr));
// For backwards-compatability reasons, we declare the operation as
// completed here (rather than in a post), so that the operation chain
// is not blocked by this operation when the observer is invoked. This
@@ -2062,11 +2057,9 @@
return;
}
// The operation completes asynchronously when the wrapper is invoked.
- rtc::scoped_refptr<CreateSessionDescriptionObserverOperationWrapper>
- observer_wrapper(new rtc::RefCountedObject<
- CreateSessionDescriptionObserverOperationWrapper>(
- std::move(observer_refptr),
- std::move(operations_chain_callback)));
+ auto observer_wrapper = rtc::make_ref_counted<
+ CreateSessionDescriptionObserverOperationWrapper>(
+ std::move(observer_refptr), std::move(operations_chain_callback));
this_weak_ptr->DoCreateAnswer(options, observer_wrapper);
});
}