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}
This commit is contained in:
parent
9d07309426
commit
b7aac6f5f4
@ -1126,11 +1126,9 @@ void SdpOfferAnswerHandler::CreateOffer(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// The operation completes asynchronously when the wrapper is invoked.
|
// The operation completes asynchronously when the wrapper is invoked.
|
||||||
rtc::scoped_refptr<CreateSessionDescriptionObserverOperationWrapper>
|
auto observer_wrapper = rtc::make_ref_counted<
|
||||||
observer_wrapper(new rtc::RefCountedObject<
|
CreateSessionDescriptionObserverOperationWrapper>(
|
||||||
CreateSessionDescriptionObserverOperationWrapper>(
|
std::move(observer_refptr), std::move(operations_chain_callback));
|
||||||
std::move(observer_refptr),
|
|
||||||
std::move(operations_chain_callback)));
|
|
||||||
this_weak_ptr->DoCreateOffer(options, observer_wrapper);
|
this_weak_ptr->DoCreateOffer(options, observer_wrapper);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1160,9 +1158,8 @@ void SdpOfferAnswerHandler::SetLocalDescription(
|
|||||||
// `observer_refptr` is invoked in a posted message.
|
// `observer_refptr` is invoked in a posted message.
|
||||||
this_weak_ptr->DoSetLocalDescription(
|
this_weak_ptr->DoSetLocalDescription(
|
||||||
std::move(desc),
|
std::move(desc),
|
||||||
rtc::scoped_refptr<SetLocalDescriptionObserverInterface>(
|
rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
|
||||||
new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
|
this_weak_ptr, observer_refptr));
|
||||||
this_weak_ptr, observer_refptr)));
|
|
||||||
// For backwards-compatability reasons, we declare the operation as
|
// For backwards-compatability reasons, we declare the operation as
|
||||||
// completed here (rather than in a post), so that the operation chain
|
// completed here (rather than in a post), so that the operation chain
|
||||||
// is not blocked by this operation when the observer is invoked. This
|
// is not blocked by this operation when the observer is invoked. This
|
||||||
@ -1203,7 +1200,7 @@ void SdpOfferAnswerHandler::SetLocalDescription(
|
|||||||
SetSessionDescriptionObserver* observer) {
|
SetSessionDescriptionObserver* observer) {
|
||||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||||
SetLocalDescription(
|
SetLocalDescription(
|
||||||
new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
|
rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
|
||||||
weak_ptr_factory_.GetWeakPtr(), observer));
|
weak_ptr_factory_.GetWeakPtr(), observer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,10 +1209,9 @@ void SdpOfferAnswerHandler::SetLocalDescription(
|
|||||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||||
// The `create_sdp_observer` handles performing DoSetLocalDescription() with
|
// The `create_sdp_observer` handles performing DoSetLocalDescription() with
|
||||||
// the resulting description as well as completing the operation.
|
// the resulting description as well as completing the operation.
|
||||||
rtc::scoped_refptr<ImplicitCreateSessionDescriptionObserver>
|
auto create_sdp_observer =
|
||||||
create_sdp_observer(
|
rtc::make_ref_counted<ImplicitCreateSessionDescriptionObserver>(
|
||||||
new rtc::RefCountedObject<ImplicitCreateSessionDescriptionObserver>(
|
weak_ptr_factory_.GetWeakPtr(), observer);
|
||||||
weak_ptr_factory_.GetWeakPtr(), observer));
|
|
||||||
// Chain this operation. If asynchronous operations are pending on the chain,
|
// Chain this operation. If asynchronous operations are pending on the chain,
|
||||||
// this operation will be queued to be invoked, otherwise the contents of the
|
// this operation will be queued to be invoked, otherwise the contents of the
|
||||||
// lambda will execute immediately.
|
// lambda will execute immediately.
|
||||||
@ -1513,9 +1509,8 @@ void SdpOfferAnswerHandler::SetRemoteDescription(
|
|||||||
// `observer_refptr` is invoked in a posted message.
|
// `observer_refptr` is invoked in a posted message.
|
||||||
this_weak_ptr->DoSetRemoteDescription(
|
this_weak_ptr->DoSetRemoteDescription(
|
||||||
std::move(desc),
|
std::move(desc),
|
||||||
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>(
|
rtc::make_ref_counted<SetSessionDescriptionObserverAdapter>(
|
||||||
new rtc::RefCountedObject<SetSessionDescriptionObserverAdapter>(
|
this_weak_ptr, observer_refptr));
|
||||||
this_weak_ptr, observer_refptr)));
|
|
||||||
// For backwards-compatability reasons, we declare the operation as
|
// For backwards-compatability reasons, we declare the operation as
|
||||||
// completed here (rather than in a post), so that the operation chain
|
// completed here (rather than in a post), so that the operation chain
|
||||||
// is not blocked by this operation when the observer is invoked. This
|
// is not blocked by this operation when the observer is invoked. This
|
||||||
@ -2062,11 +2057,9 @@ void SdpOfferAnswerHandler::CreateAnswer(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// The operation completes asynchronously when the wrapper is invoked.
|
// The operation completes asynchronously when the wrapper is invoked.
|
||||||
rtc::scoped_refptr<CreateSessionDescriptionObserverOperationWrapper>
|
auto observer_wrapper = rtc::make_ref_counted<
|
||||||
observer_wrapper(new rtc::RefCountedObject<
|
CreateSessionDescriptionObserverOperationWrapper>(
|
||||||
CreateSessionDescriptionObserverOperationWrapper>(
|
std::move(observer_refptr), std::move(operations_chain_callback));
|
||||||
std::move(observer_refptr),
|
|
||||||
std::move(operations_chain_callback)));
|
|
||||||
this_weak_ptr->DoCreateAnswer(options, observer_wrapper);
|
this_weak_ptr->DoCreateAnswer(options, observer_wrapper);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,10 +73,12 @@ class FinalRefCountedObject final : public T {
|
|||||||
FinalRefCountedObject& operator=(const FinalRefCountedObject&) = delete;
|
FinalRefCountedObject& operator=(const FinalRefCountedObject&) = delete;
|
||||||
|
|
||||||
void AddRef() const { ref_count_.IncRef(); }
|
void AddRef() const { ref_count_.IncRef(); }
|
||||||
void Release() const {
|
RefCountReleaseStatus Release() const {
|
||||||
if (ref_count_.DecRef() == RefCountReleaseStatus::kDroppedLastRef) {
|
const auto status = ref_count_.DecRef();
|
||||||
|
if (status == RefCountReleaseStatus::kDroppedLastRef) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
bool HasOneRef() const { return ref_count_.HasOneRef(); }
|
bool HasOneRef() const { return ref_count_.HasOneRef(); }
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user