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}
diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc
index 2ceef83..f59dd1e 100644
--- a/pc/sctp_data_channel.cc
+++ b/pc/sctp_data_channel.cc
@@ -253,7 +253,7 @@
uint64_t SctpDataChannel::buffered_amount() const {
RTC_DCHECK_RUN_ON(signaling_thread_);
- return buffered_amount_;
+ return queued_send_data_.byte_count();
}
void SctpDataChannel::Close() {
@@ -305,8 +305,6 @@
return false;
}
- buffered_amount_ += buffer.size();
-
// If the queue is non-empty, we're waiting for SignalReadyToSend,
// so just add to the end of the queue and keep waiting.
if (!queued_send_data_.Empty()) {
@@ -486,8 +484,6 @@
}
// Closing abruptly means any queued data gets thrown away.
- buffered_amount_ = 0;
-
queued_send_data_.Clear();
queued_control_data_.Clear();
@@ -643,8 +639,6 @@
++messages_sent_;
bytes_sent_ += buffer.size();
- RTC_DCHECK(buffered_amount_ >= buffer.size());
- buffered_amount_ -= buffer.size();
if (observer_ && buffer.size() > 0) {
observer_->OnBufferedAmountChange(buffer.size());
}
diff --git a/pc/sctp_data_channel.h b/pc/sctp_data_channel.h
index 0c3b95a..56f99df 100644
--- a/pc/sctp_data_channel.h
+++ b/pc/sctp_data_channel.h
@@ -266,9 +266,6 @@
uint64_t bytes_sent_ 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;
- // 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_
RTC_GUARDED_BY(signaling_thread_);
HandshakeState handshake_state_ RTC_GUARDED_BY(signaling_thread_) =