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

Unified Diff: net/http/bidirectional_stream.cc

Issue 1883883002: Log sent and received bytes in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 8 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 | « net/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/bidirectional_stream.cc
diff --git a/net/http/bidirectional_stream.cc b/net/http/bidirectional_stream.cc
index 5c04ca3c2e5b5dff861a5e16a80ebfc05707b695..6e0e78997edcfb0a2e169e0ed76bc6c7d463b084 100644
--- a/net/http/bidirectional_stream.cc
+++ b/net/http/bidirectional_stream.cc
@@ -47,7 +47,8 @@ BidirectionalStream::BidirectionalStream(
NetLog::SOURCE_BIDIRECTIONAL_STREAM)),
session_(session),
delegate_(delegate),
- timer_(std::move(timer)) {
+ timer_(std::move(timer)),
+ write_buffer_len_(0) {
DCHECK(delegate_);
DCHECK(request_info_);
@@ -86,7 +87,15 @@ BidirectionalStream::~BidirectionalStream() {
int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) {
DCHECK(stream_impl_);
- return stream_impl_->ReadData(buf, buf_len);
+ int rv = stream_impl_->ReadData(buf, buf_len);
+ if (rv > 0) {
+ net_log_.AddByteTransferEvent(
+ NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_RECEIVED, rv, buf->data());
+ } else if (rv == ERR_IO_PENDING) {
+ read_buffer_ = buf;
+ // Bytes will be logged in OnDataRead().
+ }
+ return rv;
}
void BidirectionalStream::SendData(IOBuffer* data,
@@ -95,6 +104,8 @@ void BidirectionalStream::SendData(IOBuffer* data,
DCHECK(stream_impl_);
stream_impl_->SendData(data, length, end_stream);
+ write_buffer_ = data;
+ write_buffer_len_ = length;
}
void BidirectionalStream::Cancel() {
@@ -146,10 +157,22 @@ void BidirectionalStream::OnHeadersReceived(
}
void BidirectionalStream::OnDataRead(int bytes_read) {
+ DCHECK(read_buffer_);
+
+ net_log_.AddByteTransferEvent(
+ NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_RECEIVED, bytes_read,
+ read_buffer_->data());
+ read_buffer_ = nullptr;
delegate_->OnDataRead(bytes_read);
}
void BidirectionalStream::OnDataSent() {
+ DCHECK(write_buffer_);
+
+ net_log_.AddByteTransferEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
+ write_buffer_len_, write_buffer_->data());
+ write_buffer_ = nullptr;
+ write_buffer_len_ = 0;
delegate_->OnDataSent();
}
« no previous file with comments | « net/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698