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

Side by Side Diff: net/spdy/bidirectional_stream_spdy_impl.cc

Issue 1969893002: Remove unnecessary array allocation in cronet_bidirectional_stream_adapter.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add include vector Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « net/spdy/bidirectional_stream_spdy_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/bidirectional_stream_spdy_impl.h" 5 #include "net/spdy/bidirectional_stream_spdy_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } else if (stream_closed_) { 91 } else if (stream_closed_) {
92 return closed_stream_status_; 92 return closed_stream_status_;
93 } 93 }
94 // Read will complete asynchronously and Delegate::OnReadCompleted will be 94 // Read will complete asynchronously and Delegate::OnReadCompleted will be
95 // called upon completion. 95 // called upon completion.
96 read_buffer_ = buf; 96 read_buffer_ = buf;
97 read_buffer_len_ = buf_len; 97 read_buffer_len_ = buf_len;
98 return ERR_IO_PENDING; 98 return ERR_IO_PENDING;
99 } 99 }
100 100
101 void BidirectionalStreamSpdyImpl::SendData(IOBuffer* data, 101 void BidirectionalStreamSpdyImpl::SendData(const scoped_refptr<IOBuffer>& data,
102 int length, 102 int length,
103 bool end_stream) { 103 bool end_stream) {
104 DCHECK(!stream_closed_); 104 DCHECK(!stream_closed_);
105 DCHECK(stream_); 105 DCHECK(stream_);
106 DCHECK(!disable_auto_flush_); 106 DCHECK(!disable_auto_flush_);
107 107
108 stream_->SendData(data, length, 108 stream_->SendData(data.get(), length,
109 end_stream ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND); 109 end_stream ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND);
110 } 110 }
111 111
112 void BidirectionalStreamSpdyImpl::SendvData( 112 void BidirectionalStreamSpdyImpl::SendvData(
113 const std::vector<IOBuffer*>& buffers, 113 const std::vector<scoped_refptr<IOBuffer>>& buffers,
114 const std::vector<int>& lengths, 114 const std::vector<int>& lengths,
115 bool end_stream) { 115 bool end_stream) {
116 DCHECK(!stream_closed_); 116 DCHECK(!stream_closed_);
117 DCHECK(stream_); 117 DCHECK(stream_);
118 DCHECK(disable_auto_flush_); 118 DCHECK(disable_auto_flush_);
119 DCHECK_EQ(buffers.size(), lengths.size()); 119 DCHECK_EQ(buffers.size(), lengths.size());
120 120
121 int total_len = 0; 121 int total_len = 0;
122 for (int len : lengths) { 122 for (int len : lengths) {
123 total_len += len; 123 total_len += len;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const { 307 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const {
308 if (stream_closed_) 308 if (stream_closed_)
309 return false; 309 return false;
310 DCHECK_GT(read_buffer_len_, 0); 310 DCHECK_GT(read_buffer_len_, 0);
311 return read_data_queue_.GetTotalSize() < 311 return read_data_queue_.GetTotalSize() <
312 static_cast<size_t>(read_buffer_len_); 312 static_cast<size_t>(read_buffer_len_);
313 } 313 }
314 314
315 } // namespace net 315 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/bidirectional_stream_spdy_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698