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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 | 301 |
302 if (write_length > send_window) { | 302 if (write_length > send_window) { |
303 // Don't send the FIN unless all the data will be sent. | 303 // Don't send the FIN unless all the data will be sent. |
304 fin = false; | 304 fin = false; |
305 | 305 |
306 // Writing more data would be a violation of flow control. | 306 // Writing more data would be a violation of flow control. |
307 write_length = static_cast<size_t>(send_window); | 307 write_length = static_cast<size_t>(send_window); |
308 } | 308 } |
309 | 309 |
310 QuicConsumedData consumed_data = | 310 QuicConsumedData consumed_data = session()->WritevData( |
311 session()->WritevData(id(), QuicIOVector(iov, iov_count, write_length), | 311 this, id(), QuicIOVector(iov, iov_count, write_length), |
312 stream_bytes_written_, fin, ack_listener); | 312 stream_bytes_written_, fin, ack_listener); |
313 stream_bytes_written_ += consumed_data.bytes_consumed; | 313 stream_bytes_written_ += consumed_data.bytes_consumed; |
314 | 314 |
315 AddBytesSent(consumed_data.bytes_consumed); | 315 AddBytesSent(consumed_data.bytes_consumed); |
316 | 316 |
317 // The write may have generated a write error causing this stream to be | 317 // The write may have generated a write error causing this stream to be |
318 // closed. If so, simply return without marking the stream write blocked. | 318 // closed. If so, simply return without marking the stream write blocked. |
319 if (write_side_closed_) { | 319 if (write_side_closed_) { |
320 return consumed_data; | 320 return consumed_data; |
321 } | 321 } |
322 | 322 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 371 |
372 QuicVersion ReliableQuicStream::version() const { | 372 QuicVersion ReliableQuicStream::version() const { |
373 return session_->connection()->version(); | 373 return session_->connection()->version(); |
374 } | 374 } |
375 | 375 |
376 void ReliableQuicStream::StopReading() { | 376 void ReliableQuicStream::StopReading() { |
377 DVLOG(1) << ENDPOINT << "Stop reading from stream " << id(); | 377 DVLOG(1) << ENDPOINT << "Stop reading from stream " << id(); |
378 sequencer_.StopReading(); | 378 sequencer_.StopReading(); |
379 } | 379 } |
380 | 380 |
| 381 const IPEndPoint& ReliableQuicStream::PeerAddressOfLatestPacket() const { |
| 382 return session_->connection()->last_packet_source_address(); |
| 383 } |
| 384 |
381 void ReliableQuicStream::OnClose() { | 385 void ReliableQuicStream::OnClose() { |
382 CloseReadSide(); | 386 CloseReadSide(); |
383 CloseWriteSide(); | 387 CloseWriteSide(); |
384 | 388 |
385 if (!fin_sent_ && !rst_sent_) { | 389 if (!fin_sent_ && !rst_sent_) { |
386 // For flow control accounting, tell the peer how many bytes have been | 390 // For flow control accounting, tell the peer how many bytes have been |
387 // written on this stream before termination. Done here if needed, using a | 391 // written on this stream before termination. Done here if needed, using a |
388 // RST_STREAM frame. | 392 // RST_STREAM frame. |
389 DVLOG(1) << ENDPOINT << "Sending RST_STREAM in OnClose: " << id(); | 393 DVLOG(1) << ENDPOINT << "Sending RST_STREAM in OnClose: " << id(); |
390 session_->SendRstStream(id(), QUIC_RST_ACKNOWLEDGEMENT, | 394 session_->SendRstStream(id(), QUIC_RST_ACKNOWLEDGEMENT, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 455 } |
452 } | 456 } |
453 | 457 |
454 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { | 458 void ReliableQuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { |
455 if (flow_controller_.UpdateSendWindowOffset(new_window)) { | 459 if (flow_controller_.UpdateSendWindowOffset(new_window)) { |
456 OnCanWrite(); | 460 OnCanWrite(); |
457 } | 461 } |
458 } | 462 } |
459 | 463 |
460 } // namespace net | 464 } // namespace net |
OLD | NEW |