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

Unified Diff: net/http/bidirectional_stream.cc

Issue 1856073002: Coalesce small buffers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix javadoc 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_impl.h » ('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 9b588f18459b236636c32c1f59f1be430a2ddd44..602349fd50b6275b79c01b5b55c6deeb28215139 100644
--- a/net/http/bidirectional_stream.cc
+++ b/net/http/bidirectional_stream.cc
@@ -28,29 +28,34 @@ namespace net {
BidirectionalStream::Delegate::Delegate() {}
+void BidirectionalStream::Delegate::OnStreamReady() {}
+
BidirectionalStream::Delegate::~Delegate() {}
BidirectionalStream::BidirectionalStream(
std::unique_ptr<BidirectionalStreamRequestInfo> request_info,
HttpNetworkSession* session,
+ bool disable_auto_flush,
Delegate* delegate)
: BidirectionalStream(std::move(request_info),
session,
+ disable_auto_flush,
delegate,
base::WrapUnique(new base::Timer(false, false))) {}
BidirectionalStream::BidirectionalStream(
std::unique_ptr<BidirectionalStreamRequestInfo> request_info,
HttpNetworkSession* session,
+ bool disable_auto_flush,
Delegate* delegate,
std::unique_ptr<base::Timer> timer)
: request_info_(std::move(request_info)),
net_log_(BoundNetLog::Make(session->net_log(),
NetLog::SOURCE_BIDIRECTIONAL_STREAM)),
session_(session),
+ disable_auto_flush_(disable_auto_flush),
delegate_(delegate),
- timer_(std::move(timer)),
- write_buffer_len_(0) {
+ timer_(std::move(timer)) {
DCHECK(delegate_);
DCHECK(request_info_);
@@ -104,10 +109,27 @@ void BidirectionalStream::SendData(IOBuffer* data,
int length,
bool end_stream) {
DCHECK(stream_impl_);
+ DCHECK(write_buffer_list_.empty());
+ DCHECK(write_buffer_len_list_.empty());
stream_impl_->SendData(data, length, end_stream);
- write_buffer_ = data;
- write_buffer_len_ = length;
+ write_buffer_list_.push_back(data);
+ write_buffer_len_list_.push_back(length);
+}
+
+void BidirectionalStream::SendvData(const std::vector<IOBuffer*>& buffers,
+ const std::vector<int>& lengths,
+ bool end_stream) {
+ DCHECK(stream_impl_);
+ DCHECK_EQ(buffers.size(), lengths.size());
+ DCHECK(write_buffer_list_.empty());
+ DCHECK(write_buffer_len_list_.empty());
+
+ stream_impl_->SendvData(buffers, lengths, end_stream);
+ for (size_t i = 0; i < buffers.size(); ++i) {
+ write_buffer_list_.push_back(buffers[i]);
+ write_buffer_len_list_.push_back(lengths[i]);
+ }
}
void BidirectionalStream::Cancel() {
@@ -139,8 +161,8 @@ int64_t BidirectionalStream::GetTotalSentBytes() const {
return stream_impl_->GetTotalSentBytes();
}
-void BidirectionalStream::OnHeadersSent() {
- delegate_->OnHeadersSent();
+void BidirectionalStream::OnStreamReady() {
+ delegate_->OnStreamReady();
}
void BidirectionalStream::OnHeadersReceived(
@@ -169,12 +191,16 @@ void BidirectionalStream::OnDataRead(int bytes_read) {
}
void BidirectionalStream::OnDataSent() {
- DCHECK(write_buffer_);
+ DCHECK(!write_buffer_list_.empty());
+ DCHECK_EQ(write_buffer_list_.size(), write_buffer_len_list_.size());
- net_log_.AddByteTransferEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
- write_buffer_len_, write_buffer_->data());
- write_buffer_ = nullptr;
- write_buffer_len_ = 0;
+ for (size_t i = 0; i < write_buffer_list_.size(); ++i) {
+ net_log_.AddByteTransferEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
+ write_buffer_len_list_[i],
+ write_buffer_list_[i]->data());
+ }
+ write_buffer_list_.clear();
+ write_buffer_len_list_.clear();
delegate_->OnDataSent();
}
@@ -200,7 +226,8 @@ void BidirectionalStream::OnBidirectionalStreamImplReady(
stream_request_.reset();
stream_impl_.reset(stream);
- stream_impl_->Start(request_info_.get(), net_log_, this, std::move(timer_));
+ stream_impl_->Start(request_info_.get(), net_log_, disable_auto_flush_, this,
+ std::move(timer_));
}
void BidirectionalStream::OnWebSocketHandshakeStreamReady(
« no previous file with comments | « net/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698