| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/iovector.h" | 8 #include "net/quic/iovector.h" |
| 9 #include "net/quic/quic_ack_listener_interface.h" | 9 #include "net/quic/quic_ack_listener_interface.h" |
| 10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (!stream_contributes_to_connection_flow_control_) { | 270 if (!stream_contributes_to_connection_flow_control_) { |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 connection_flow_controller_->MaybeSendBlocked(); | 273 connection_flow_controller_->MaybeSendBlocked(); |
| 274 // If the stream is blocked by connection-level flow control but not by | 274 // If the stream is blocked by connection-level flow control but not by |
| 275 // stream-level flow control, add the stream to the write blocked list so that | 275 // stream-level flow control, add the stream to the write blocked list so that |
| 276 // the stream will be given a chance to write when a connection-level | 276 // the stream will be given a chance to write when a connection-level |
| 277 // WINDOW_UPDATE arrives. | 277 // WINDOW_UPDATE arrives. |
| 278 if (connection_flow_controller_->IsBlocked() && | 278 if (connection_flow_controller_->IsBlocked() && |
| 279 !flow_controller_.IsBlocked()) { | 279 !flow_controller_.IsBlocked()) { |
| 280 session_->MarkConnectionLevelWriteBlocked(id(), EffectivePriority()); | 280 session_->MarkConnectionLevelWriteBlocked(id(), Priority()); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 QuicConsumedData ReliableQuicStream::WritevData( | 284 QuicConsumedData ReliableQuicStream::WritevData( |
| 285 const struct iovec* iov, | 285 const struct iovec* iov, |
| 286 int iov_count, | 286 int iov_count, |
| 287 bool fin, | 287 bool fin, |
| 288 QuicAckListenerInterface* ack_listener) { | 288 QuicAckListenerInterface* ack_listener) { |
| 289 if (write_side_closed_) { | 289 if (write_side_closed_) { |
| 290 DLOG(ERROR) << ENDPOINT << "Attempt to write when the write side is closed"; | 290 DLOG(ERROR) << ENDPOINT << "Attempt to write when the write side is closed"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 318 write_length = static_cast<size_t>(send_window); | 318 write_length = static_cast<size_t>(send_window); |
| 319 } | 319 } |
| 320 | 320 |
| 321 QuicConsumedData consumed_data = session()->WritevData( | 321 QuicConsumedData consumed_data = session()->WritevData( |
| 322 id(), QuicIOVector(iov, iov_count, write_length), stream_bytes_written_, | 322 id(), QuicIOVector(iov, iov_count, write_length), stream_bytes_written_, |
| 323 fin, GetFecProtection(), ack_listener); | 323 fin, GetFecProtection(), ack_listener); |
| 324 stream_bytes_written_ += consumed_data.bytes_consumed; | 324 stream_bytes_written_ += consumed_data.bytes_consumed; |
| 325 | 325 |
| 326 AddBytesSent(consumed_data.bytes_consumed); | 326 AddBytesSent(consumed_data.bytes_consumed); |
| 327 | 327 |
| 328 // The write may have generated a write error causing this stream to be |
| 329 // closed. If so, simply return without marking the stream write blocked. |
| 330 if (write_side_closed_) { |
| 331 return consumed_data; |
| 332 } |
| 333 |
| 328 if (consumed_data.bytes_consumed == write_length) { | 334 if (consumed_data.bytes_consumed == write_length) { |
| 329 if (!fin_with_zero_data) { | 335 if (!fin_with_zero_data) { |
| 330 MaybeSendBlocked(); | 336 MaybeSendBlocked(); |
| 331 } | 337 } |
| 332 if (fin && consumed_data.fin_consumed) { | 338 if (fin && consumed_data.fin_consumed) { |
| 333 fin_sent_ = true; | 339 fin_sent_ = true; |
| 334 if (fin_received_) { | 340 if (fin_received_) { |
| 335 session_->StreamDraining(id_); | 341 session_->StreamDraining(id_); |
| 336 } | 342 } |
| 337 CloseWriteSide(); | 343 CloseWriteSide(); |
| 338 } else if (fin && !consumed_data.fin_consumed) { | 344 } else if (fin && !consumed_data.fin_consumed) { |
| 339 session_->MarkConnectionLevelWriteBlocked(id(), EffectivePriority()); | 345 session_->MarkConnectionLevelWriteBlocked(id(), Priority()); |
| 340 } | 346 } |
| 341 } else { | 347 } else { |
| 342 session_->MarkConnectionLevelWriteBlocked(id(), EffectivePriority()); | 348 session_->MarkConnectionLevelWriteBlocked(id(), Priority()); |
| 343 } | 349 } |
| 344 return consumed_data; | 350 return consumed_data; |
| 345 } | 351 } |
| 346 | 352 |
| 347 FecProtection ReliableQuicStream::GetFecProtection() { | 353 FecProtection ReliableQuicStream::GetFecProtection() { |
| 348 return fec_policy_ == FEC_PROTECT_ALWAYS ? MUST_FEC_PROTECT : MAY_FEC_PROTECT; | 354 return fec_policy_ == FEC_PROTECT_ALWAYS ? MUST_FEC_PROTECT : MAY_FEC_PROTECT; |
| 349 } | 355 } |
| 350 | 356 |
| 351 void ReliableQuicStream::CloseReadSide() { | 357 void ReliableQuicStream::CloseReadSide() { |
| 352 if (read_side_closed_) { | 358 if (read_side_closed_) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 470 } |
| 465 } | 471 } |
| 466 | 472 |
| 467 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { | 473 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { |
| 468 if (flow_controller_.UpdateSendWindowOffset(new_window)) { | 474 if (flow_controller_.UpdateSendWindowOffset(new_window)) { |
| 469 OnCanWrite(); | 475 OnCanWrite(); |
| 470 } | 476 } |
| 471 } | 477 } |
| 472 | 478 |
| 473 } // namespace net | 479 } // namespace net |
| OLD | NEW |