| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |