| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_session.h" | 7 #include "net/quic/quic_session.h" |
| 8 #include "net/quic/quic_spdy_decompressor.h" | 8 #include "net/quic/quic_spdy_decompressor.h" |
| 9 #include "net/spdy/write_blocked_list.h" | 9 #include "net/spdy/write_blocked_list.h" |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 QuicConsumedData ReliableQuicStream::WriteDataInternal( | 243 QuicConsumedData ReliableQuicStream::WriteDataInternal( |
| 244 StringPiece data, bool fin) { | 244 StringPiece data, bool fin) { |
| 245 struct iovec iov = {const_cast<char*>(data.data()), | 245 struct iovec iov = {const_cast<char*>(data.data()), |
| 246 static_cast<size_t>(data.size())}; | 246 static_cast<size_t>(data.size())}; |
| 247 return WritevDataInternal(&iov, 1, fin); | 247 return WritevDataInternal(&iov, 1, fin); |
| 248 } | 248 } |
| 249 | 249 |
| 250 QuicConsumedData ReliableQuicStream::WritevDataInternal(const struct iovec* iov, | 250 QuicConsumedData ReliableQuicStream::WritevDataInternal(const struct iovec* iov, |
| 251 int count, | 251 int iov_count, |
| 252 bool fin) { | 252 bool fin) { |
| 253 if (write_side_closed_) { | 253 if (write_side_closed_) { |
| 254 DLOG(ERROR) << "Attempt to write when the write side is closed"; | 254 DLOG(ERROR) << "Attempt to write when the write side is closed"; |
| 255 return QuicConsumedData(0, false); | 255 return QuicConsumedData(0, false); |
| 256 } | 256 } |
| 257 | 257 |
| 258 size_t write_length = 0u; | 258 size_t write_length = 0u; |
| 259 for (int i = 0; i < count; ++i) { | 259 for (int i = 0; i < iov_count; ++i) { |
| 260 write_length += iov[i].iov_len; | 260 write_length += iov[i].iov_len; |
| 261 } | 261 } |
| 262 QuicConsumedData consumed_data = | 262 QuicConsumedData consumed_data = |
| 263 session()->WritevData(id(), iov, count, stream_bytes_written_, fin); | 263 session()->WritevData(id(), iov, iov_count, stream_bytes_written_, fin); |
| 264 stream_bytes_written_ += consumed_data.bytes_consumed; | 264 stream_bytes_written_ += consumed_data.bytes_consumed; |
| 265 if (consumed_data.bytes_consumed == write_length) { | 265 if (consumed_data.bytes_consumed == write_length) { |
| 266 if (fin && consumed_data.fin_consumed) { | 266 if (fin && consumed_data.fin_consumed) { |
| 267 fin_sent_ = true; | 267 fin_sent_ = true; |
| 268 CloseWriteSide(); | 268 CloseWriteSide(); |
| 269 } else if (fin && !consumed_data.fin_consumed) { | 269 } else if (fin && !consumed_data.fin_consumed) { |
| 270 session_->MarkWriteBlocked(id(), EffectivePriority()); | 270 session_->MarkWriteBlocked(id(), EffectivePriority()); |
| 271 } | 271 } |
| 272 } else { | 272 } else { |
| 273 session_->MarkWriteBlocked(id(), EffectivePriority()); | 273 session_->MarkWriteBlocked(id(), EffectivePriority()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 286 DLOG(INFO) << "Done reading from stream " << id(); | 286 DLOG(INFO) << "Done reading from stream " << id(); |
| 287 | 287 |
| 288 read_side_closed_ = true; | 288 read_side_closed_ = true; |
| 289 if (write_side_closed_) { | 289 if (write_side_closed_) { |
| 290 DLOG(INFO) << "Closing stream: " << id(); | 290 DLOG(INFO) << "Closing stream: " << id(); |
| 291 session_->CloseStream(id()); | 291 session_->CloseStream(id()); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 uint32 ReliableQuicStream::ProcessRawData(const char* data, uint32 data_len) { | 295 uint32 ReliableQuicStream::ProcessRawData(const char* data, uint32 data_len) { |
| 296 DCHECK_NE(0u, data_len); |
| 296 if (id() == kCryptoStreamId) { | 297 if (id() == kCryptoStreamId) { |
| 297 if (data_len == 0) { | |
| 298 return 0; | |
| 299 } | |
| 300 // The crypto stream does not use compression. | 298 // The crypto stream does not use compression. |
| 301 return ProcessData(data, data_len); | 299 return ProcessData(data, data_len); |
| 302 } | 300 } |
| 303 | 301 |
| 304 uint32 total_bytes_consumed = 0; | 302 uint32 total_bytes_consumed = 0; |
| 305 if (headers_id_ == 0u) { | 303 if (headers_id_ == 0u) { |
| 306 total_bytes_consumed += StripPriorityAndHeaderId(data, data_len); | 304 total_bytes_consumed += StripPriorityAndHeaderId(data, data_len); |
| 307 data += total_bytes_consumed; | 305 data += total_bytes_consumed; |
| 308 data_len -= total_bytes_consumed; | 306 data_len -= total_bytes_consumed; |
| 309 if (data_len == 0 || !session_->connection()->connected()) { | 307 if (data_len == 0 || !session_->connection()->connected()) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 if (data_len > 0 && headers_id_ == 0u) { | 505 if (data_len > 0 && headers_id_ == 0u) { |
| 508 // The headers ID has not yet been read. Strip it from the beginning of | 506 // The headers ID has not yet been read. Strip it from the beginning of |
| 509 // the data stream. | 507 // the data stream. |
| 510 total_bytes_parsed += StripUint32( | 508 total_bytes_parsed += StripUint32( |
| 511 data, data_len, &headers_id_and_priority_buffer_, &headers_id_); | 509 data, data_len, &headers_id_and_priority_buffer_, &headers_id_); |
| 512 } | 510 } |
| 513 return total_bytes_parsed; | 511 return total_bytes_parsed; |
| 514 } | 512 } |
| 515 | 513 |
| 516 } // namespace net | 514 } // namespace net |
| OLD | NEW |