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

Unified Diff: webrtc/api/datachannel.cc

Issue 2413803002: DataChannel[Interface]::[message/bytes]_[sent/received]() added. (Closed)
Patch Set: Addressed comments Created 4 years, 2 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 | « webrtc/api/datachannel.h ('k') | webrtc/api/datachannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/datachannel.cc
diff --git a/webrtc/api/datachannel.cc b/webrtc/api/datachannel.cc
index 066e60c2ee06a504aa96e326d207ae53870fd2c3..af694b7b1c4324d504aaf39947f3dd7536e96609 100644
--- a/webrtc/api/datachannel.cc
+++ b/webrtc/api/datachannel.cc
@@ -126,8 +126,12 @@ DataChannel::DataChannel(
cricket::DataChannelType dct,
const std::string& label)
: label_(label),
- observer_(NULL),
+ observer_(nullptr),
state_(kConnecting),
+ messages_sent_(0),
+ bytes_sent_(0),
+ messages_received_(0),
+ bytes_received_(0),
data_channel_type_(dct),
provider_(provider),
handshake_state_(kHandshakeInit),
@@ -367,6 +371,8 @@ void DataChannel::OnDataReceived(cricket::DataChannel* channel,
bool binary = (params.type == cricket::DMT_BINARY);
std::unique_ptr<DataBuffer> buffer(new DataBuffer(payload, binary));
if (state_ == kOpen && observer_) {
+ ++messages_received_;
+ bytes_received_ += buffer->size();
observer_->OnMessage(*buffer.get());
} else {
if (queued_received_data_.byte_count() + payload.size() >
@@ -498,6 +504,8 @@ void DataChannel::DeliverQueuedReceivedData() {
while (!queued_received_data_.Empty()) {
std::unique_ptr<DataBuffer> buffer(queued_received_data_.Front());
+ ++messages_received_;
+ bytes_received_ += buffer->size();
observer_->OnMessage(*buffer);
queued_received_data_.Pop();
}
@@ -551,6 +559,8 @@ bool DataChannel::SendDataMessage(const DataBuffer& buffer,
bool success = provider_->SendData(send_params, buffer.data, &send_result);
if (success) {
+ ++messages_sent_;
+ bytes_sent_ += buffer.size();
return true;
}
« no previous file with comments | « webrtc/api/datachannel.h ('k') | webrtc/api/datachannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698