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

Side by Side Diff: net/quic/bidirectional_stream_quic_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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/quic/bidirectional_stream_quic_impl.h" 5 #include "net/quic/bidirectional_stream_quic_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/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 return rv; 91 return rv;
92 } 92 }
93 // Read will complete asynchronously and Delegate::OnReadCompleted will be 93 // Read will complete asynchronously and Delegate::OnReadCompleted will be
94 // called upon completion. 94 // called upon completion.
95 read_buffer_ = buffer; 95 read_buffer_ = buffer;
96 read_buffer_len_ = buffer_len; 96 read_buffer_len_ = buffer_len;
97 return ERR_IO_PENDING; 97 return ERR_IO_PENDING;
98 } 98 }
99 99
100 void BidirectionalStreamQuicImpl::SendData(IOBuffer* data, 100 void BidirectionalStreamQuicImpl::SendData(const scoped_refptr<IOBuffer>& data,
101 int length, 101 int length,
102 bool end_stream) { 102 bool end_stream) {
103 DCHECK(stream_); 103 DCHECK(stream_);
104 DCHECK(length > 0 || (length == 0 && end_stream)); 104 DCHECK(length > 0 || (length == 0 && end_stream));
105 105
106 base::StringPiece string_data(data->data(), length); 106 base::StringPiece string_data(data->data(), length);
107 int rv = stream_->WriteStreamData( 107 int rv = stream_->WriteStreamData(
108 string_data, end_stream, 108 string_data, end_stream,
109 base::Bind(&BidirectionalStreamQuicImpl::OnSendDataComplete, 109 base::Bind(&BidirectionalStreamQuicImpl::OnSendDataComplete,
110 weak_factory_.GetWeakPtr())); 110 weak_factory_.GetWeakPtr()));
111 DCHECK(rv == OK || rv == ERR_IO_PENDING); 111 DCHECK(rv == OK || rv == ERR_IO_PENDING);
112 if (rv == OK) { 112 if (rv == OK) {
113 base::ThreadTaskRunnerHandle::Get()->PostTask( 113 base::ThreadTaskRunnerHandle::Get()->PostTask(
114 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::OnSendDataComplete, 114 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::OnSendDataComplete,
115 weak_factory_.GetWeakPtr(), OK)); 115 weak_factory_.GetWeakPtr(), OK));
116 } 116 }
117 } 117 }
118 118
119 void BidirectionalStreamQuicImpl::SendvData( 119 void BidirectionalStreamQuicImpl::SendvData(
120 const std::vector<IOBuffer*>& buffers, 120 const std::vector<scoped_refptr<IOBuffer>>& buffers,
121 const std::vector<int>& lengths, 121 const std::vector<int>& lengths,
122 bool end_stream) { 122 bool end_stream) {
123 DCHECK(stream_); 123 DCHECK(stream_);
124 DCHECK_EQ(buffers.size(), lengths.size()); 124 DCHECK_EQ(buffers.size(), lengths.size());
125 125
126 QuicConnection::ScopedPacketBundler bundler( 126 QuicConnection::ScopedPacketBundler bundler(
127 session_->connection(), QuicConnection::SEND_ACK_IF_PENDING); 127 session_->connection(), QuicConnection::SEND_ACK_IF_PENDING);
128 if (!has_sent_headers_) { 128 if (!has_sent_headers_) {
129 SendRequestHeaders(); 129 SendRequestHeaders();
130 } 130 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 void BidirectionalStreamQuicImpl::ResetStream() { 287 void BidirectionalStreamQuicImpl::ResetStream() {
288 if (!stream_) 288 if (!stream_)
289 return; 289 return;
290 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 290 closed_stream_received_bytes_ = stream_->stream_bytes_read();
291 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 291 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
292 stream_->SetDelegate(nullptr); 292 stream_->SetDelegate(nullptr);
293 stream_ = nullptr; 293 stream_ = nullptr;
294 } 294 }
295 295
296 } // namespace net 296 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/bidirectional_stream_quic_impl.h ('k') | net/quic/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698