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; |
} |