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_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 302 } |
303 | 303 |
304 if (write_length > send_window) { | 304 if (write_length > send_window) { |
305 // Don't send the FIN unless all the data will be sent. | 305 // Don't send the FIN unless all the data will be sent. |
306 fin = false; | 306 fin = false; |
307 | 307 |
308 // Writing more data would be a violation of flow control. | 308 // Writing more data would be a violation of flow control. |
309 write_length = static_cast<size_t>(send_window); | 309 write_length = static_cast<size_t>(send_window); |
310 } | 310 } |
311 | 311 |
312 QuicConsumedData consumed_data = session()->WritevData( | 312 QuicConsumedData consumed_data = |
313 this, id(), QuicIOVector(iov, iov_count, write_length), | 313 WritevDataInner(QuicIOVector(iov, iov_count, write_length), |
314 stream_bytes_written_, fin, ack_listener); | 314 stream_bytes_written_, fin, ack_listener); |
315 stream_bytes_written_ += consumed_data.bytes_consumed; | 315 stream_bytes_written_ += consumed_data.bytes_consumed; |
316 | 316 |
317 AddBytesSent(consumed_data.bytes_consumed); | 317 AddBytesSent(consumed_data.bytes_consumed); |
318 | 318 |
319 // The write may have generated a write error causing this stream to be | 319 // The write may have generated a write error causing this stream to be |
320 // closed. If so, simply return without marking the stream write blocked. | 320 // closed. If so, simply return without marking the stream write blocked. |
321 if (write_side_closed_) { | 321 if (write_side_closed_) { |
322 return consumed_data; | 322 return consumed_data; |
323 } | 323 } |
324 | 324 |
325 if (consumed_data.bytes_consumed == write_length) { | 325 if (consumed_data.bytes_consumed == write_length) { |
326 if (!fin_with_zero_data) { | 326 if (!fin_with_zero_data) { |
327 MaybeSendBlocked(); | 327 MaybeSendBlocked(); |
328 } | 328 } |
329 if (fin && consumed_data.fin_consumed) { | 329 if (fin && consumed_data.fin_consumed) { |
330 fin_sent_ = true; | 330 fin_sent_ = true; |
331 if (fin_received_) { | 331 if (fin_received_) { |
332 session_->StreamDraining(id_); | 332 session_->StreamDraining(id_); |
333 } | 333 } |
334 CloseWriteSide(); | 334 CloseWriteSide(); |
335 } else if (fin && !consumed_data.fin_consumed) { | 335 } else if (fin && !consumed_data.fin_consumed) { |
336 session_->MarkConnectionLevelWriteBlocked(id()); | 336 session_->MarkConnectionLevelWriteBlocked(id()); |
337 } | 337 } |
338 } else { | 338 } else { |
339 session_->MarkConnectionLevelWriteBlocked(id()); | 339 session_->MarkConnectionLevelWriteBlocked(id()); |
340 } | 340 } |
341 return consumed_data; | 341 return consumed_data; |
342 } | 342 } |
343 | 343 |
| 344 QuicConsumedData ReliableQuicStream::WritevDataInner( |
| 345 QuicIOVector iov, |
| 346 QuicStreamOffset offset, |
| 347 bool fin, |
| 348 QuicAckListenerInterface* ack_notifier_delegate) { |
| 349 return session()->WritevData(this, id(), iov, offset, fin, |
| 350 ack_notifier_delegate); |
| 351 } |
| 352 |
344 void ReliableQuicStream::CloseReadSide() { | 353 void ReliableQuicStream::CloseReadSide() { |
345 if (read_side_closed_) { | 354 if (read_side_closed_) { |
346 return; | 355 return; |
347 } | 356 } |
348 DVLOG(1) << ENDPOINT << "Done reading from stream " << id(); | 357 DVLOG(1) << ENDPOINT << "Done reading from stream " << id(); |
349 | 358 |
350 read_side_closed_ = true; | 359 read_side_closed_ = true; |
351 if (write_side_closed_) { | 360 if (write_side_closed_) { |
352 DVLOG(1) << ENDPOINT << "Closing stream: " << id(); | 361 DVLOG(1) << ENDPOINT << "Closing stream: " << id(); |
353 session_->CloseStream(id()); | 362 session_->CloseStream(id()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 466 } |
458 } | 467 } |
459 | 468 |
460 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { | 469 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { |
461 if (flow_controller_.UpdateSendWindowOffset(new_window)) { | 470 if (flow_controller_.UpdateSendWindowOffset(new_window)) { |
462 OnCanWrite(); | 471 OnCanWrite(); |
463 } | 472 } |
464 } | 473 } |
465 | 474 |
466 } // namespace net | 475 } // namespace net |
OLD | NEW |