Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: talk/app/webrtc/datachannel.cc

Issue 1207613006: Support for onbufferedamountlow (Closed) Base URL: https://chromium.googlesource.com/external/webrtc/trunk/talk.git@master
Patch Set: Remove unnecessary comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/datachannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/datachannel.cc
diff --git a/talk/app/webrtc/datachannel.cc b/talk/app/webrtc/datachannel.cc
index 559eec5343f15e3102d5fcd7dbbad0632fdcf847..690ee65d3b713f9f8ee1257b3e48593aaaefd61e 100644
--- a/talk/app/webrtc/datachannel.cc
+++ b/talk/app/webrtc/datachannel.cc
@@ -476,6 +476,7 @@ void DataChannel::SendQueuedDataMessages() {
ASSERT(state_ == kOpen || state_ == kClosing);
+ uint64 start_buffered_amount = buffered_amount();
while (!queued_send_data_.Empty()) {
DataBuffer* buffer = queued_send_data_.Front();
if (!SendDataMessage(*buffer, false)) {
@@ -485,6 +486,10 @@ void DataChannel::SendQueuedDataMessages() {
queued_send_data_.Pop();
delete buffer;
}
+
+ if (observer_ && buffered_amount() < start_buffered_amount) {
+ observer_->OnBufferedAmountChange(start_buffered_amount);
+ }
}
bool DataChannel::SendDataMessage(const DataBuffer& buffer,
@@ -534,11 +539,17 @@ bool DataChannel::SendDataMessage(const DataBuffer& buffer,
}
bool DataChannel::QueueSendDataMessage(const DataBuffer& buffer) {
- if (queued_send_data_.byte_count() >= kMaxQueuedSendDataBytes) {
+ size_t start_buffered_amount = buffered_amount();
+ if (start_buffered_amount >= kMaxQueuedSendDataBytes) {
LOG(LS_ERROR) << "Can't buffer any more data for the data channel.";
return false;
}
queued_send_data_.Push(new DataBuffer(buffer));
+
+ // The buffer can have length zero, in which case there is no change.
+ if (observer_ && buffered_amount() > start_buffered_amount) {
+ observer_->OnBufferedAmountChange(start_buffered_amount);
+ }
return true;
}
« no previous file with comments | « no previous file | talk/app/webrtc/datachannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698