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

Side by Side Diff: net/http/bidirectional_stream.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/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_impl.h » ('j') | 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/http/bidirectional_stream.h" 5 #include "net/http/bidirectional_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (rv > 0) { 138 if (rv > 0) {
139 net_log_.AddByteTransferEvent( 139 net_log_.AddByteTransferEvent(
140 NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_RECEIVED, rv, buf->data()); 140 NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_RECEIVED, rv, buf->data());
141 } else if (rv == ERR_IO_PENDING) { 141 } else if (rv == ERR_IO_PENDING) {
142 read_buffer_ = buf; 142 read_buffer_ = buf;
143 // Bytes will be logged in OnDataRead(). 143 // Bytes will be logged in OnDataRead().
144 } 144 }
145 return rv; 145 return rv;
146 } 146 }
147 147
148 void BidirectionalStream::SendData(IOBuffer* data, 148 void BidirectionalStream::SendData(const scoped_refptr<IOBuffer>& data,
149 int length, 149 int length,
150 bool end_stream) { 150 bool end_stream) {
151 DCHECK(stream_impl_); 151 DCHECK(stream_impl_);
152 DCHECK(write_buffer_list_.empty()); 152 DCHECK(write_buffer_list_.empty());
153 DCHECK(write_buffer_len_list_.empty()); 153 DCHECK(write_buffer_len_list_.empty());
154 154
155 stream_impl_->SendData(data, length, end_stream); 155 stream_impl_->SendData(data, length, end_stream);
156 write_buffer_list_.push_back(data); 156 write_buffer_list_.push_back(data);
157 write_buffer_len_list_.push_back(length); 157 write_buffer_len_list_.push_back(length);
158 } 158 }
159 159
160 void BidirectionalStream::SendvData(const std::vector<IOBuffer*>& buffers, 160 void BidirectionalStream::SendvData(
161 const std::vector<int>& lengths, 161 const std::vector<scoped_refptr<IOBuffer>>& buffers,
162 bool end_stream) { 162 const std::vector<int>& lengths,
163 bool end_stream) {
163 DCHECK(stream_impl_); 164 DCHECK(stream_impl_);
164 DCHECK_EQ(buffers.size(), lengths.size()); 165 DCHECK_EQ(buffers.size(), lengths.size());
165 DCHECK(write_buffer_list_.empty()); 166 DCHECK(write_buffer_list_.empty());
166 DCHECK(write_buffer_len_list_.empty()); 167 DCHECK(write_buffer_len_list_.empty());
167 168
168 stream_impl_->SendvData(buffers, lengths, end_stream); 169 stream_impl_->SendvData(buffers, lengths, end_stream);
169 for (size_t i = 0; i < buffers.size(); ++i) { 170 for (size_t i = 0; i < buffers.size(); ++i) {
170 write_buffer_list_.push_back(buffers[i]); 171 write_buffer_list_.push_back(buffers[i]);
171 write_buffer_len_list_.push_back(lengths[i]); 172 write_buffer_len_list_.push_back(lengths[i]);
172 } 173 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const ProxyInfo& used_proxy_info, 332 const ProxyInfo& used_proxy_info,
332 HttpStream* stream) { 333 HttpStream* stream) {
333 DCHECK(stream_request_); 334 DCHECK(stream_request_);
334 335
335 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); 336 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
336 } 337 }
337 338
338 void BidirectionalStream::OnQuicBroken() {} 339 void BidirectionalStream::OnQuicBroken() {}
339 340
340 } // namespace net 341 } // namespace net
OLDNEW
« 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