datachannel: Remove buffered_amount_ variable

The queued_send_data_ packet queue contains the actual data and has an
efficient byte_count() accessor. It removes the need to do some manual
accounting on the side.

Bug: webrtc:13288
Change-Id: Ie6bc39c344186160c630bcf337631614c6d9ee10
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235372
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35227}
This commit is contained in:
Florent Castelli
2021-10-18 11:13:22 +02:00
committed by WebRTC LUCI CQ
parent 486cbd37ca
commit 6595685b3b
2 changed files with 1 additions and 10 deletions

View File

@ -253,7 +253,7 @@ bool SctpDataChannel::reliable() const {
uint64_t SctpDataChannel::buffered_amount() const { uint64_t SctpDataChannel::buffered_amount() const {
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
return buffered_amount_; return queued_send_data_.byte_count();
} }
void SctpDataChannel::Close() { void SctpDataChannel::Close() {
@ -305,8 +305,6 @@ bool SctpDataChannel::Send(const DataBuffer& buffer) {
return false; return false;
} }
buffered_amount_ += buffer.size();
// If the queue is non-empty, we're waiting for SignalReadyToSend, // If the queue is non-empty, we're waiting for SignalReadyToSend,
// so just add to the end of the queue and keep waiting. // so just add to the end of the queue and keep waiting.
if (!queued_send_data_.Empty()) { if (!queued_send_data_.Empty()) {
@ -486,8 +484,6 @@ void SctpDataChannel::CloseAbruptlyWithError(RTCError error) {
} }
// Closing abruptly means any queued data gets thrown away. // Closing abruptly means any queued data gets thrown away.
buffered_amount_ = 0;
queued_send_data_.Clear(); queued_send_data_.Clear();
queued_control_data_.Clear(); queued_control_data_.Clear();
@ -643,8 +639,6 @@ bool SctpDataChannel::SendDataMessage(const DataBuffer& buffer,
++messages_sent_; ++messages_sent_;
bytes_sent_ += buffer.size(); bytes_sent_ += buffer.size();
RTC_DCHECK(buffered_amount_ >= buffer.size());
buffered_amount_ -= buffer.size();
if (observer_ && buffer.size() > 0) { if (observer_ && buffer.size() > 0) {
observer_->OnBufferedAmountChange(buffer.size()); observer_->OnBufferedAmountChange(buffer.size());
} }

View File

@ -266,9 +266,6 @@ class SctpDataChannel : public DataChannelInterface,
uint64_t bytes_sent_ RTC_GUARDED_BY(signaling_thread_) = 0; uint64_t bytes_sent_ RTC_GUARDED_BY(signaling_thread_) = 0;
uint32_t messages_received_ RTC_GUARDED_BY(signaling_thread_) = 0; uint32_t messages_received_ RTC_GUARDED_BY(signaling_thread_) = 0;
uint64_t bytes_received_ RTC_GUARDED_BY(signaling_thread_) = 0; uint64_t bytes_received_ RTC_GUARDED_BY(signaling_thread_) = 0;
// Number of bytes of data that have been queued using Send(). Increased
// before each transport send and decreased after each successful send.
uint64_t buffered_amount_ RTC_GUARDED_BY(signaling_thread_) = 0;
SctpDataChannelProviderInterface* const provider_ SctpDataChannelProviderInterface* const provider_
RTC_GUARDED_BY(signaling_thread_); RTC_GUARDED_BY(signaling_thread_);
HandshakeState handshake_state_ RTC_GUARDED_BY(signaling_thread_) = HandshakeState handshake_state_ RTC_GUARDED_BY(signaling_thread_) =